From 8436fbf30fd66c87d6e2cece6e57a88e217ad1dc Mon Sep 17 00:00:00 2001 From: klzgrad Date: Tue, 19 May 2020 23:42:14 +0800 Subject: [PATCH] build: Support -mcpu= on ARM and ARM64 --- src/build/config/arm.gni | 5 +++++ src/build/config/compiler/BUILD.gn | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/build/config/arm.gni b/src/build/config/arm.gni index 410d3cb8f9..08e68d3fbe 100644 --- a/src/build/config/arm.gni +++ b/src/build/config/arm.gni @@ -36,6 +36,8 @@ if (current_cpu == "arm" || v8_current_cpu == "arm") { # Thumb is a reduced instruction set available on some ARM processors that # has increased code density. arm_use_thumb = true + + arm_cpu = "" } if (current_os == "android" || target_os == "android") { @@ -124,6 +126,9 @@ if (current_cpu == "arm" || v8_current_cpu == "arm") { # arm64 supports only "hard". arm_float_abi = "hard" arm_use_neon = true + declare_args() { + arm_cpu = "" + } declare_args() { # Enables the new Armv8 branch protection features. Valid strings are: # - "pac": Enables Pointer Authentication Code (PAC, featured in Armv8.3) diff --git a/src/build/config/compiler/BUILD.gn b/src/build/config/compiler/BUILD.gn index e03223d56b..5ed631b71b 100644 --- a/src/build/config/compiler/BUILD.gn +++ b/src/build/config/compiler/BUILD.gn @@ -926,6 +926,10 @@ config("compiler_cpu_abi") { "-march=$arm_arch", "-mfloat-abi=$arm_float_abi", ] + if (arm_cpu != "") { + cflags += [ "-mcpu=$arm_cpu" ] + } + ldflags += [ "-mfloat-abi=$arm_float_abi" ] } if (arm_tune != "") { cflags += [ "-mtune=$arm_tune" ] @@ -939,6 +943,9 @@ config("compiler_cpu_abi") { # Outline atomics crash on Exynos 9810. http://crbug.com/1272795 cflags += [ "-mno-outline-atomics" ] } + if (arm_cpu != "") { + cflags += [ "-mcpu=$arm_cpu" ] + } } else if (current_cpu == "mipsel" && !is_nacl) { ldflags += [ "-Wl,--hash-style=sysv" ] if (custom_toolchain == "") {