Skip to content

Commit 257ec08

Browse files
committed
Auto merge of #48757 - alexcrichton:fix-msbuild-build, r=Mark-Simulacrum
rustbuild: Fix MSBuild location of `llvm-config.exe` For LLD integration the path to `llvm-config` needed to change to inside the build directory itself (for whatever reason) but the build directory is different on MSBuild than it is on `ninja` for MSVC builds, so the path to `llvm-config.exe` was actually wrong and not working! This commit removes the `Build::llvm_config` function in favor of the source of truth, the `Llvm` build step itself. The build step was then updated to find the right build directory for MSBuild as well as `ninja` for where `llvm-config.exe` is located. Closes #48749
2 parents fedce67 + be902e7 commit 257ec08

File tree

6 files changed

+20
-24
lines changed

6 files changed

+20
-24
lines changed

src/bootstrap/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Step for Std {
4646
let out_dir = build.stage_out(compiler, Mode::Libstd);
4747
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
4848
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
49-
std_cargo(build, &compiler, target, &mut cargo);
49+
std_cargo(builder, &compiler, target, &mut cargo);
5050
run_cargo(build,
5151
&mut cargo,
5252
&libstd_stamp(build, compiler, target),

src/bootstrap/compile.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl Step for Std {
105105
let out_dir = build.stage_out(compiler, Mode::Libstd);
106106
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
107107
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build");
108-
std_cargo(build, &compiler, target, &mut cargo);
108+
std_cargo(builder, &compiler, target, &mut cargo);
109109
run_cargo(build,
110110
&mut cargo,
111111
&libstd_stamp(build, compiler, target),
@@ -135,7 +135,7 @@ fn copy_musl_third_party_objects(build: &Build,
135135

136136
/// Configure cargo to compile the standard library, adding appropriate env vars
137137
/// and such.
138-
pub fn std_cargo(build: &Build,
138+
pub fn std_cargo(build: &Builder,
139139
compiler: &Compiler,
140140
target: Interned<String>,
141141
cargo: &mut Command) {
@@ -162,7 +162,11 @@ pub fn std_cargo(build: &Build,
162162
// missing
163163
// We also only build the runtimes when --enable-sanitizers (or its
164164
// config.toml equivalent) is used
165-
cargo.env("LLVM_CONFIG", build.llvm_config(target));
165+
let llvm_config = build.ensure(native::Llvm {
166+
target: build.config.build,
167+
emscripten: false,
168+
});
169+
cargo.env("LLVM_CONFIG", llvm_config);
166170
}
167171

168172
cargo.arg("--features").arg(features)

src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ impl Step for Std {
481481
t!(symlink_dir_force(&my_out, &out_dir));
482482

483483
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "doc");
484-
compile::std_cargo(build, &compiler, target, &mut cargo);
484+
compile::std_cargo(builder, &compiler, target, &mut cargo);
485485

486486
// We don't want to build docs for internal std dependencies unless
487487
// in compiler-docs mode. When not in that mode, we whitelist the crates

src/bootstrap/lib.rs

-14
Original file line numberDiff line numberDiff line change
@@ -532,20 +532,6 @@ impl Build {
532532
}
533533
}
534534

535-
/// Returns the path to `llvm-config` for the specified target.
536-
///
537-
/// If a custom `llvm-config` was specified for target then that's returned
538-
/// instead.
539-
fn llvm_config(&self, target: Interned<String>) -> PathBuf {
540-
let target_config = self.config.target_config.get(&target);
541-
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
542-
s.clone()
543-
} else {
544-
self.llvm_out(self.config.build).join("bin")
545-
.join(exe("llvm-config", &*target))
546-
}
547-
}
548-
549535
/// Returns the path to `FileCheck` binary for the specified target
550536
fn llvm_filecheck(&self, target: Interned<String>) -> PathBuf {
551537
let target_config = self.config.target_config.get(&target);

src/bootstrap/native.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ impl Step for Llvm {
8181

8282
let (out_dir, llvm_config_ret_dir) = if emscripten {
8383
let dir = build.emscripten_llvm_out(target);
84-
let config_dir = dir.join("build/bin");
84+
let config_dir = dir.join("bin");
8585
(dir, config_dir)
8686
} else {
87-
(build.llvm_out(target),
88-
build.llvm_out(build.config.build).join("build/bin"))
87+
let mut dir = build.llvm_out(build.config.build);
88+
if !build.config.build.contains("msvc") || build.config.ninja {
89+
dir.push("build");
90+
}
91+
(build.llvm_out(target), dir.join("bin"))
8992
};
9093
let done_stamp = out_dir.join("llvm-finished-building");
9194
let build_llvm_config = llvm_config_ret_dir

src/bootstrap/test.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,10 @@ impl Step for Compiletest {
915915
}
916916

917917
if build.config.llvm_enabled {
918-
let llvm_config = build.llvm_config(build.config.build);
918+
let llvm_config = builder.ensure(native::Llvm {
919+
target: build.config.build,
920+
emscripten: false,
921+
});
919922
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
920923
cmd.arg("--llvm-version").arg(llvm_version);
921924
if !build.is_rust_llvm(target) {
@@ -1382,7 +1385,7 @@ impl Step for Crate {
13821385
let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
13831386
match mode {
13841387
Mode::Libstd => {
1385-
compile::std_cargo(build, &compiler, target, &mut cargo);
1388+
compile::std_cargo(builder, &compiler, target, &mut cargo);
13861389
}
13871390
Mode::Libtest => {
13881391
compile::test_cargo(build, &compiler, target, &mut cargo);

0 commit comments

Comments
 (0)