Use -Zno-embed-metadata for the codegen backend and sysroot

This saves about 10MB on the dist size and about 240MB on the build dir
size.
This commit is contained in:
bjorn3 2026-01-14 11:18:07 +00:00
parent 0b05e69bce
commit e4e41b7426
2 changed files with 4 additions and 1 deletions

View file

@ -43,6 +43,8 @@ pub(crate) fn build_backend(
cmd.arg("--release");
cmd.arg("-Zno-embed-metadata");
eprintln!("[BUILD] rustc_codegen_cranelift");
crate::utils::spawn_and_wait(cmd);

View file

@ -242,6 +242,7 @@ fn build_clif_sysroot_for_triple(
build_cmd.arg("--release");
build_cmd.arg("--features").arg("backtrace panic-unwind");
build_cmd.arg(format!("-Zroot-dir={}", STDLIB_SRC.to_path(dirs).display()));
build_cmd.arg("-Zno-embed-metadata");
build_cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "true");
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");
if compiler.triple.contains("apple") {
@ -256,7 +257,7 @@ fn build_clif_sysroot_for_triple(
for entry in fs::read_dir(build_dir.join("deps")).unwrap() {
let entry = entry.unwrap();
if let Some(ext) = entry.path().extension() {
if ext == "rmeta" || ext == "d" || ext == "dSYM" || ext == "clif" {
if ext == "d" || ext == "dSYM" || ext == "clif" {
continue;
}
} else {