Skip to content

Commit d806d65

Browse files
committed
Auto merge of #79115 - cuviper:rust-description, r=Mark-Simulacrum
x.py: allow a custom string appended to the version This adds `rust.description` to the config as a descriptive string to be appended to `rustc --version` output, which is also used in places like debuginfo `DW_AT_producer`. This may be useful for supplementary build information, like distro-specific package versions. For example, in Fedora 33, `gcc --version` outputs: gcc (GCC) 10.2.1 20201016 (Red Hat 10.2.1-6) With this change, we can add similar vendor info to `rustc --version`.
2 parents 539402c + 5f08568 commit d806d65

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

config.toml.example

+5
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ changelog-seen = 2
446446
# nightly features
447447
#channel = "dev"
448448

449+
# A descriptive string to be appended to `rustc --version` output, which is
450+
# also used in places like debuginfo `DW_AT_producer`. This may be useful for
451+
# supplementary build information, like distro-specific package versions.
452+
#description = ""
453+
449454
# The root location of the musl installation directory.
450455
#musl-root = "..."
451456

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ pub struct Config {
152152
// misc
153153
pub low_priority: bool,
154154
pub channel: String,
155+
pub description: Option<String>,
155156
pub verbose_tests: bool,
156157
pub save_toolstates: Option<PathBuf>,
157158
pub print_step_timings: bool,
@@ -470,6 +471,7 @@ struct Rust {
470471
parallel_compiler: Option<bool>,
471472
default_linker: Option<String>,
472473
channel: Option<String>,
474+
description: Option<String>,
473475
musl_root: Option<String>,
474476
rpath: Option<bool>,
475477
verbose_tests: Option<bool>,
@@ -841,6 +843,7 @@ impl Config {
841843
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
842844
set(&mut config.backtrace, rust.backtrace);
843845
set(&mut config.channel, rust.channel);
846+
config.description = rust.description;
844847
set(&mut config.rust_dist_src, rust.dist_src);
845848
set(&mut config.verbose_tests, rust.verbose_tests);
846849
// in the case "false" is set explicitly, do not overwrite the command line args

src/bootstrap/configure.py

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def v(*args):
146146
v("experimental-targets", "llvm.experimental-targets",
147147
"experimental LLVM targets to build")
148148
v("release-channel", "rust.channel", "the name of the release channel to build")
149+
v("release-description", "rust.description", "optional descriptive string for version output")
149150

150151
# Used on systems where "cc" is unavailable
151152
v("default-linker", "rust.default-linker", "the default linker")

src/bootstrap/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,13 @@ impl Build {
10821082
/// Note that this is a descriptive string which includes the commit date,
10831083
/// sha, version, etc.
10841084
fn rust_version(&self) -> String {
1085-
self.rust_info.version(self, &self.version)
1085+
let mut version = self.rust_info.version(self, &self.version);
1086+
if let Some(ref s) = self.config.description {
1087+
version.push_str(" (");
1088+
version.push_str(s);
1089+
version.push_str(")");
1090+
}
1091+
version
10861092
}
10871093

10881094
/// Returns the full commit hash.

0 commit comments

Comments
 (0)