Skip to content

Commit

Permalink
Set CLANG_TABLEGEN when cross compiling clang
Browse files Browse the repository at this point in the history
When cross compiling rustc with `llvm.clang = true`, CLANG_TABLEGEN
has to be set to the host clang-tblgen executable to build clang.
  • Loading branch information
topjohnwu committed Jul 4, 2022
1 parent ce9e719 commit 600026a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 600026a

Please sign in to comment.