summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-19 01:05:22 +0000
committerbors <bors@rust-lang.org>2023-11-19 01:05:22 +0000
commit0d3dfb529610660794b421d3b703fe44abb3ff47 (patch)
treee99b42c6d8c239aa949f327a02560a5f2865f251 /src/bootstrap
parentea6b131132eb383e8f4ae136fc39c4dec53b8ec6 (diff)
parentcd4adb8a3f011189985b9f367c9e84347b39c636 (diff)
downloadrust-0d3dfb529610660794b421d3b703fe44abb3ff47.tar.gz
rust-0d3dfb529610660794b421d3b703fe44abb3ff47.zip
Auto merge of #117868 - ferrocene:pa-omit-git-hash, r=Mark-Simulacrum
Set `CFG_OMIT_GIT_HASH=1` during builds when `omit-git-hash` is enabled

This environment variable will allow tools like Cargo to disable their own detection when `omit-git-hash` is set to `true`.

I created this PR because of https://github.com/rust-lang/cargo/pull/12968. There is not a dependency between the two PRs, they can land in any order. They just won't do anything until both of them are merged into the repo.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/core/build_steps/compile.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index 51e4195827f..c253dd2c6aa 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -1005,6 +1005,13 @@ pub fn rustc_cargo_env(
         .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
         .env("CFG_VERSION", builder.rust_version());
 
+    // Some tools like Cargo detect their own git information in build scripts. When omit-git-hash
+    // is enabled in config.toml, we pass this environment variable to tell build scripts to avoid
+    // detecting git information on their own.
+    if builder.config.omit_git_hash {
+        cargo.env("CFG_OMIT_GIT_HASH", "1");
+    }
+
     if let Some(backend) = builder.config.default_codegen_backend() {
         cargo.env("CFG_DEFAULT_CODEGEN_BACKEND", backend);
     }