From ccc515b88d4a1580d704db6c5b13b08a0ef9d1c9 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 | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/build/config/arm.gni b/src/build/config/arm.gni index 21fc25c63b..2c67ff61d1 100644 --- a/src/build/config/arm.gni +++ b/src/build/config/arm.gni @@ -37,6 +37,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 = "" } # For lacros build, we use ARM v8 by default. @@ -130,6 +132,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 20f75650bb..f1b9d0b03c 100644 --- a/src/build/config/compiler/BUILD.gn +++ b/src/build/config/compiler/BUILD.gn @@ -827,7 +827,11 @@ config("compiler") { # TODO(pcc): The contents of .ARM.attributes should be based on the # -march flag passed at compile time (see llvm.org/pr36291). if (current_cpu == "arm") { - ldflags += [ "-march=$arm_arch" ] + if (arm_cpu != "") { + ldflags += [ "-mcpu=$arm_cpu" ] + } else { + ldflags += [ "-march=$arm_arch" ] + } } } @@ -1180,9 +1184,14 @@ config("compiler_cpu_abi") { } if (!is_nacl) { cflags += [ - "-march=$arm_arch", "-mfloat-abi=$arm_float_abi", ] + if (arm_cpu != "") { + cflags += [ "-mcpu=$arm_cpu" ] + } else { + cflags += [ "-march=$arm_arch" ] + } + ldflags += [ "-mfloat-abi=$arm_float_abi" ] } if (arm_tune != "") { cflags += [ "-mtune=$arm_tune" ] @@ -1193,6 +1202,9 @@ config("compiler_cpu_abi") { cflags += [ "--target=aarch64-linux-gnu" ] ldflags += [ "--target=aarch64-linux-gnu" ] } + if (arm_cpu != "") { + cflags += [ "-mcpu=$arm_cpu" ] + } } else if (current_cpu == "mipsel" && !is_nacl) { ldflags += [ "-Wl,--hash-style=sysv" ] if (custom_toolchain == "") {