Skip to content

Commit cca83af

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

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/lib.rs

Lines changed: 13 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 DEFAULT_SYSROOT_PROFILE: &str = "custom_sysroot";
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,13 @@ version = "0.0.0"
347350
# empty dummy, just so that things are being built
348351
path = "lib.rs"
349352
353+
[profile.{DEFAULT_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+
panic = 'unwind'
359+
350360
{crates}
351361
352362
{patches}
@@ -426,7 +436,8 @@ path = "lib.rs"
426436
// Run cargo.
427437
let mut cmd = cargo;
428438
cmd.arg(self.mode.as_str());
429-
cmd.arg("--release");
439+
cmd.arg("--profile");
440+
cmd.arg(DEFAULT_SYSROOT_PROFILE);
430441
cmd.arg("--manifest-path");
431442
cmd.arg(&manifest_file);
432443
cmd.arg("--target");
@@ -458,7 +469,7 @@ path = "lib.rs"
458469
TempDir::new_in(&self.sysroot_dir).context("failed to create staging dir")?;
459470
let out_dir = build_target_dir
460471
.join(&target_name)
461-
.join("release")
472+
.join(DEFAULT_SYSROOT_PROFILE)
462473
.join("deps");
463474
for entry in fs::read_dir(&out_dir).context("failed to read cargo out dir")? {
464475
let entry = entry.context("failed to read cargo out dir entry")?;

0 commit comments

Comments
 (0)