Skip to content

Commit a01a250

Browse files
committed
Use our own release profile to insulate from custom release profiles
1 parent cb6c757 commit a01a250

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/lib.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ use anyhow::{bail, Context, Result};
1717
use tempfile::TempDir;
1818
use walkdir::WalkDir;
1919

20+
/// The name of the profile used for buliding the sysroot.
21+
const SYSROOT_PROFILE: &str = "sysroot_release";
22+
2023
/// Returns where the given rustc stores its sysroot source code.
2124
pub fn rustc_sysroot_src(mut rustc: Command) -> Result<PathBuf> {
2225
let output = rustc
@@ -347,6 +350,23 @@ version = "0.0.0"
347350
# empty dummy, just so that things are being built
348351
path = "lib.rs"
349352
353+
[profile.{SYSROOT_PROFILE}]
354+
# While it says "inherits", we override all settings.
355+
# This is to insulate us from any custom release profile.
356+
# The only reason we use inherits is because it's required.
357+
inherits = "release"
358+
opt-level = 3
359+
debug = false
360+
strip = "none"
361+
split-debuginfo = 'off'
362+
debug-assertions = false
363+
overflow-checks = false
364+
lto = false
365+
panic = 'unwind'
366+
incremental = false
367+
codegen-units = 16
368+
rpath = false
369+
350370
{crates}
351371
352372
{patches}
@@ -426,7 +446,8 @@ path = "lib.rs"
426446
// Run cargo.
427447
let mut cmd = cargo;
428448
cmd.arg(self.mode.as_str());
429-
cmd.arg("--release");
449+
cmd.arg("--profile");
450+
cmd.arg("sysroot_release");
430451
cmd.arg("--manifest-path");
431452
cmd.arg(&manifest_file);
432453
cmd.arg("--target");
@@ -458,7 +479,7 @@ path = "lib.rs"
458479
TempDir::new_in(&self.sysroot_dir).context("failed to create staging dir")?;
459480
let out_dir = build_target_dir
460481
.join(&target_name)
461-
.join("release")
482+
.join(SYSROOT_PROFILE)
462483
.join("deps");
463484
for entry in fs::read_dir(&out_dir).context("failed to read cargo out dir")? {
464485
let entry = entry.context("failed to read cargo out dir entry")?;

0 commit comments

Comments
 (0)