Skip to content

Commit b31628d

Browse files
committed
Don't hardcode the path to bootstrap_out
The `rust-dev` dist component puts binaries in `bootstrap/bin`, but we expected them to be in `bootstrap/debug` to match cargo's behavior. Rather than making the dist component inconsistent with other components, make bootstrap slightly smarter and allow using any path as long as all the binaries are in the same directory. As a bonus, this greatly simplifies the logic, and makes it possible for the shell scripts to start avoiding python. Co-authored-by: Joshua Nelson <github@jyn.dev>
1 parent 55c040e commit b31628d

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/bootstrap/lib.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -456,19 +456,15 @@ impl Build {
456456
.expect("failed to read src/version");
457457
let version = version.trim();
458458

459-
let bootstrap_out = if std::env::var("BOOTSTRAP_PYTHON").is_ok() {
460-
out.join("bootstrap").join("debug")
461-
} else {
462-
let workspace_target_dir = std::env::var("CARGO_TARGET_DIR")
463-
.map(PathBuf::from)
464-
.unwrap_or_else(|_| src.join("target"));
465-
let bootstrap_out = workspace_target_dir.join("debug");
466-
if !bootstrap_out.join("rustc").exists() && !cfg!(test) {
467-
// this restriction can be lifted whenever https://github.com/rust-lang/rfcs/pull/3028 is implemented
468-
panic!("run `cargo build --bins` before `cargo run`")
469-
}
470-
bootstrap_out
471-
};
459+
let bootstrap_out = std::env::current_exe()
460+
.expect("could not determine path to running process")
461+
.parent()
462+
.unwrap()
463+
.to_path_buf();
464+
if !bootstrap_out.join("rustc").exists() && !cfg!(test) {
465+
// this restriction can be lifted whenever https://github.com/rust-lang/rfcs/pull/3028 is implemented
466+
panic!("run `cargo build --bins` before `cargo run`")
467+
}
472468

473469
let mut build = Build {
474470
initial_rustc: config.initial_rustc.clone(),

0 commit comments

Comments
 (0)