From 076ecff3f4c6ff978733a07814c0e6f90e0e6b3c Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 27 Feb 2024 17:03:32 -0500 Subject: [PATCH 1/2] fix(libstd): switch to `-Zpublic-dependency` cargo flag rust-lang/cargo#13340 switches the featurte gate for public-dependency from `cargo-features` in Cargo.toml to CLI flag `-Zpublic-dependency`. `cargo-features` will continue working for 1 to 2 release cycles as a transition period, to make sure that it doesn't break self-rebuilds. --- library/std/Cargo.toml | 2 -- src/bootstrap/src/core/build_steps/clean.rs | 3 ++- src/bootstrap/src/core/build_steps/dist.rs | 1 + src/bootstrap/src/core/build_steps/test.rs | 1 + src/bootstrap/src/core/metadata.rs | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index d2804b4d20af3..61572a8fecd97 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -1,5 +1,3 @@ -cargo-features = ["public-dependency"] - [package] name = "std" version = "0.0.0" diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index 9e103a350e654..008c753fa5d65 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -71,7 +71,8 @@ macro_rules! clean_crate_tree { // Since https://github.com/rust-lang/rust/pull/111076 enables // unstable cargo feature (`public-dependency`), we need to ensure // that unstable features are enabled before reading libstd Cargo.toml. - cargo.env("RUSTC_BOOTSTRAP", "1"); + cargo.env("RUSTC_BOOTSTRAP", "1") + .arg("-Zpublic-dependency"); for krate in &*self.crates { cargo.arg("-p"); diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 012d64e534439..033fcc02889a2 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -1014,6 +1014,7 @@ impl Step for PlainSourceTarball { // Will read the libstd Cargo.toml // which uses the unstable `public-dependency` feature. .env("RUSTC_BOOTSTRAP", "1") + .arg("-Zpublic-dependency") .current_dir(plain_dst_src); let config = if !builder.config.dry_run() { diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 6d3163b90b10c..9b182091ef24b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2899,6 +2899,7 @@ impl Step for Distcheck { // Will read the libstd Cargo.toml // which uses the unstable `public-dependency` feature. .env("RUSTC_BOOTSTRAP", "1") + .arg("-Zpublic-dependency") .arg("generate-lockfile") .arg("--manifest-path") .arg(&toml) diff --git a/src/bootstrap/src/core/metadata.rs b/src/bootstrap/src/core/metadata.rs index 08a96407a6917..25cca1882f6dd 100644 --- a/src/bootstrap/src/core/metadata.rs +++ b/src/bootstrap/src/core/metadata.rs @@ -76,6 +76,7 @@ fn workspace_members(build: &Build) -> impl Iterator { // Will read the libstd Cargo.toml // which uses the unstable `public-dependency` feature. .env("RUSTC_BOOTSTRAP", "1") + .arg("-Zpublic-dependency") .arg("metadata") .arg("--format-version") .arg("1") From 6fa351828f19c3f37b21447faeefa60cddc5a326 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sat, 23 Mar 2024 00:51:41 -0400 Subject: [PATCH 2/2] [DONT MERGE] let private dependencies scream! --- src/bootstrap/src/core/builder.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 7f93fdc72ef08..8e0d2a0820e2f 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1799,6 +1799,9 @@ impl<'a> Builder<'a> { // Enable usage of unstable features cargo.env("RUSTC_BOOTSTRAP", "1"); + // In addition, we enable Cargo's `-Zpublic-dependency` so that every + // build runs `exported-private-dependencies` and suppress unstable warnings. + cargo.arg("-Zpublic-dependency"); if self.config.dump_bootstrap_shims { prepare_behaviour_dump_dir(self.build);