Skip to content

Commit 600026a

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 ce9e719 commit 600026a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bootstrap/native.rs

+9
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,20 @@ impl Step for Llvm {
430430
// actually exists most of the time in normal installs of LLVM.
431431
let host_bin = builder.llvm_out(builder.config.build).join("bin");
432432
cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION));
433+
// LLVM_NM is required for cross compiling using MSVC
433434
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
434435
cfg.define(
435436
"LLVM_CONFIG_PATH",
436437
host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
437438
);
439+
if builder.config.llvm_clang {
440+
let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin");
441+
let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION);
442+
if !builder.config.dry_run && !clang_tblgen.exists() {
443+
panic!("unable to find {}", clang_tblgen.display());
444+
}
445+
cfg.define("CLANG_TABLEGEN", clang_tblgen);
446+
}
438447
}
439448

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

0 commit comments

Comments
 (0)