-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Stabilize build-dir layout v2
#16807
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: master
Are you sure you want to change the base?
Changes from all commits
98a3a60
4a8f506
6383be1
6a4053c
5ae7823
d5087bb
867bf64
324047c
b9767f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -814,7 +814,7 @@ macro_rules! unstable_cli_options { | |
| /// Cargo, like `rustc`, accepts a suite of `-Z` flags which are intended for | ||
| /// gating unstable functionality to Cargo. These flags are only available on | ||
| /// the nightly channel of Cargo. | ||
| #[derive(Default, Debug, Deserialize)] | ||
| #[derive(Debug, Deserialize)] | ||
| #[serde(default, rename_all = "kebab-case")] | ||
| pub struct CliUnstable { | ||
| $( | ||
|
|
@@ -852,6 +852,68 @@ macro_rules! unstable_cli_options { | |
| } | ||
| } | ||
|
|
||
| // TODO: Move this back to derive(Default) once `build_dir_new_layout` is stabilized and the old | ||
| // layout has been removed. | ||
| impl Default for CliUnstable { | ||
|
Comment on lines
+855
to
+857
Contributor
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. Why not put the hack in My general recommendation is to be as surgical as possible with hacks/todos
Member
Author
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. ehh yeah its a bit tricky to spot the places it gets used.
My thought is that while this chunk is pretty ugly, its less invasive than trying to modify all of the functions that could potentially call |
||
| fn default() -> Self { | ||
| Self { | ||
| build_dir_new_layout: !is_new_build_dir_layout_opt_out(), | ||
|
|
||
| allow_features: Default::default(), | ||
| print_im_a_teapot: Default::default(), | ||
| advanced_env: Default::default(), | ||
| any_build_script_metadata: Default::default(), | ||
| asymmetric_token: Default::default(), | ||
| avoid_dev_deps: Default::default(), | ||
| binary_dep_depinfo: Default::default(), | ||
| bindeps: Default::default(), | ||
| build_analysis: Default::default(), | ||
| build_std: Default::default(), | ||
| build_std_features: Default::default(), | ||
| cargo_lints: Default::default(), | ||
| checksum_freshness: Default::default(), | ||
| codegen_backend: Default::default(), | ||
| direct_minimal_versions: Default::default(), | ||
| dual_proc_macros: Default::default(), | ||
| feature_unification: Default::default(), | ||
| features: Default::default(), | ||
| fine_grain_locking: Default::default(), | ||
| fix_edition: Default::default(), | ||
| gc: Default::default(), | ||
| git: Default::default(), | ||
| gitoxide: Default::default(), | ||
| host_config: Default::default(), | ||
| json_target_spec: Default::default(), | ||
| minimal_versions: Default::default(), | ||
| msrv_policy: Default::default(), | ||
| mtime_on_use: Default::default(), | ||
| next_lockfile_bump: Default::default(), | ||
| no_embed_metadata: Default::default(), | ||
| no_index_update: Default::default(), | ||
| panic_abort_tests: Default::default(), | ||
| panic_immediate_abort: Default::default(), | ||
| profile_hint_mostly_unused: Default::default(), | ||
| profile_rustflags: Default::default(), | ||
| public_dependency: Default::default(), | ||
| publish_timeout: Default::default(), | ||
| root_dir: Default::default(), | ||
| rustc_unicode: Default::default(), | ||
| rustdoc_depinfo: Default::default(), | ||
| rustdoc_map: Default::default(), | ||
| rustdoc_mergeable_info: Default::default(), | ||
| rustdoc_scrape_examples: Default::default(), | ||
| sbom: Default::default(), | ||
| script: Default::default(), | ||
| section_timings: Default::default(), | ||
| separate_nightlies: Default::default(), | ||
| skip_rustdoc_fingerprint: Default::default(), | ||
| target_applies_to_host: Default::default(), | ||
| trim_paths: Default::default(), | ||
| unstable_options: Default::default(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| unstable_cli_options!( | ||
| // Permanently unstable features: | ||
| allow_features: Option<AllowFeatures> = ("Allow *only* the listed unstable features"), | ||
|
|
@@ -1003,6 +1065,8 @@ const STABILIZED_LOCKFILE_PATH: &str = "The `lockfile-path` config key is now al | |
|
|
||
| const STABILIZED_WARNINGS: &str = "The `build.warnings` config key is now always available"; | ||
|
|
||
| const STABILIZED_BUILD_DIR_NEW_LAYOUT: &str = "build.build-dir-new-layout is now always enabled."; | ||
|
|
||
| fn deserialize_comma_separated_list<'de, D>( | ||
| deserializer: D, | ||
| ) -> Result<Option<Vec<String>>, D::Error> | ||
|
|
@@ -1268,6 +1332,12 @@ impl CliUnstable { | |
| self.gitoxide = GitoxideFeatures::safe().into(); | ||
| } | ||
|
|
||
| // NOTE: We set this before `implicitly_enable_features_if_needed` as `-Zfine-grain-locking` | ||
| // must use the new layout so that takes priority. | ||
| if is_new_build_dir_layout_opt_out() { | ||
| self.build_dir_new_layout = false; | ||
| } | ||
|
|
||
| self.implicitly_enable_features_if_needed(); | ||
|
|
||
| Ok(warnings) | ||
|
|
@@ -1393,6 +1463,7 @@ impl CliUnstable { | |
| "config-include" => stabilized_warn(k, "1.93", STABILIZED_CONFIG_INCLUDE), | ||
| "lockfile-path" => stabilized_warn(k, "1.97", STABILIZED_LOCKFILE_PATH), | ||
| "warnings" => stabilized_warn(k, "1.97", STABILIZED_WARNINGS), | ||
| "build-dir-new-layout" => stabilized_warn(k, "1.98", STABILIZED_BUILD_DIR_NEW_LAYOUT), | ||
|
|
||
| // Unstable features | ||
| // Sorted alphabetically: | ||
|
|
@@ -1403,7 +1474,6 @@ impl CliUnstable { | |
| "binary-dep-depinfo" => self.binary_dep_depinfo = parse_empty(k, v)?, | ||
| "bindeps" => self.bindeps = parse_empty(k, v)?, | ||
| "build-analysis" => self.build_analysis = parse_empty(k, v)?, | ||
| "build-dir-new-layout" => self.build_dir_new_layout = parse_empty(k, v)?, | ||
| "build-std" => self.build_std = Some(parse_list(v)), | ||
| "build-std-features" => self.build_std_features = Some(parse_list(v)), | ||
| "cargo-lints" => self.cargo_lints = parse_empty(k, v)?, | ||
|
|
@@ -1588,6 +1658,14 @@ fn cargo_use_gitoxide_instead_of_git2() -> bool { | |
| std::env::var_os("__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2").map_or(false, |value| value == "1") | ||
| } | ||
|
|
||
| #[expect( | ||
| clippy::disallowed_methods, | ||
| reason = "Temporary opt out that is not part of the public interface" | ||
| )] | ||
| fn is_new_build_dir_layout_opt_out() -> bool { | ||
| std::env::var("__CARGO_TEMPORARY_BUILD_DIR_NEW_LAYOUT_OPT_OUT").as_deref() == Ok("1") | ||
| } | ||
|
|
||
| /// Generate a link to Cargo documentation for the current release channel | ||
| /// `path` is the URL component after `https://doc.rust-lang.org/{channel}/cargo/` | ||
| pub fn cargo_docs_link(path: &str) -> String { | ||
|
|
||
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.
Is there any documentation we want to update when stabilizing this? I guess at least
unstable.md?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.
Also https://doc.rust-lang.org/cargo/reference/build-cache.html has some details about the
build-dirinternals.