about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorPietro Albini <pietro.albini@ferrous-systems.com>2023-11-13 11:18:55 +0100
committerPietro Albini <pietro.albini@ferrous-systems.com>2023-11-13 11:18:55 +0100
commitcd4adb8a3f011189985b9f367c9e84347b39c636 (patch)
treeb4a16c7cd8fdb0d6dae2560d1edb7b7980bee2ed /src/bootstrap
parent6eb3e97d5549f81bbdb8a5e94a005a338bc284ec (diff)
set CFG_OMIT_GIT_HASH=1 during builds when omit-git-hash is enabled
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 441931e415c..276a1193cf2 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -975,6 +975,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);
     }