[llvm] 05c5ff5 - [gn build] make stage2_unix_toolchain set clang_base_path
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 4 16:43:22 PDT 2020
Author: Nico Weber
Date: 2020-07-04T19:36:09-04:00
New Revision: 05c5ff5ab0b4d7cec25210bce7444827c25d71b1
URL: https://github.com/llvm/llvm-project/commit/05c5ff5ab0b4d7cec25210bce7444827c25d71b1
DIFF: https://github.com/llvm/llvm-project/commit/05c5ff5ab0b4d7cec25210bce7444827c25d71b1.diff
LOG: [gn build] make stage2_unix_toolchain set clang_base_path
This fixes the build of compiler-rt on macOS when _not_ using
clang_base_path in args.gn: Xcode clang knows where to find the
SDK, but regular clang doesn't and needs a -isysroot parameter.
We correctly add that parameter when clang_base_path is set,
but else we omit it. If clang_base_path was not set, we also
didn't add the flag for stage2_unix_toolchain() when we build
compiler-rt with just-built clang.
Make stage2_unix_toolchain() use clang_base_path instead of setting
cc / cxx. It's less code, and it gets things like this right.
Added:
Modified:
llvm/utils/gn/build/toolchain/BUILD.gn
Removed:
################################################################################
diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn
index 86e95d3de188..1f963ca40905 100644
--- a/llvm/utils/gn/build/toolchain/BUILD.gn
+++ b/llvm/utils/gn/build/toolchain/BUILD.gn
@@ -11,8 +11,26 @@ declare_args() {
template("unix_toolchain") {
toolchain(target_name) {
+ # https://groups.google.com/a/chromium.org/d/msg/gn-dev/F_lv5T-tNDM
+ forward_variables_from(invoker.toolchain_args, "*")
+ not_needed("*")
+
forward_variables_from(invoker, "*")
+ cc = "cc"
+ cxx = "c++"
+
+ if (clang_base_path != "") {
+ cc = "$clang_base_path/bin/clang"
+ cxx = "$clang_base_path/bin/clang++"
+ }
+
+ ld = cxx # Don't use goma wrapper for linking.
+ if (use_goma) {
+ cc = "$goma_dir/gomacc $cc"
+ cxx = "$goma_dir/gomacc $cxx"
+ }
+
tool("cc") {
depfile = "{{output}}.d"
command = "$cc -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}"
@@ -128,20 +146,6 @@ template("unix_toolchain") {
}
unix_toolchain("unix") {
- cc = "cc"
- cxx = "c++"
-
- if (clang_base_path != "") {
- cc = "$clang_base_path/bin/clang"
- cxx = "$clang_base_path/bin/clang++"
- }
-
- ld = cxx # Don't use goma wrapper for linking.
- if (use_goma) {
- cc = "$goma_dir/gomacc $cc"
- cxx = "$goma_dir/gomacc $cxx"
- }
-
if (current_os != "mac") {
ar = "ar"
}
@@ -156,13 +160,11 @@ unix_toolchain("unix") {
# as compiler and linker.
template("stage2_unix_toolchain") {
unix_toolchain(target_name) {
- forward_variables_from(invoker, "*")
+ toolchain_args = {
+ forward_variables_from(invoker.toolchain_args, "*")
- cc = "bin/clang"
- cxx = "bin/clang++"
- ld = cxx
- if (current_os != "mac") {
- ar = "bin/llvm-ar"
+ clang_base_path = "."
+ use_goma = false
}
deps = [
@@ -170,6 +172,7 @@ template("stage2_unix_toolchain") {
"//:lld($host_toolchain)",
]
if (current_os != "mac") {
+ ar = "bin/llvm-ar"
deps += [ "//:llvm-ar($host_toolchain)" ]
}
}
@@ -179,8 +182,6 @@ stage2_unix_toolchain("stage2_unix") {
toolchain_args = {
current_os = host_os
current_cpu = host_cpu
- is_clang = true
- use_lld = host_os != "mac"
}
}
@@ -189,8 +190,6 @@ if (android_ndk_path != "") {
toolchain_args = {
current_os = "android"
current_cpu = "arm64"
- is_clang = true
- use_lld = true
}
}
@@ -198,8 +197,6 @@ if (android_ndk_path != "") {
toolchain_args = {
current_os = "android"
current_cpu = "arm"
- is_clang = true
- use_lld = true
}
}
}
More information about the llvm-commits
mailing list