Index: llvm/trunk/utils/gn/build/BUILDCONFIG.gn =================================================================== --- llvm/trunk/utils/gn/build/BUILDCONFIG.gn +++ llvm/trunk/utils/gn/build/BUILDCONFIG.gn @@ -33,6 +33,13 @@ 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 { Index: llvm/trunk/utils/gn/build/toolchain/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/build/toolchain/BUILD.gn +++ llvm/trunk/utils/gn/build/toolchain/BUILD.gn @@ -153,6 +153,7 @@ toolchain_args = { current_os = host_os + current_cpu = host_cpu } } @@ -171,6 +172,7 @@ toolchain_args = { current_os = "android" + current_cpu = "arm64" } libcxx_path = "$android_ndk_path/sources/cxx-stl/llvm-libc++" @@ -293,5 +295,6 @@ toolchain_args = { current_os = "win" + current_cpu = host_cpu } } Index: llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn +++ llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn @@ -52,7 +52,7 @@ # 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", Index: llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn @@ -322,7 +322,7 @@ "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", Index: llvm/trunk/utils/gn/secondary/llvm/test/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/test/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/test/BUILD.gn @@ -54,7 +54,7 @@ "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. Index: llvm/trunk/utils/gn/secondary/llvm/triples.gni =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/triples.gni +++ llvm/trunk/utils/gn/secondary/llvm/triples.gni @@ -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 }