Skip to content

Use our own release profile to insulate from custom release profiles #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2024
Merged
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
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use anyhow::{bail, Context, Result};
use tempfile::TempDir;
use walkdir::WalkDir;

/// The name of the profile used for buliding the sysroot.
const DEFAULT_SYSROOT_PROFILE: &str = "custom_sysroot";

/// Returns where the given rustc stores its sysroot source code.
pub fn rustc_sysroot_src(mut rustc: Command) -> Result<PathBuf> {
let output = rustc
Expand Down Expand Up @@ -347,6 +350,12 @@ version = "0.0.0"
# empty dummy, just so that things are being built
path = "lib.rs"

[profile.{DEFAULT_SYSROOT_PROFILE}]
# We inherit from the local release profile, but then overwrite some
# settings to ensure we still get a working sysroot.
inherits = "release"
panic = 'unwind'

{crates}

{patches}
Expand Down Expand Up @@ -426,7 +435,8 @@ path = "lib.rs"
// Run cargo.
let mut cmd = cargo;
cmd.arg(self.mode.as_str());
cmd.arg("--release");
cmd.arg("--profile");
cmd.arg(DEFAULT_SYSROOT_PROFILE);
cmd.arg("--manifest-path");
cmd.arg(&manifest_file);
cmd.arg("--target");
Expand Down Expand Up @@ -458,7 +468,7 @@ path = "lib.rs"
TempDir::new_in(&self.sysroot_dir).context("failed to create staging dir")?;
let out_dir = build_target_dir
.join(&target_name)
.join("release")
.join(DEFAULT_SYSROOT_PROFILE)
.join("deps");
for entry in fs::read_dir(&out_dir).context("failed to read cargo out dir")? {
let entry = entry.context("failed to read cargo out dir entry")?;
Expand Down