Skip to content

Commit dac4ffd

Browse files
authored
Rollup merge of #137723 - onur-ozkan:cfg-ver-description, r=pietroalbini,weihanglo
Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION` Moves the `description` field from the `rust` section to the `build` section as it can be useful for tools and is not specific to rustc. Also passes this value to tool builds through the `CFG_VER_DESCRIPTION` env. Motivated from https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Propagate.20rust.2Edescription.20to.20tools.20in.20dist.20build
2 parents 4aa61e7 + 9646c2f commit dac4ffd

File tree

5 files changed

+37
-14
lines changed

5 files changed

+37
-14
lines changed

config.example.toml

+11-11
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@
189189
# The default stage to use for the `bench` subcommand
190190
#bench-stage = 2
191191

192+
# A descriptive string to be appended to version output (e.g., `rustc --version`),
193+
# which is also used in places like debuginfo `DW_AT_producer`. This may be useful for
194+
# supplementary build information, like distro-specific package versions.
195+
#
196+
# The Rust compiler will differentiate between versions of itself, including
197+
# based on this string, which means that if you wish to be compatible with
198+
# upstream Rust you need to set this to "". However, note that if you set this to "" but
199+
# are not actually compatible -- for example if you've backported patches that change
200+
# behavior -- this may lead to miscompilations or other bugs.
201+
#description = ""
202+
192203
# Build triple for the pre-compiled snapshot compiler. If `rustc` is set, this must match its host
193204
# triple (see `rustc --version --verbose`; cross-compiling the rust build system itself is NOT
194205
# supported). If `rustc` is unset, this must be a platform with pre-compiled host tools
@@ -615,17 +626,6 @@
615626
# If using tarball sources, default value is "auto-detect", otherwise, it's "dev".
616627
#channel = if "is a tarball source" { "auto-detect" } else { "dev" }
617628

618-
# A descriptive string to be appended to `rustc --version` output, which is
619-
# also used in places like debuginfo `DW_AT_producer`. This may be useful for
620-
# supplementary build information, like distro-specific package versions.
621-
#
622-
# The Rust compiler will differentiate between versions of itself, including
623-
# based on this string, which means that if you wish to be compatible with
624-
# upstream Rust you need to set this to "". However, note that if you are not
625-
# actually compatible -- for example if you've backported patches that change
626-
# behavior -- this may lead to miscompilations or other bugs.
627-
#description = ""
628-
629629
# The root location of the musl installation directory. The library directory
630630
# will also need to contain libunwind.a for an unwinding implementation. Note
631631
# that this option only makes sense for musl targets that produce statically

src/bootstrap/configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def v(*args):
292292
v("release-channel", "rust.channel", "the name of the release channel to build")
293293
v(
294294
"release-description",
295-
"rust.description",
295+
"build.description",
296296
"optional descriptive string for version output",
297297
)
298298
v("dist-compression-formats", None, "List of compression formats to use")

src/bootstrap/src/core/build_steps/tool.rs

+9
Original file line numberDiff line numberDiff line change
@@ -248,23 +248,32 @@ pub fn prepare_tool_cargo(
248248
cargo.env("CFG_VERSION", builder.rust_version());
249249
cargo.env("CFG_RELEASE_NUM", &builder.version);
250250
cargo.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel());
251+
251252
if let Some(ref ver_date) = builder.rust_info().commit_date() {
252253
cargo.env("CFG_VER_DATE", ver_date);
253254
}
255+
254256
if let Some(ref ver_hash) = builder.rust_info().sha() {
255257
cargo.env("CFG_VER_HASH", ver_hash);
256258
}
257259

260+
if let Some(description) = &builder.config.description {
261+
cargo.env("CFG_VER_DESCRIPTION", description);
262+
}
263+
258264
let info = GitInfo::new(builder.config.omit_git_hash, &dir);
259265
if let Some(sha) = info.sha() {
260266
cargo.env("CFG_COMMIT_HASH", sha);
261267
}
268+
262269
if let Some(sha_short) = info.sha_short() {
263270
cargo.env("CFG_SHORT_COMMIT_HASH", sha_short);
264271
}
272+
265273
if let Some(date) = info.commit_date() {
266274
cargo.env("CFG_COMMIT_DATE", date);
267275
}
276+
268277
if !features.is_empty() {
269278
cargo.arg("--features").arg(features.join(", "));
270279
}

src/bootstrap/src/core/config/config.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ define_config! {
894894
#[derive(Default)]
895895
struct Build {
896896
build: Option<String> = "build",
897+
description: Option<String> = "description",
897898
host: Option<Vec<String>> = "host",
898899
target: Option<Vec<String>> = "target",
899900
build_dir: Option<String> = "build-dir",
@@ -1176,6 +1177,7 @@ define_config! {
11761177
incremental: Option<bool> = "incremental",
11771178
default_linker: Option<String> = "default-linker",
11781179
channel: Option<String> = "channel",
1180+
// FIXME: Remove this field at Q2 2025, it has been replaced by build.description
11791181
description: Option<String> = "description",
11801182
musl_root: Option<String> = "musl-root",
11811183
rpath: Option<bool> = "rpath",
@@ -1583,6 +1585,7 @@ impl Config {
15831585
config.change_id = toml.change_id.inner;
15841586

15851587
let Build {
1588+
mut description,
15861589
build,
15871590
host,
15881591
target,
@@ -1831,7 +1834,7 @@ impl Config {
18311834
randomize_layout,
18321835
default_linker,
18331836
channel: _, // already handled above
1834-
description,
1837+
description: rust_description,
18351838
musl_root,
18361839
rpath,
18371840
verbose_tests,
@@ -1924,7 +1927,12 @@ impl Config {
19241927
set(&mut config.jemalloc, jemalloc);
19251928
set(&mut config.test_compare_mode, test_compare_mode);
19261929
set(&mut config.backtrace, backtrace);
1927-
config.description = description;
1930+
if rust_description.is_some() {
1931+
eprintln!(
1932+
"Warning: rust.description is deprecated. Use build.description instead."
1933+
);
1934+
}
1935+
description = description.or(rust_description);
19281936
set(&mut config.rust_dist_src, dist_src);
19291937
set(&mut config.verbose_tests, verbose_tests);
19301938
// in the case "false" is set explicitly, do not overwrite the command line args
@@ -1990,6 +1998,7 @@ impl Config {
19901998
}
19911999

19922000
config.reproducible_artifacts = flags.reproducible_artifact;
2001+
config.description = description;
19932002

19942003
// We need to override `rust.channel` if it's manually specified when using the CI rustc.
19952004
// This is because if the compiler uses a different channel than the one specified in config.toml,

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
365365
severity: ChangeSeverity::Info,
366366
summary: "`rust.channel` now supports \"auto-detect\" to load the channel from `src/ci/channel`",
367367
},
368+
ChangeInfo {
369+
change_id: 137723,
370+
severity: ChangeSeverity::Info,
371+
summary: "The rust.description option has moved to build.description and rust.description is now deprecated.",
372+
},
368373
];

0 commit comments

Comments
 (0)