about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authortopjohnwu <topjohnwu@google.com>2022-07-03 23:52:01 -0700
committertopjohnwu <topjohnwu@google.com>2022-07-03 23:52:01 -0700
commit600026ac9473e75729e67b38036e7deaffbe2a20 (patch)
tree774e22b84935a6ac742bbf6c07f2e9e25aaa438b /src/bootstrap
parentce9e71949cb3b788830b119d8fcfae9e20b62fbd (diff)
downloadrust-600026ac9473e75729e67b38036e7deaffbe2a20.tar.gz
rust-600026ac9473e75729e67b38036e7deaffbe2a20.zip
Set CLANG_TABLEGEN when cross compiling clang
When cross compiling rustc with `llvm.clang = true`, CLANG_TABLEGEN
has to be set to the host clang-tblgen executable to build clang.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/native.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index c6d6c256c28..37f692c0189 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -430,11 +430,20 @@ impl Step for Llvm {
             //        actually exists most of the time in normal installs of LLVM.
             let host_bin = builder.llvm_out(builder.config.build).join("bin");
             cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION));
+            // LLVM_NM is required for cross compiling using MSVC
             cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
             cfg.define(
                 "LLVM_CONFIG_PATH",
                 host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
             );
+            if builder.config.llvm_clang {
+                let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin");
+                let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION);
+                if !builder.config.dry_run && !clang_tblgen.exists() {
+                    panic!("unable to find {}", clang_tblgen.display());
+                }
+                cfg.define("CLANG_TABLEGEN", clang_tblgen);
+            }
         }
 
         let llvm_version_suffix = if let Some(ref suffix) = builder.config.llvm_version_suffix {