Skip to content
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
10 changes: 9 additions & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ impl Step for Std {
if self.is_for_mir_opt_tests {
ArtifactKeepMode::OnlyRmeta
} else {
ArtifactKeepMode::OnlyRlib
// We use -Zno-embed-metadata for the standard library
ArtifactKeepMode::BothRlibAndRmeta
},
);

Expand Down Expand Up @@ -2645,6 +2646,10 @@ pub enum ArtifactKeepMode {
OnlyRlib,
/// Only keep .rmeta files, ignore .rlib files
OnlyRmeta,
/// Keep both .rlib and .rmeta files.
/// This is essentially only useful when using `-Zno-embed-metadata`, in which case both the
/// .rlib and .rmeta files are needed for compilation/linking.
BothRlibAndRmeta,
/// Custom logic for keeping an artifact
/// It receives the filename of an artifact, and returns true if it should be kept.
Custom(Box<dyn Fn(&str) -> bool>),
Expand Down Expand Up @@ -2701,6 +2706,9 @@ pub fn run_cargo(
match &artifact_keep_mode {
ArtifactKeepMode::OnlyRlib => filename.ends_with(".rlib"),
ArtifactKeepMode::OnlyRmeta => filename.ends_with(".rmeta"),
ArtifactKeepMode::BothRlibAndRmeta => {
filename.ends_with(".rmeta") || filename.ends_with(".rlib")
}
ArtifactKeepMode::Custom(func) => func(&filename),
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,10 @@ impl Builder<'_> {
// Enable usage of unstable features
cargo.env("RUSTC_BOOTSTRAP", "1");

if matches!(mode, Mode::Std) {
cargo.arg("-Zno-embed-metadata");
}

if self.config.dump_bootstrap_shims {
prepare_behaviour_dump_dir(self.build);

Expand Down
18 changes: 11 additions & 7 deletions tests/run-make/sysroot-crates-are-unstable/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ fn check_crate_is_unstable(cr: &Crate) {

print!("- Verifying that sysroot crate '{name}' is an unstable crate ...");

// Trying to use this crate from a user program should fail.
let output = rustc()
.crate_type("rlib")
.extern_(name, path)
.input("-")
.stdin_buf(format!("extern crate {name};"))
.run_fail();
// Checking if rmeta path exists
let rmeta_path = path.with_extension("rmeta");

let mut cmd = rustc();
cmd.crate_type("rlib").extern_(name, path); // Pass the rlib

if rmeta_path.exists() {
cmd.extern_(name, &rmeta_path);
}

let output = cmd.input("-").stdin_buf(format!("extern crate {name};")).run_fail();

// Make sure it failed for the intended reason, not some other reason.
// (The actual feature required varies between crates.)
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0152-duplicate-lang-items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!
//! Issue: <https://github.com/rust-lang/rust/issues/31788>

//@ normalize-stderr: "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
//@ normalize-stderr: "loaded from .*libstd-.*.rmeta" -> "loaded from SYSROOT/libstd-*.rmeta"
//@ dont-require-annotations: NOTE

#![feature(lang_items)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0152-duplicate-lang-items.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | | }
| |_^
|
= note: the lang item is first defined in crate `std` (which `E0152_duplicate_lang_items` depends on)
= note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
= note: first definition in `std` loaded from SYSROOT/libstd-*.rmeta
= note: second definition in the local crate (`E0152_duplicate_lang_items`)

error: aborting due to 1 previous error
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0152.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ normalize-stderr: "loaded from .*liballoc-.*.rlib" -> "loaded from SYSROOT/liballoc-*.rlib"
//@ normalize-stderr: "loaded from .*liballoc-.*.rmeta" -> "loaded from SYSROOT/liballoc-*.rmeta"
#![feature(lang_items)]

#[lang = "owned_box"]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0152.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | struct Foo<T>(T);
| ^^^^^^^^^^^^^^^^^
|
= note: the lang item is first defined in crate `alloc` (which `std` depends on)
= note: first definition in `alloc` loaded from SYSROOT/liballoc-*.rlib
= note: first definition in `alloc` loaded from SYSROOT/liballoc-*.rmeta
= note: second definition in the local crate (`E0152`)

error: aborting due to 1 previous error
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lang-items/duplicate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ normalize-stderr: "loaded from .*libcore-.*.rlib" -> "loaded from SYSROOT/libcore-*.rlib"
//@ normalize-stderr: "loaded from .*libcore-.*.rmeta" -> "loaded from SYSROOT/libcore-*.rmeta"
#![feature(lang_items)]

#[lang = "sized"]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lang-items/duplicate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | trait Sized {}
| ^^^^^^^^^^^^^^
|
= note: the lang item is first defined in crate `core` (which `std` depends on)
= note: first definition in `core` loaded from SYSROOT/libcore-*.rlib
= note: first definition in `core` loaded from SYSROOT/libcore-*.rmeta
= note: second definition in the local crate (`duplicate`)

error: aborting due to 1 previous error
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/panic-handler/panic-handler-std.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ normalize-stderr: "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
//@ normalize-stderr: "loaded from .*libstd-.*.rmeta" -> "loaded from SYSROOT/libstd-*.rmeta"

extern crate core;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/panic-handler/panic-handler-std.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | | }
| |_^
|
= note: the lang item is first defined in crate `std` (which `panic_handler_std` depends on)
= note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
= note: first definition in `std` loaded from SYSROOT/libstd-*.rmeta
= note: second definition in the local crate (`panic_handler_std`)

error: aborting due to 1 previous error
Expand Down
Loading