From 5f0856804292a6f4b73cb0f5771877657d8f6af8 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 16 Nov 2020 14:08:21 -0800 Subject: [PATCH] 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`. --- config.toml.example | 5 +++++ src/bootstrap/config.rs | 3 +++ src/bootstrap/configure.py | 1 + src/bootstrap/lib.rs | 8 +++++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config.toml.example b/config.toml.example index c9e183887504c..5b045d4e32d8d 100644 --- a/config.toml.example +++ b/config.toml.example @@ -446,6 +446,11 @@ changelog-seen = 2 # nightly features #channel = "dev" +# 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. +#description = "" + # The root location of the musl installation directory. #musl-root = "..." diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 94319a6d1e9e2..b8ec666ff95a5 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -152,6 +152,7 @@ pub struct Config { // misc pub low_priority: bool, pub channel: String, + pub description: Option, pub verbose_tests: bool, pub save_toolstates: Option, pub print_step_timings: bool, @@ -470,6 +471,7 @@ struct Rust { parallel_compiler: Option, default_linker: Option, channel: Option, + description: Option, musl_root: Option, rpath: Option, verbose_tests: Option, @@ -841,6 +843,7 @@ impl Config { .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); set(&mut config.backtrace, rust.backtrace); set(&mut config.channel, rust.channel); + config.description = rust.description; set(&mut config.rust_dist_src, rust.dist_src); set(&mut config.verbose_tests, rust.verbose_tests); // in the case "false" is set explicitly, do not overwrite the command line args diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 322e9d6923295..42f00ce962174 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -146,6 +146,7 @@ def v(*args): v("experimental-targets", "llvm.experimental-targets", "experimental LLVM targets to build") v("release-channel", "rust.channel", "the name of the release channel to build") +v("release-description", "rust.description", "optional descriptive string for version output") # Used on systems where "cc" is unavailable v("default-linker", "rust.default-linker", "the default linker") diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index ca140b9d27828..06ccd72186dd1 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1082,7 +1082,13 @@ impl Build { /// Note that this is a descriptive string which includes the commit date, /// sha, version, etc. fn rust_version(&self) -> String { - self.rust_info.version(self, &self.version) + let mut version = self.rust_info.version(self, &self.version); + if let Some(ref s) = self.config.description { + version.push_str(" ("); + version.push_str(s); + version.push_str(")"); + } + version } /// Returns the full commit hash.