-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Move bootstrap configuration to library workspace #149514
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
ce86629
88a5974
7c01a90
890bbd1
0bae09c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,31 @@ rustflags = ["-Cpanic=abort"] | |
| [profile.release.package.panic_abort] | ||
| rustflags = ["-Cpanic=abort"] | ||
|
|
||
| # The "dist" profile is used by bootstrap for prebuilt libstd artifacts | ||
| # These settings ensure that the prebuilt artifacts support a variety of features | ||
| # in the user's profile. | ||
| [profile.dist] | ||
| inherits = "release" | ||
| codegen-units = 1 | ||
| debug = 1 # "limited" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this get unconditionally overridden by the value set for |
||
| rustflags = [ | ||
| # Unconditionally embedding bitcode is necessary for when users enable LTO. | ||
| # Until Cargo can rebuild the standard library with the user profile's `lto` | ||
| # setting, Cargo will force this to be `no` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the last sentence here - should that be
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cargo forces
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So in other words, Cargo will pass
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
| "-Cembed-bitcode=yes", | ||
| # Enable frame pointers | ||
| "-Zunstable-options", | ||
| "-Cforce-frame-pointers=non-leaf", | ||
| ] | ||
|
|
||
| [profile.dist.package.panic_abort] | ||
| rustflags = [ | ||
| "-Cpanic=abort", | ||
| "-Cembed-bitcode=yes", | ||
| "-Zunstable-options", | ||
| "-Cforce-frame-pointers=non-leaf", | ||
| ] | ||
|
|
||
| [patch.crates-io] | ||
| # See comments in `library/rustc-std-workspace-core/README.md` for what's going on here | ||
| rustc-std-workspace-core = { path = 'rustc-std-workspace-core' } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -103,9 +103,9 @@ pub struct Cargo { | |||||
| rustdocflags: Rustflags, | ||||||
| hostflags: HostFlags, | ||||||
| allow_features: String, | ||||||
| release_build: bool, | ||||||
| build_compiler_stage: u32, | ||||||
| extra_rustflags: Vec<String>, | ||||||
| profile: Option<&'static str>, | ||||||
| } | ||||||
|
|
||||||
| impl Cargo { | ||||||
|
|
@@ -134,7 +134,11 @@ impl Cargo { | |||||
| } | ||||||
|
|
||||||
| pub fn release_build(&mut self, release_build: bool) { | ||||||
| self.release_build = release_build; | ||||||
| self.profile = if release_build { Some("release") } else { None }; | ||||||
| } | ||||||
|
|
||||||
| pub fn profile(&mut self, profile: &'static str) { | ||||||
| self.profile = Some(profile) | ||||||
| } | ||||||
|
|
||||||
| pub fn compiler(&self) -> Compiler { | ||||||
|
|
@@ -400,8 +404,8 @@ impl Cargo { | |||||
|
|
||||||
| impl From<Cargo> for BootstrapCommand { | ||||||
| fn from(mut cargo: Cargo) -> BootstrapCommand { | ||||||
| if cargo.release_build { | ||||||
| cargo.args.insert(0, "--release".into()); | ||||||
| if let Some(profile) = cargo.profile { | ||||||
| cargo.args.insert(0, format!("--profile={profile}").into()); | ||||||
| } | ||||||
|
|
||||||
| for arg in &cargo.extra_rustflags { | ||||||
|
|
@@ -1396,9 +1400,18 @@ impl Builder<'_> { | |||||
| .unwrap_or(&self.config.rust_rustflags) | ||||||
| .clone(); | ||||||
|
|
||||||
| let release_build = self.config.rust_optimize.is_release() && | ||||||
| // cargo bench/install do not accept `--release` and miri doesn't want it | ||||||
| !matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest); | ||||||
| let profile = | ||||||
| if matches!(cmd_kind, Kind::Bench | Kind::Miri | Kind::MiriSetup | Kind::MiriTest) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Previously the code also handled |
||||||
| // Use the default profile for bench/miri | ||||||
| None | ||||||
| } else { | ||||||
| match (mode, self.config.rust_optimize.is_release()) { | ||||||
| // Some std configuration exists in its own profile | ||||||
| (Mode::Std, true) => Some("dist"), | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||
| (_, true) => Some("release"), | ||||||
| (_, false) => Some("dev"), | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| Cargo { | ||||||
| command: cargo, | ||||||
|
|
@@ -1409,9 +1422,9 @@ impl Builder<'_> { | |||||
| rustdocflags, | ||||||
| hostflags, | ||||||
| allow_features, | ||||||
| release_build, | ||||||
| build_compiler_stage, | ||||||
| extra_rustflags, | ||||||
| profile, | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
cargo_profile_varfunction will also need to be updated, so that it handles thedistprofile (eventually we should make that a hard error, but for now it's some things for Std are configured through it).