[llvm] a739f4d - gn build: Fix build when not building the native target.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 5 14:18:15 PDT 2022
Author: Peter Collingbourne
Date: 2022-06-05T14:12:51-07:00
New Revision: a739f4d083dfaff900ff4b78b2547ad9d2369164
URL: https://github.com/llvm/llvm-project/commit/a739f4d083dfaff900ff4b78b2547ad9d2369164
DIFF: https://github.com/llvm/llvm-project/commit/a739f4d083dfaff900ff4b78b2547ad9d2369164.diff
LOG: gn build: Fix build when not building the native target.
Differential Revision: https://reviews.llvm.org/D127068
Added:
Modified:
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
Removed:
################################################################################
diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
index b4b77edf3d1f6..225c11a28b0f3 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -329,13 +329,6 @@ write_cmake_config("llvm-config") {
"LLVM_HAVE_TF_API=",
"LLVM_HOST_TRIPLE=$llvm_current_triple",
"LLVM_NATIVE_ARCH=$native_target",
- "LLVM_NATIVE_ASMPARSER=1",
- "LLVM_NATIVE_ASMPRINTER=1",
- "LLVM_NATIVE_DISASSEMBLER=1",
- "LLVM_NATIVE_TARGET=1",
- "LLVM_NATIVE_TARGETINFO=1",
- "LLVM_NATIVE_TARGETMC=1",
- "LLVM_NATIVE_TARGETMCA=1",
"LLVM_UNREACHABLE_OPTIMIZE=1",
"LLVM_USE_INTEL_JITEVENTS=",
"LLVM_USE_OPROFILE=",
@@ -347,6 +340,28 @@ write_cmake_config("llvm-config") {
"PACKAGE_VERSION=${llvm_version}git",
]
+ if (llvm_build_native) {
+ values += [
+ "LLVM_NATIVE_ASMPARSER=1",
+ "LLVM_NATIVE_ASMPRINTER=1",
+ "LLVM_NATIVE_DISASSEMBLER=1",
+ "LLVM_NATIVE_TARGET=1",
+ "LLVM_NATIVE_TARGETINFO=1",
+ "LLVM_NATIVE_TARGETMC=1",
+ "LLVM_NATIVE_TARGETMCA=1",
+ ]
+ } else {
+ values += [
+ "LLVM_NATIVE_ASMPARSER=",
+ "LLVM_NATIVE_ASMPRINTER=",
+ "LLVM_NATIVE_DISASSEMBLER=",
+ "LLVM_NATIVE_TARGET=",
+ "LLVM_NATIVE_TARGETINFO=",
+ "LLVM_NATIVE_TARGETMC=",
+ "LLVM_NATIVE_TARGETMCA=",
+ ]
+ }
+
if (current_os == "win") {
values += [
"HAVE_SYSEXITS_H=",
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/targets.gni b/llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
index 699b01fbba9a7..f5048f2824a91 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
+++ b/llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
@@ -26,18 +26,21 @@ llvm_all_targets = [
"X86",
]
+# FIXME: This should be based off target_cpu once cross compiles work.
+if (host_cpu == "arm64") {
+ native_target = "AArch64"
+} else if (host_cpu == "arm") {
+ native_target = "ARM"
+} else if (host_cpu == "ppc" || host_cpu == "ppc64") {
+ native_target = "PowerPC"
+} else if (host_cpu == "x86" || host_cpu == "x64") {
+ native_target = "X86"
+} else {
+ assert(false, "add your host_cpu above")
+}
+
if (llvm_targets_to_build == "host") {
- if (host_cpu == "arm64") {
- llvm_targets_to_build = [ "AArch64" ]
- } else if (host_cpu == "arm") {
- llvm_targets_to_build = [ "ARM" ]
- } else if (host_cpu == "ppc" || host_cpu == "ppc64") {
- llvm_targets_to_build = [ "PowerPC" ]
- } else if (host_cpu == "x86" || host_cpu == "x64") {
- llvm_targets_to_build = [ "X86" ]
- } else {
- assert(false, "add your host_cpu above")
- }
+ llvm_targets_to_build = [ native_target ]
} else if (llvm_targets_to_build == "all") {
llvm_targets_to_build = llvm_all_targets
}
@@ -54,7 +57,11 @@ llvm_build_PowerPC = false
llvm_build_SystemZ = false
llvm_build_WebAssembly = false
llvm_build_X86 = false
+llvm_build_native = false
foreach(target, llvm_targets_to_build) {
+ if (target == native_target) {
+ llvm_build_native = true
+ }
if (target == "AArch64") {
llvm_build_AArch64 = true
} else if (target == "AMDGPU") {
@@ -87,19 +94,6 @@ foreach(target, llvm_targets_to_build) {
}
}
-# FIXME: This should be based off target_cpu once cross compiles work.
-if (host_cpu == "arm64") {
- native_target = "AArch64"
-} else if (host_cpu == "arm") {
- native_target = "ARM"
-} else if (host_cpu == "ppc" || host_cpu == "ppc64") {
- native_target = "PowerPC"
-} else if (host_cpu == "x86" || host_cpu == "x64") {
- native_target = "X86"
-} else {
- assert(false, "Unsuppored host_cpu '$host_cpu'.")
-}
-
supported_android_toolchains = []
if (android_ndk_path != "") {
More information about the llvm-commits
mailing list