Snap for 10321980 from fab96d98127b722c4be452dfc24a1ff629d36f79 to ndk-r26-release

Change-Id: Ib2e12df680c393f8b2c8c4a3f0464b8fbaf6a501
diff --git a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
index 5347087..8f4eacd 100644
--- a/cc_toolchain_config.bzl
+++ b/cc_toolchain_config.bzl
@@ -26,6 +26,7 @@
     "get_features",
     "int_overflow_ignorelist_filename",
     "int_overflow_ignorelist_path",
+    "sanitizer_blocklist_dict",
 )
 load("//build/bazel/platforms/arch/variants:constants.bzl", _arch_constants = "constants")
 
@@ -516,6 +517,9 @@
             "%s_compiler_binaries" % name,
             "%s_compiler_clang_includes" % name,
             "@//%s:%s" % (int_overflow_ignorelist_path, int_overflow_ignorelist_filename),
+        ] + [
+            "@//%s:%s" % (blocklist[0], blocklist[1])
+            for blocklist in sanitizer_blocklist_dict.items()
         ],
     )
 
diff --git a/cc_toolchain_features.bzl b/cc_toolchain_features.bzl
index 902992e..9c5a1bf 100644
--- a/cc_toolchain_features.bzl
+++ b/cc_toolchain_features.bzl
@@ -1821,6 +1821,80 @@
 int_overflow_ignorelist_path = "build/soong/cc/config"
 int_overflow_ignorelist_filename = "integer_overflow_blocklist.txt"
 
+def _get_unsupported_integer_check_with_feature_sets(feature_check):
+    integer_sanitizers = [
+        "implicit-unsigned-integer-truncation",
+        "implicit-signed-integer-truncation",
+        "implicit-integer-sign-change",
+        "integer-divide-by-zero",
+        "signed-integer-overflow",
+        "unsigned-integer-overflow",
+        "implicit-integer-truncation",
+        "implicit-integer-arithmetic-value-change",
+        "integer",
+        "integer_overflow",
+    ]
+    if feature_check in integer_sanitizers:
+        integer_sanitizers.remove(feature_check)
+
+    return [
+        with_feature_set(
+            features = ["ubsan_" + integer_sanitizer],
+            not_features = ["ubsan_" + feature_check],
+        )
+        for integer_sanitizer in integer_sanitizers
+    ]
+
+# The key of this dict is the package path to the blocklist, while the value is
+# its filename.
+# TODO: b/286872909 - When the blocking bug is complete, put these in their
+#                     respective packages
+sanitizer_blocklist_dict = {
+    "external/libavc": "libavc_blocklist.txt",
+    "external/libaom": "libaom_blocklist.txt",
+    "external/libvpx": "libvpx_blocklist.txt",
+    "frameworks/base/libs/androidfw": "libandroidfw_blocklist.txt",
+    "external/libhevc": "libhevc_blocklist.txt",
+    "external/libexif": "libexif_blocklist.txt",
+    "external/libopus": "libopus_blocklist.txt",
+    "external/libmpeg2": "libmpeg2dec_blocklist.txt",
+    "external/expat": "libexpat_blocklist.txt",
+    "external/flac/src/libFLAC": "libFLAC_blocklist.txt",
+    "system/extras/toolchain-extras": "libprofile_clang_extras_blocklist.txt",
+}
+
+def _get_ubsan_blocklist_features():
+    features = []
+    for blocklist in sanitizer_blocklist_dict.items():
+        # Format the blocklist name to be used in a feature name
+        blocklist_feature_name_suffix = blocklist[1].lower().replace(".", "_")
+        features.append(
+            feature(
+                name = "ubsan_blocklist_" + blocklist_feature_name_suffix,
+                enabled = False,
+                requires = [
+                    feature_set(features = ["ubsan_enabled"]),
+                ],
+                flag_sets = [
+                    flag_set(
+                        actions = _actions.c_and_cpp_compile,
+                        flag_groups = [
+                            flag_group(
+                                flags = [
+                                    "%s%s/%s" % (
+                                        _generated_sanitizer_constants.SanitizeIgnorelistPrefix,
+                                        blocklist[0],
+                                        blocklist[1],
+                                    ),
+                                ],
+                            ),
+                        ],
+                    ),
+                ],
+            ),
+        )
+    return features
+
 def _get_ubsan_features(target_os, libclang_rt_ubsan_minimal):
     if target_os in [_oses.Windows, _oses.Darwin]:
         return []
@@ -2031,14 +2105,9 @@
                             ],
                         ),
                     ],
-                    with_features = [
-                        with_feature_set(
-                            features = ["ubsan_integer"],
-                            not_features = [
-                                "ubsan_implicit-integer-sign-change",
-                            ],
-                        ),
-                    ],
+                    with_features = _get_unsupported_integer_check_with_feature_sets(
+                        "implicit-integer-sign-change",
+                    ),
                 ),
                 # TODO(b/171275751): If this bug is fixed, this shouldn't be
                 #                    needed anymore
@@ -2051,19 +2120,16 @@
                             ],
                         ),
                     ],
-                    with_features = [
-                        with_feature_set(
-                            features = ["ubsan_integer"],
-                            not_features = [
-                                "ubsan_unsigned-shift-base",
-                            ],
-                        ),
-                    ],
+                    with_features = _get_unsupported_integer_check_with_feature_sets(
+                        "unsigned-shift-base",
+                    ),
                 ),
             ],
         ),
     )
 
+    ubsan_features.extend(_get_ubsan_blocklist_features())
+
     return ubsan_features
 
 def _manual_binder_interface_feature():
diff --git a/clang-r487747c/bin/llvm-dlltool b/clang-r487747c/bin/llvm-dlltool
new file mode 120000
index 0000000..3b94d1a
--- /dev/null
+++ b/clang-r487747c/bin/llvm-dlltool
@@ -0,0 +1 @@
+llvm-ar
\ No newline at end of file
diff --git a/kleaf/BUILD.bazel b/kleaf/BUILD.bazel
index 4454530..28b96cc 100644
--- a/kleaf/BUILD.bazel
+++ b/kleaf/BUILD.bazel
@@ -20,6 +20,7 @@
 load(
     ":clang_toolchain.bzl",
     "android_arm64_clang_toolchain",
+    "android_arm_clang_toolchain",
     "android_riscv64_clang_toolchain",
     "android_x86_64_clang_toolchain",
     "linux_x86_64_clang_toolchain",
@@ -51,6 +52,11 @@
     clang_version = VARS["CLANG_VERSION"],
 )
 
+android_arm_clang_toolchain(
+    name = "android_arm_clang_toolchain",
+    clang_version = VARS["CLANG_VERSION"],
+)
+
 android_x86_64_clang_toolchain(
     name = "android_x86_64_clang_toolchain",
     clang_version = VARS["CLANG_VERSION"],
@@ -83,6 +89,12 @@
     extra_compatible_with = [version],
 ) for version in VERSIONS]
 
+[android_arm_clang_toolchain(
+    name = version + "_android_arm_clang_toolchain",
+    clang_version = version,
+    extra_compatible_with = [version],
+) for version in VERSIONS]
+
 [android_x86_64_clang_toolchain(
     name = version + "_android_x86_64_clang_toolchain",
     clang_version = version,
diff --git a/kleaf/clang_config.bzl b/kleaf/clang_config.bzl
index 1fc3bb3..ac3afea 100644
--- a/kleaf/clang_config.bzl
+++ b/kleaf/clang_config.bzl
@@ -51,6 +51,7 @@
     attrs = {
         "target_cpu": attr.string(mandatory = True, values = [
             "arm64",
+            "arm",
             "riscv64",
             "x86_64",
         ]),
diff --git a/kleaf/clang_toolchain.bzl b/kleaf/clang_toolchain.bzl
index 56e3922..a47b230 100644
--- a/kleaf/clang_toolchain.bzl
+++ b/kleaf/clang_toolchain.bzl
@@ -207,6 +207,30 @@
         extra_compatible_with = extra_compatible_with,
     )
 
+def android_arm_clang_toolchain(
+        name,
+        clang_version,
+        extra_compatible_with = None):
+    """Declare an android_arm (32-bit) toolchain.
+
+    Args:
+        name: name prefix
+        clang_version: `CLANG_VERSION`
+        extra_compatible_with: extra `exec_compatible_with` and `target_compatible_with`
+    """
+    clang_toolchain(
+        name = name,
+        clang_version = clang_version,
+        ndk_triple = VARS.get("ARM_NDK_TRIPLE"),
+        # From _setup_env.sh: when NDK triple is set,
+        # --sysroot=${NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/sysroot
+        sysroot_label = "@prebuilt_ndk//:sysroot" if "ARM_NDK_TRIPLE" in VARS else None,
+        sysroot_path = "external/prebuilt_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot" if "AARCH64_NDK_TRIPLE" in VARS else None,
+        target_cpu = "arm",
+        target_os = "android",
+        extra_compatible_with = extra_compatible_with,
+    )
+
 def android_x86_64_clang_toolchain(
         name,
         clang_version,
diff --git a/kleaf/register.bzl b/kleaf/register.bzl
index a1d01fc..264568b 100644
--- a/kleaf/register.bzl
+++ b/kleaf/register.bzl
@@ -22,6 +22,7 @@
     for version in VERSIONS:
         native.register_toolchains(
             "//prebuilts/clang/host/linux-x86/kleaf:{}_android_arm64_clang_toolchain".format(version),
+            "//prebuilts/clang/host/linux-x86/kleaf:{}_android_arm_clang_toolchain".format(version),
             "//prebuilts/clang/host/linux-x86/kleaf:{}_android_x86_64_clang_toolchain".format(version),
             "//prebuilts/clang/host/linux-x86/kleaf:{}_android_riscv64_clang_toolchain".format(version),
             "//prebuilts/clang/host/linux-x86/kleaf:{}_linux_x86_64_clang_toolchain".format(version),
@@ -29,6 +30,7 @@
 
     native.register_toolchains(
         "//prebuilts/clang/host/linux-x86/kleaf:android_arm64_clang_toolchain",
+        "//prebuilts/clang/host/linux-x86/kleaf:android_arm_clang_toolchain",
         "//prebuilts/clang/host/linux-x86/kleaf:android_x86_64_clang_toolchain",
         "//prebuilts/clang/host/linux-x86/kleaf:android_riscv64_clang_toolchain",
         "//prebuilts/clang/host/linux-x86/kleaf:linux_x86_64_clang_toolchain",
diff --git a/profiles/pgo-r487747.tar.bz2 b/profiles/pgo-r487747.tar.bz2
deleted file mode 100644
index a119827..0000000
--- a/profiles/pgo-r487747.tar.bz2
+++ /dev/null
Binary files differ
diff --git a/profiles/pgo-r498229.tar.bz2 b/profiles/pgo-r498229.tar.bz2
new file mode 100644
index 0000000..5eec1c6
--- /dev/null
+++ b/profiles/pgo-r498229.tar.bz2
Binary files differ