gn2bp: Support MTE in arm64 to fix build error

Test: lunch aosp_arm64 && m cronet_aml_components_cronet_android_cronet
Change-Id: I73b92b96175689f649e0bba04db0fbb1f38d0c5e
This commit is contained in:
Motomu Utsumi
2022-11-28 16:56:52 +09:00
parent 8b291dc401
commit 3371d685f7
2 changed files with 7 additions and 0 deletions

View File

@@ -641,6 +641,7 @@ cc_library_static {
"-DANDROID", "-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1", "-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H", "-DHAVE_SYS_UIO_H",
"-march=armv8-a+memtag",
], ],
local_include_dirs: [ local_include_dirs: [
"third_party/android_ndk/sources/android/cpufeatures/", "third_party/android_ndk/sources/android/cpufeatures/",

View File

@@ -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. # TODO: set_module_xxx is confusing, apply similar function to module and target in better way.
for arch_name, arch in target.arch.items(): for arch_name, arch in target.arch.items():
set_module_flags(module.target[arch_name], arch.cflags, arch.defines) 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) set_module_include_dirs(module.target[arch_name], arch.cflags, arch.include_dirs)
if module.is_compiled(): if module.is_compiled():