Skip to content
Open
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
33 changes: 24 additions & 9 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,13 +1185,15 @@ impl Step for Rustc {
{
// jemalloc_sys and rustc_public_bridge are not linked into librustc_driver.so,
// so we need to distribute them as rlib to be able to use them.
filename.ends_with(".rlib")
} else {
// Distribute the rest of the rustc crates as rmeta files only to reduce
// the tarball sizes by about 50%. The object files are linked into
// librustc_driver.so, so it is still possible to link against them.
filename.ends_with(".rmeta")
if filename.ends_with(".rlib") {
return true;
}
}

// Distribute the rest of the rustc crates as rmeta files only to reduce
// the tarball sizes by about 50%. The object files are linked into
// librustc_driver.so, so it is still possible to link against them.
filename.ends_with(".rmeta")
})),
);

Expand Down Expand Up @@ -1732,7 +1734,7 @@ impl Step for GccCodegenBackend {

let _guard =
builder.msg(Kind::Build, "codegen backend gcc", Mode::Codegen, build_compiler, host);
let files = run_cargo(builder, cargo, vec![], &stamp, vec![], ArtifactKeepMode::OnlyRlib);
let files = run_cargo(builder, cargo, vec![], &stamp, vec![], ArtifactKeepMode::OnlyDylib);

GccCodegenBackendOutput {
stamp: write_codegen_backend_stamp(stamp, files, builder.config.dry_run()),
Expand Down Expand Up @@ -1808,7 +1810,7 @@ impl Step for CraneliftCodegenBackend {
build_compiler,
target,
);
let files = run_cargo(builder, cargo, vec![], &stamp, vec![], ArtifactKeepMode::OnlyRlib);
let files = run_cargo(builder, cargo, vec![], &stamp, vec![], ArtifactKeepMode::OnlyDylib);
write_codegen_backend_stamp(stamp, files, builder.config.dry_run())
}

Expand Down Expand Up @@ -2642,6 +2644,8 @@ pub fn add_to_sysroot(
/// build stamp, and thus be included in dist archives and copied into sysroots by default.
/// Note that some kinds of artifacts are copied automatically (e.g. native libraries).
pub enum ArtifactKeepMode {
/// Only keep .so files, ignore .rlib and .rmeta files
OnlyDylib,
/// Only keep .rlib files, ignore .rmeta files
OnlyRlib,
/// Only keep .rmeta files, ignore .rlib files
Expand All @@ -2657,7 +2661,7 @@ pub enum ArtifactKeepMode {

pub fn run_cargo(
builder: &Builder<'_>,
cargo: Cargo,
mut cargo: Cargo,
tail_args: Vec<String>,
stamp: &BuildStamp,
additional_target_deps: Vec<(PathBuf, DependencyType)>,
Expand All @@ -2675,6 +2679,16 @@ pub fn run_cargo(
.unwrap() // chop off `$target`
.join(target_root_dir.file_name().unwrap());

match artifact_keep_mode {
ArtifactKeepMode::OnlyDylib
| ArtifactKeepMode::OnlyRmeta
| ArtifactKeepMode::BothRlibAndRmeta
| ArtifactKeepMode::Custom(_) => {
cargo.arg("-Zno-embed-metadata");
}
ArtifactKeepMode::OnlyRlib => {}
}

// Spawn Cargo slurping up its JSON output. We'll start building up the
// `deps` array of all files it generated along with a `toplevel` array of
// files we need to probe for later.
Expand Down Expand Up @@ -2704,6 +2718,7 @@ pub fn run_cargo(
true
} else {
match &artifact_keep_mode {
ArtifactKeepMode::OnlyDylib => false,
ArtifactKeepMode::OnlyRlib => filename.ends_with(".rlib"),
ArtifactKeepMode::OnlyRmeta => filename.ends_with(".rmeta"),
ArtifactKeepMode::BothRlibAndRmeta => {
Expand Down
4 changes: 0 additions & 4 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,10 +1095,6 @@ 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
Loading