Skip to content

Commit 7180afb

Browse files
committed
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.
1 parent 8fb6c54 commit 7180afb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: src/bootstrap/native.rs

+9
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,20 @@ impl Step for Llvm {
417417
// actually exists most of the time in normal installs of LLVM.
418418
let host_bin = builder.llvm_out(builder.config.build).join("bin");
419419
cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION));
420+
// LLVM_NM is required for cross compiling using MSVC
420421
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
421422
cfg.define(
422423
"LLVM_CONFIG_PATH",
423424
host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
424425
);
426+
if builder.config.llvm_clang {
427+
let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin");
428+
let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION);
429+
if !clang_tblgen.exists() {
430+
panic!("unable to find {}", clang_tblgen.display());
431+
}
432+
cfg.define("CLANG_TABLEGEN", clang_tblgen);
433+
}
425434
}
426435

427436
if let Some(ref suffix) = builder.config.llvm_version_suffix {

0 commit comments

Comments
 (0)