Skip to content

Rust bootstrap sysroot now has src in the same place as rust-src #1300

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
Apr 4, 2020
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 rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
537ccdf3ac44c8c7a8d36cbdbe6fb224afabb7ae
6050e523bae6de61de4e060facc43dc512adaccd
41 changes: 13 additions & 28 deletions src/bin/cargo-miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,34 +301,19 @@ fn setup(ask_user: bool) {
.stdout;
let sysroot = std::str::from_utf8(&sysroot).unwrap();
let sysroot = Path::new(sysroot.trim_end_matches('\n'));
// First try: `$SYSROOT/lib/rustlib/src/rust`; test if that contains `Cargo.lock`.
let rustup_src = sysroot.join("lib").join("rustlib").join("src").join("rust");
let base_dir = if rustup_src.join("Cargo.lock").exists() {
// Just use this.
rustup_src
} else {
// Maybe this is a local toolchain built with `x.py` and linked into `rustup`?
// Second try: `$SYSROOT/../../..`; test if that contains `x.py`.
let local_src = sysroot.parent().and_then(Path::parent).and_then(Path::parent);
match local_src {
Some(local_src) if local_src.join("x.py").exists() => {
// Use this.
PathBuf::from(local_src)
}
_ => {
// Fallback: Ask the user to install the `rust-src` component, and use that.
let mut cmd = Command::new("rustup");
cmd.args(&["component", "add", "rust-src"]);
ask_to_run(
cmd,
ask_user,
"install the rustc-src component for the selected toolchain",
);
rustup_src
}
}
};
base_dir.join("src") // Xargo wants the src-subdir
// Check for `$SYSROOT/lib/rustlib/src/rust/src`; test if that contains `libstd/lib.rs`.
let rustup_src = sysroot.join("lib").join("rustlib").join("src").join("rust").join("src");
Copy link
Member

Choose a reason for hiding this comment

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

Hmm I should note something: $sysroot/lib/rustlib/src/rust corresponds to the "root" of rust-lang/rust, that's why it has a further src in it. It's annoying that it repeats but I think it would be to work with if $sysroot/lib/rustlib/src/rust was the directory being referred to and src/libstd/lib.rs a path within that directory.

Sadly it seems like XARGO_RUST_SRC includes the src directory component of rust-lang/rust, so this entire comment is unactionable 😞.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it would be nicer to treat rustlib/src/rust as the root but as you said, that's not what xargo did, and now it's too late to change it (and not worth trying anyway).

if !rustup_src.join("libstd").join("lib.rs").exists() {
// Ask the user to install the `rust-src` component, and use that.
let mut cmd = Command::new("rustup");
cmd.args(&["component", "add", "rust-src"]);
ask_to_run(
cmd,
ask_user,
"install the rustc-src component for the selected toolchain",
);
}
rustup_src
}
};
if !rust_src.exists() {
Expand Down