arm: build: Support -mcpu= on ARM and ARM64

master
klzgrad 2020-05-19 23:42:14 +08:00
parent 58efb2b04b
commit 98d089bccc
3 changed files with 18 additions and 1 deletions

View File

@ -26,6 +26,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") {
@ -68,6 +70,9 @@ if (current_cpu == "arm" || v8_current_cpu == "arm") {
current_cpu == "arm64e" || v8_current_cpu == "arm64e") {
# arm64 supports only "hard".
arm_float_abi = "hard"
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

@ -903,7 +903,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" ]
}
}
}

View File

@ -82,6 +82,11 @@ if ((is_posix && !is_apple) || is_fuchsia) {
"-march=$arm_arch",
"-mfloat-abi=$arm_float_abi",
]
if (arm_cpu != "") {
cpu_abi_cflags -= [ "-march=$arm_arch" ]
cpu_abi_cflags += [ "-mcpu=$arm_cpu" ]
}
cpu_abi_ldflags += [ "-mfloat-abi=$arm_float_abi" ]
} else if (current_cpu == "arm64") {
if (is_clang && !is_android && !is_fuchsia && !is_chromeos_device) {
cpu_abi_cflags += [ "--target=aarch64-linux-gnu" ]
@ -92,6 +97,9 @@ if ((is_posix && !is_apple) || is_fuchsia) {
cpu_abi_cflags += [ "-march=$cros_target_cpu_arch" ]
cpu_abi_ldflags += [ "-march=$cros_target_cpu_arch" ]
}
if (arm_cpu != "") {
cpu_abi_cflags += [ "-mcpu=$arm_cpu" ]
}
} else if (current_cpu == "mipsel") {
cpu_abi_ldflags += [ "-Wl,--hash-style=sysv" ]
if (custom_toolchain == "") {