[llvm] r351168 - gn build: Rename llvm_host_triple to llvm_current_triple and have it use current_{cpu, os}.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 15 00:20:29 PST 2019


Author: pcc
Date: Tue Jan 15 00:20:29 2019
New Revision: 351168

URL: http://llvm.org/viewvc/llvm-project?rev=351168&view=rev
Log:
gn build: Rename llvm_host_triple to llvm_current_triple and have it use current_{cpu,os}.

This makes e.g. ToolChain::isCrossCompiling() in
clang/lib/Driver/ToolChain.cpp return the correct result
if the compiler was cross-compiled. This change also affects
llvm_default_target_triple, so cross-compiled compilers default to
targeting the cross-compilation target, which makes more sense than
the host that the compiler was compiled on.

This change will also be necessary in order for the correct triples
to appear in generated lit files for non-native targets.

Differential Revision: https://reviews.llvm.org/D56696

Modified:
    llvm/trunk/utils/gn/build/BUILDCONFIG.gn
    llvm/trunk/utils/gn/build/toolchain/BUILD.gn
    llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/test/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/triples.gni

Modified: llvm/trunk/utils/gn/build/BUILDCONFIG.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/BUILDCONFIG.gn?rev=351168&r1=351167&r2=351168&view=diff
==============================================================================
--- llvm/trunk/utils/gn/build/BUILDCONFIG.gn (original)
+++ llvm/trunk/utils/gn/build/BUILDCONFIG.gn Tue Jan 15 00:20:29 2019
@@ -33,6 +33,13 @@ if (current_os == "") {
   current_os = target_os
 }
 
+if (target_cpu == "") {
+  target_cpu = host_cpu
+}
+if (current_cpu == "") {
+  current_cpu = target_cpu
+}
+
 if (host_os == "win") {
   host_toolchain = "//llvm/utils/gn/build/toolchain:win"
 } else {

Modified: llvm/trunk/utils/gn/build/toolchain/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/toolchain/BUILD.gn?rev=351168&r1=351167&r2=351168&view=diff
==============================================================================
--- llvm/trunk/utils/gn/build/toolchain/BUILD.gn (original)
+++ llvm/trunk/utils/gn/build/toolchain/BUILD.gn Tue Jan 15 00:20:29 2019
@@ -153,6 +153,7 @@ unix_toolchain("unix") {
 
   toolchain_args = {
     current_os = host_os
+    current_cpu = host_cpu
   }
 }
 
@@ -171,6 +172,7 @@ if (android_ndk_path != "") {
 
     toolchain_args = {
       current_os = "android"
+      current_cpu = "arm64"
     }
 
     libcxx_path = "$android_ndk_path/sources/cxx-stl/llvm-libc++"
@@ -293,5 +295,6 @@ toolchain("win") {
 
   toolchain_args = {
     current_os = "win"
+    current_cpu = host_cpu
   }
 }

Modified: llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn?rev=351168&r1=351167&r2=351168&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn Tue Jan 15 00:20:29 2019
@@ -52,7 +52,7 @@ write_lit_config("lit_site_cfg") {
     # builds exist, to make sure it's a toolchain var.
     "CMAKE_CXX_COMPILER=c++",
     "ENABLE_BACKTRACES=1",
-    "LLVM_HOST_TRIPLE=$llvm_host_triple",
+    "LLVM_HOST_TRIPLE=$llvm_current_triple",
     "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
     "LLVM_USE_SANITIZER=",
     "PYTHON_EXECUTABLE=$python_path",

Modified: llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn?rev=351168&r1=351167&r2=351168&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn Tue Jan 15 00:20:29 2019
@@ -322,7 +322,7 @@ write_cmake_config("llvm-config") {
     "LINK_POLLY_INTO_TOOLS=",
     "LLVM_DEFAULT_TARGET_TRIPLE=$llvm_target_triple",
     "LLVM_HAS_ATOMICS=1",
-    "LLVM_HOST_TRIPLE=$llvm_host_triple",
+    "LLVM_HOST_TRIPLE=$llvm_current_triple",
     "LLVM_NATIVE_ARCH=$native_target",
     "LLVM_NATIVE_ASMPARSER=1",
     "LLVM_NATIVE_ASMPRINTER=1",

Modified: llvm/trunk/utils/gn/secondary/llvm/test/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/test/BUILD.gn?rev=351168&r1=351167&r2=351168&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/test/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/llvm/test/BUILD.gn Tue Jan 15 00:20:29 2019
@@ -54,7 +54,7 @@ write_lit_config("lit_site_cfg") {
 
     "LLVM_ENABLE_FFI=0",
     "LLVM_HAVE_OPT_VIEWER_MODULES=0",
-    "LLVM_HOST_TRIPLE=$llvm_host_triple",
+    "LLVM_HOST_TRIPLE=$llvm_current_triple",
     "LLVM_LIBRARY_DIR=" + rebase_path("$root_out_dir/lib"),
     "LLVM_LINK_LLVM_DYLIB=0",
     "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.

Modified: llvm/trunk/utils/gn/secondary/llvm/triples.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/triples.gni?rev=351168&r1=351167&r2=351168&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/triples.gni (original)
+++ llvm/trunk/utils/gn/secondary/llvm/triples.gni Tue Jan 15 00:20:29 2019
@@ -1,16 +1,22 @@
-if (host_cpu == "x64") {
-  if (host_os == "linux") {
-    llvm_host_triple = "x86_64-unknown-linux-gnu"
-  } else if (host_os == "mac") {
-    llvm_host_triple = "x86_64-apple-darwin"
-  } else if (host_os == "win") {
-    llvm_host_triple = "x86_64-pc-windows"
+if (current_cpu == "x64") {
+  if (current_os == "linux") {
+    llvm_current_triple = "x86_64-unknown-linux-gnu"
+  } else if (current_os == "mac") {
+    llvm_current_triple = "x86_64-apple-darwin"
+  } else if (current_os == "win") {
+    llvm_current_triple = "x86_64-pc-windows"
   }
-} else {
-  assert(false, "unimplemented host_cpu " + host_cpu)
+} else if (current_cpu == "arm64") {
+  if (current_os == "android") {
+    llvm_current_triple = "aarch64-linux-android21"
+  }
+}
+
+if (!defined(llvm_current_triple)) {
+  assert(false, "unimplemented cpu/os " + current_cpu + "/" + current_os)
 }
 
 declare_args() {
   # The default target triple.
-  llvm_target_triple = llvm_host_triple
+  llvm_target_triple = llvm_current_triple
 }




More information about the llvm-commits mailing list