Skip to content

rustbuild: Fix MSBuild location of llvm-config.exe #48757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Step for Std {
let out_dir = build.stage_out(compiler, Mode::Libstd);
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "check");
std_cargo(build, &compiler, target, &mut cargo);
std_cargo(builder, &compiler, target, &mut cargo);
run_cargo(build,
&mut cargo,
&libstd_stamp(build, compiler, target),
Expand Down
10 changes: 7 additions & 3 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Step for Std {
let out_dir = build.stage_out(compiler, Mode::Libstd);
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build");
std_cargo(build, &compiler, target, &mut cargo);
std_cargo(builder, &compiler, target, &mut cargo);
run_cargo(build,
&mut cargo,
&libstd_stamp(build, compiler, target),
Expand Down Expand Up @@ -135,7 +135,7 @@ fn copy_musl_third_party_objects(build: &Build,

/// Configure cargo to compile the standard library, adding appropriate env vars
/// and such.
pub fn std_cargo(build: &Build,
pub fn std_cargo(build: &Builder,
compiler: &Compiler,
target: Interned<String>,
cargo: &mut Command) {
Expand All @@ -162,7 +162,11 @@ pub fn std_cargo(build: &Build,
// missing
// We also only build the runtimes when --enable-sanitizers (or its
// config.toml equivalent) is used
cargo.env("LLVM_CONFIG", build.llvm_config(target));
let llvm_config = build.ensure(native::Llvm {
target: build.config.build,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be the target we're passing to std_cargo? Or is this some other llvm-config? Either way, it'd be good to comment on the build.config.build with why we're passing it, and not target.

It also looks like it's maybe worth making this build.ensure(...) call the body of the old llvm_config function and then just calling it so we avoid duplicating it. But that's probably a minor detail, up to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point! I was hoping to keep the ensure here though to canonicalize the definition of where llvm-config comes from in one place (previously it was calculated in two places)

emscripten: false,
});
cargo.env("LLVM_CONFIG", llvm_config);
}

cargo.arg("--features").arg(features)
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl Step for Std {
t!(symlink_dir_force(&my_out, &out_dir));

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

// We don't want to build docs for internal std dependencies unless
// in compiler-docs mode. When not in that mode, we whitelist the crates
Expand Down
14 changes: 0 additions & 14 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,20 +532,6 @@ impl Build {
}
}

/// Returns the path to `llvm-config` for the specified target.
///
/// If a custom `llvm-config` was specified for target then that's returned
/// instead.
fn llvm_config(&self, target: Interned<String>) -> PathBuf {
let target_config = self.config.target_config.get(&target);
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
s.clone()
} else {
self.llvm_out(self.config.build).join("bin")
.join(exe("llvm-config", &*target))
}
}

/// Returns the path to `FileCheck` binary for the specified target
fn llvm_filecheck(&self, target: Interned<String>) -> PathBuf {
let target_config = self.config.target_config.get(&target);
Expand Down
9 changes: 6 additions & 3 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ impl Step for Llvm {

let (out_dir, llvm_config_ret_dir) = if emscripten {
let dir = build.emscripten_llvm_out(target);
let config_dir = dir.join("build/bin");
let config_dir = dir.join("bin");
(dir, config_dir)
} else {
(build.llvm_out(target),
build.llvm_out(build.config.build).join("build/bin"))
let mut dir = build.llvm_out(build.config.build);
if !build.config.build.contains("msvc") || build.config.ninja {
dir.push("build");
}
(build.llvm_out(target), dir.join("bin"))
};
let done_stamp = out_dir.join("llvm-finished-building");
let build_llvm_config = llvm_config_ret_dir
Expand Down
7 changes: 5 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,10 @@ impl Step for Compiletest {
}

if build.config.llvm_enabled {
let llvm_config = build.llvm_config(build.config.build);
let llvm_config = builder.ensure(native::Llvm {
target: build.config.build,
emscripten: false,
});
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
cmd.arg("--llvm-version").arg(llvm_version);
if !build.is_rust_llvm(target) {
Expand Down Expand Up @@ -1382,7 +1385,7 @@ impl Step for Crate {
let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
match mode {
Mode::Libstd => {
compile::std_cargo(build, &compiler, target, &mut cargo);
compile::std_cargo(builder, &compiler, target, &mut cargo);
}
Mode::Libtest => {
compile::test_cargo(build, &compiler, target, &mut cargo);
Expand Down