Skip to content

Commit

Permalink
Auto merge of rust-lang#117868 - ferrocene:pa-omit-git-hash, r=Mark-S…
Browse files Browse the repository at this point in the history
…imulacrum

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 rust-lang/cargo#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.
  • Loading branch information
bors committed Nov 19, 2023
2 parents ea6b131 + cd4adb8 commit 0d3dfb5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 0d3dfb5

Please sign in to comment.