build: Support -mcpu= on ARM and ARM64

This commit is contained in:
klzgrad 2020-05-19 23:42:14 +08:00
parent 56bfc47a0c
commit 6add91f34f
2 changed files with 19 additions and 2 deletions

View File

@ -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.
@ -128,6 +130,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)

View File

@ -786,9 +786,13 @@ 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") {
if (arm_cpu != "") {
ldflags += [ "-mcpu=$arm_cpu" ]
} else {
ldflags += [ "-march=$arm_arch" ]
}
}
}
if (compiler_timing) {
if (is_clang && !is_nacl) {
@ -1102,9 +1106,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" ]
@ -1115,6 +1124,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 == "") {