Skip to content

Commit 2761aae

Browse files
authored
Merge pull request #17 from RossSmyth/custom-release
Use our own release profile to insulate from custom release profiles
2 parents 126cf18 + c067311 commit 2761aae

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/lib.rs

Lines changed: 12 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
@@ -364,6 +367,12 @@ version = "0.0.0"
364367
# empty dummy, just so that things are being built
365368
path = "lib.rs"
366369
370+
[profile.{DEFAULT_SYSROOT_PROFILE}]
371+
# We inherit from the local release profile, but then overwrite some
372+
# settings to ensure we still get a working sysroot.
373+
inherits = "release"
374+
panic = 'unwind'
375+
367376
{crates}
368377
369378
{patches}
@@ -424,7 +433,8 @@ path = "lib.rs"
424433
// Run cargo.
425434
let mut cmd = cargo;
426435
cmd.arg(self.mode.as_str());
427-
cmd.arg("--release");
436+
cmd.arg("--profile");
437+
cmd.arg(DEFAULT_SYSROOT_PROFILE);
428438
cmd.arg("--manifest-path");
429439
cmd.arg(&manifest_file);
430440
cmd.arg("--target");
@@ -454,7 +464,7 @@ path = "lib.rs"
454464
TempDir::new_in(&self.sysroot_dir).context("failed to create staging dir")?;
455465
let out_dir = build_target_dir
456466
.join(&target_name)
457-
.join("release")
467+
.join(DEFAULT_SYSROOT_PROFILE)
458468
.join("deps");
459469
for entry in fs::read_dir(&out_dir).context("failed to read cargo out dir")? {
460470
let entry = entry.context("failed to read cargo out dir entry")?;

0 commit comments

Comments
 (0)