Skip to content

Commit 0d8d22f

Browse files
committed
Auto merge of #14370 - weihanglo:build-std, r=Muscraft
fix: std Cargo.lock moved to `library` dir #14358 didn't check the correct Cargo.lock existence Perhaps it was there so the test passed, but after a new nightly is out it is gone. ``` Blocking waiting for file lock on package cache error: "/home/user/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/Cargo.lock" does not exist, unable to build with the standard library, try: rustup component add rust-src --toolchain nightly-aarch64-apple-darwin note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Fixes rust-lang/rust#128808 ### How to test the change: The current nightly `cargo 1.82.0-nightly (94977cb 2024-08-06)` would fail when running ``` cargo +nightly build -Zbuild-std --target <host-triple> ``` After this fix, it should just work ``` RUSTC=~/.rustup/toolchains/nightly-<host-triple>/bin/rustc ./target/debug/cargo build -Zbuild-std --target <host-triple> ```
2 parents f50c592 + 50237f4 commit 0d8d22f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/cargo/core/compiler/standard_lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn resolve_std<'gctx>(
7373
}
7474

7575
let src_path = detect_sysroot_src_path(target_data)?;
76-
let std_ws_manifest_path = src_path.join("library").join("Cargo.toml");
76+
let std_ws_manifest_path = src_path.join("Cargo.toml");
7777
let gctx = ws.gctx();
7878
// TODO: Consider doing something to enforce --locked? Or to prevent the
7979
// lock file from being written, such as setting ephemeral.
@@ -192,7 +192,8 @@ fn detect_sysroot_src_path(target_data: &RustcTargetData<'_>) -> CargoResult<Pat
192192
.join("lib")
193193
.join("rustlib")
194194
.join("src")
195-
.join("rust");
195+
.join("rust")
196+
.join("library");
196197
let lock = src_path.join("Cargo.lock");
197198
if !lock.exists() {
198199
let msg = format!(

tests/testsuite/standard_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn setup() -> Setup {
132132
fn enable_build_std(e: &mut Execs, setup: &Setup) {
133133
// First up, force Cargo to use our "mock sysroot" which mimics what
134134
// libstd looks like upstream.
135-
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/testsuite/mock-std");
135+
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/testsuite/mock-std/library");
136136
e.env("__CARGO_TESTS_ONLY_SRC_ROOT", &root);
137137

138138
e.masquerade_as_nightly_cargo(&["build-std"]);

0 commit comments

Comments
 (0)