Skip to content

Commit 84475a2

Browse files
authored
Rollup merge of rust-lang#147419 - cuviper:bootstrap-rustc-libs, r=Zalathar,jieyouxu
bootstrap: add `Builder::rustc_cmd` that includes the lib path When building with `rust.rpath = false`, every `rustc` invocation needs to include the library path as well. I particularly ran into this in `generate_target_spec_json_schema` when testing 1.91-beta in Fedora, where we do disable rpath for our system builds. The new helper function will hopefully encourage the right thing going forward.
2 parents c2b9031 + 03cdcb5 commit 84475a2

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, cargo: &mut Car
529529
// Query rustc for the deployment target, and the associated env var.
530530
// The env var is one of the standard `*_DEPLOYMENT_TARGET` vars, i.e.
531531
// `MACOSX_DEPLOYMENT_TARGET`, `IPHONEOS_DEPLOYMENT_TARGET`, etc.
532-
let mut cmd = command(builder.rustc(cargo.compiler()));
532+
let mut cmd = builder.rustc_cmd(cargo.compiler());
533533
cmd.arg("--target").arg(target.rustc_target_arg());
534534
cmd.arg("--print=deployment-target");
535535
let output = cmd.run_capture_stdout(builder).stdout();

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ fn generate_target_spec_json_schema(builder: &Builder<'_>, sysroot: &Path) {
625625
// We do this by using the stage 1 compiler, which is always compiled for the host,
626626
// even in a cross build.
627627
let stage1_host = builder.compiler(1, builder.host_target);
628-
let mut rustc = command(builder.rustc(stage1_host)).fail_fast();
628+
let mut rustc = builder.rustc_cmd(stage1_host).fail_fast();
629629
rustc
630630
.env("RUSTC_BOOTSTRAP", "1")
631631
.args(["--print=target-spec-json-schema", "-Zunstable-options"]);

src/bootstrap/src/core/build_steps/synthetic_targets.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use crate::Compiler;
1111
use crate::core::builder::{Builder, ShouldRun, Step};
1212
use crate::core::config::TargetSelection;
13-
use crate::utils::exec::command;
1413

1514
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1615
pub(crate) struct MirOptPanicAbortSyntheticTarget {
@@ -55,7 +54,7 @@ fn create_synthetic_target(
5554
return TargetSelection::create_synthetic(&name, path.to_str().unwrap());
5655
}
5756

58-
let mut cmd = command(builder.rustc(compiler));
57+
let mut cmd = builder.rustc_cmd(compiler);
5958
cmd.arg("--target").arg(base.rustc_target_arg());
6059
cmd.args(["-Zunstable-options", "--print", "target-spec-json"]);
6160

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,8 @@ impl Builder<'_> {
728728
// Build proc macros both for the host and the target unless proc-macros are not
729729
// supported by the target.
730730
if target != compiler.host && cmd_kind != Kind::Check {
731-
let mut rustc_cmd = command(self.rustc(compiler));
732-
self.add_rustc_lib_path(compiler, &mut rustc_cmd);
733-
734-
let error = rustc_cmd
731+
let error = self
732+
.rustc_cmd(compiler)
735733
.arg("--target")
736734
.arg(target.rustc_target_arg())
737735
.arg("--print=file-names")

src/bootstrap/src/core/builder/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,14 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler
16051605
}
16061606
}
16071607

1608+
/// Gets a command to run the compiler specified, including the dynamic library
1609+
/// path in case the executable has not been build with `rpath` enabled.
1610+
pub fn rustc_cmd(&self, compiler: Compiler) -> BootstrapCommand {
1611+
let mut cmd = command(self.rustc(compiler));
1612+
self.add_rustc_lib_path(compiler, &mut cmd);
1613+
cmd
1614+
}
1615+
16081616
/// Gets the paths to all of the compiler's codegen backends.
16091617
fn codegen_backends(&self, compiler: Compiler) -> impl Iterator<Item = PathBuf> {
16101618
fs::read_dir(self.sysroot_codegen_backends(compiler))

0 commit comments

Comments
 (0)