[llvm] 463ee15 - [gn build] Fix Android compiler-rt targets
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 11 18:42:07 PST 2021
Author: Arthur Eubanks
Date: 2021-11-11T18:41:18-08:00
New Revision: 463ee15e33c0a71c7ab13eef2eb235bcdcd792a5
URL: https://github.com/llvm/llvm-project/commit/463ee15e33c0a71c7ab13eef2eb235bcdcd792a5
DIFF: https://github.com/llvm/llvm-project/commit/463ee15e33c0a71c7ab13eef2eb235bcdcd792a5.diff
LOG: [gn build] Fix Android compiler-rt targets
If a sysroot was specified, it would take precedence over the Android
NDK sysroot since it would appear after in the command line.
Also only build runtimes for enabled target arches. Many places have
copied this around so create and use supported_android_toolchains.
Reviewed By: pcc
Differential Revision: https://reviews.llvm.org/D113606
Added:
Modified:
llvm/utils/gn/build/BUILD.gn
llvm/utils/gn/secondary/compiler-rt/BUILD.gn
llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn
llvm/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn
llvm/utils/gn/secondary/libunwind/BUILD.gn
llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
Removed:
################################################################################
diff --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 3b22f6f302214..39f58c66fc89f 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -269,7 +269,8 @@ config("compiler_defaults") {
if (current_os == "win") {
assert(is_clang, "sysroot only works with clang-cl as host compiler")
cflags += [ "/winsysroot" + rebase_path(sysroot, root_build_dir) ]
- } else if (current_os != "ios" && current_os != "mac") {
+ } else if (current_os != "ios" && current_os != "mac" &&
+ current_os != "android") {
cflags += [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
}
}
diff --git a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
index a234a3ce1f847..b4933bd80d7b1 100644
--- a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
@@ -11,12 +11,7 @@ if (current_os == "win") {
} else {
supported_toolchains = [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
}
-if (android_ndk_path != "") {
- supported_toolchains += [
- "//llvm/utils/gn/build/toolchain:stage2_android_aarch64",
- "//llvm/utils/gn/build/toolchain:stage2_android_arm",
- ]
-}
+supported_toolchains += supported_android_toolchains
group("compiler-rt") {
deps = [ "//compiler-rt/include($host_toolchain)" ]
foreach(toolchain, supported_toolchains) {
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn
index c8c057f85cd3c..430f55b8976cc 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/scudo/BUILD.gn
@@ -1,15 +1,11 @@
+import("//llvm/lib/Target/targets.gni")
import("//llvm/utils/gn/build/toolchain/compiler.gni")
supported_toolchains = []
if (target_os == "linux" || target_os == "fuchsia") {
supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
}
-if (android_ndk_path != "") {
- supported_toolchains += [
- "//llvm/utils/gn/build/toolchain:stage2_android_aarch64",
- "//llvm/utils/gn/build/toolchain:stage2_android_arm",
- ]
-}
+supported_toolchains += supported_android_toolchains
group("scudo") {
deps = []
diff --git a/llvm/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn
index 2c394860f9159..0ec6469e65ac4 100644
--- a/llvm/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn
@@ -1,5 +1,6 @@
import("//compiler-rt/target.gni")
import("//compiler-rt/test/test.gni")
+import("//llvm/lib/Target/targets.gni")
import("//llvm/utils/gn/build/toolchain/compiler.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni")
@@ -59,7 +60,7 @@ supported_toolchains = []
if (host_os == "linux" && host_cpu == "x64") {
supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
}
-if (android_ndk_path != "") {
+if (llvm_build_AArch64 && android_ndk_path != "") {
supported_toolchains +=
[ "//llvm/utils/gn/build/toolchain:stage2_android_aarch64" ]
}
diff --git a/llvm/utils/gn/secondary/libunwind/BUILD.gn b/llvm/utils/gn/secondary/libunwind/BUILD.gn
index f66246dc7703e..5d95bbe778876 100644
--- a/llvm/utils/gn/secondary/libunwind/BUILD.gn
+++ b/llvm/utils/gn/secondary/libunwind/BUILD.gn
@@ -1,12 +1,8 @@
+import("//llvm/lib/Target/targets.gni")
import("//llvm/utils/gn/build/toolchain/compiler.gni")
-supported_toolchains = [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
-if (android_ndk_path != "") {
- supported_toolchains += [
- "//llvm/utils/gn/build/toolchain:stage2_android_aarch64",
- "//llvm/utils/gn/build/toolchain:stage2_android_arm",
- ]
-}
+supported_toolchains = [ "//llvm/utils/gn/build/toolchain:stage2_unix" ] +
+ supported_android_toolchains
group("libunwind") {
deps = []
diff --git a/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn b/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
index 7f69adc2cd7e0..4883af4fa4150 100644
--- a/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
@@ -1,3 +1,4 @@
+import("//llvm/lib/Target/targets.gni")
import("//llvm/utils/TableGen/tablegen.gni")
import("//llvm/utils/gn/build/toolchain/compiler.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
@@ -16,13 +17,7 @@ if (current_os == "mac") {
}
}
-supported_toolchains = []
-if (android_ndk_path != "") {
- supported_toolchains += [
- "//llvm/utils/gn/build/toolchain:stage2_android_aarch64",
- "//llvm/utils/gn/build/toolchain:stage2_android_arm",
- ]
-}
+supported_toolchains = supported_android_toolchains
executable("lldb") {
configs += [ "//llvm/utils/gn/build:lldb_code" ]
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/targets.gni b/llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
index 22da518ea1fb9..699b01fbba9a7 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
+++ b/llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
@@ -1,3 +1,5 @@
+import("//llvm/utils/gn/build/toolchain/compiler.gni")
+
declare_args() {
# The target archs LLVM should support. Defaults to the host arch.
# Set to a list, e.g. `llvm_targets_to_build = [ "X86", "ARM" ]`,
@@ -97,3 +99,16 @@ if (host_cpu == "arm64") {
} else {
assert(false, "Unsuppored host_cpu '$host_cpu'.")
}
+
+supported_android_toolchains = []
+
+if (android_ndk_path != "") {
+ if (llvm_build_AArch64) {
+ supported_android_toolchains +=
+ [ "//llvm/utils/gn/build/toolchain:stage2_android_aarch64" ]
+ }
+ if (llvm_build_ARM) {
+ supported_android_toolchains +=
+ [ "//llvm/utils/gn/build/toolchain:stage2_android_arm" ]
+ }
+}
More information about the llvm-commits
mailing list