diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp index 60caa1d25d..50bb9b9be3 100644 --- a/tools/gn2bp/Android.bp.swp +++ b/tools/gn2bp/Android.bp.swp @@ -641,6 +641,7 @@ cc_library_static { "-DANDROID", "-DANDROID_NDK_VERSION_ROLL=r23_1", "-DHAVE_SYS_UIO_H", + "-march=armv8-a+memtag", ], local_include_dirs: [ "third_party/android_ndk/sources/android/cpufeatures/", diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp index 000faf54e1..addcaacda5 100755 --- a/tools/gn2bp/gen_android_bp +++ b/tools/gn2bp/gen_android_bp @@ -903,6 +903,12 @@ def create_modules_from_target(blueprint, gn, gn_target_name): # TODO: set_module_xxx is confusing, apply similar function to module and target in better way. for arch_name, arch in target.arch.items(): set_module_flags(module.target[arch_name], arch.cflags, arch.defines) + # -Xclang -target-feature -Xclang +mte are used to enable MTE (Memory Tagging Extensions). + # Flags which does not start with '-' could not be in the cflags so enabling MTE by + # -march and -mcpu Feature Modifiers. MTE is only available on arm64. This is needed for + # building //base/allocator/partition_allocator:partition_alloc for arm64. + if '+mte' in arch.cflags and arch_name == 'android_arm64': + module.target[arch_name].cflags.add('-march=armv8-a+memtag') set_module_include_dirs(module.target[arch_name], arch.cflags, arch.include_dirs) if module.is_compiled():