From 91c7dd047c352e18b284096cf6310ece91c8fd9b Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 23 Jun 2022 11:23:23 -0700 Subject: [PATCH] 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. --- src/bootstrap/native.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index ece02499d249f..ed5549f104246 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -417,11 +417,18 @@ 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)); - 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 !clang_tblgen.exists() { + panic!("unable to find {}", clang_tblgen.display()); + } + cfg.define("CLANG_TABLEGEN", clang_tblgen); + } } if let Some(ref suffix) = builder.config.llvm_version_suffix {