about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-04-18 05:28:44 +0000
committerbors <bors@rust-lang.org>2023-04-18 05:28:44 +0000
commit74864fa496997a6498e623f0d2019ccb7eb6dad0 (patch)
tree90fc9fcdd8e4fb35b88ffa626a5f97a0b2734a62 /src/bootstrap
parent386025117a6b7cd9e7f7c96946793db2ec8aa24c (diff)
parent5606653f01b6b2fbcbaa1b2ff37e04d4e66486f8 (diff)
Auto merge of #110481 - matthiaskrgr:rollup-phkkgm9, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109981 (Set commit information environment variables when building tools)
 - #110348 (Add list of supported disambiguators and suffixes for intra-doc links in the rustdoc book)
 - #110409 (Don't use `serde_json` to serialize a simple JSON object)
 - #110442 (Avoid including dry run steps in the build metrics)
 - #110450 (rustdoc: Fix invalid handling of nested items with `--document-private-items`)
 - #110461 (Use `Item::expect_*` and `ImplItem::expect_*` more)
 - #110465 (Assure everyone that `has_type_flags` is fast)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/builder.rs4
-rw-r--r--src/bootstrap/metrics.rs23
-rw-r--r--src/bootstrap/render_tests.rs1
-rw-r--r--src/bootstrap/test.rs4
-rw-r--r--src/bootstrap/tool.rs6
5 files changed, 32 insertions, 6 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index e959ea06f8b..4977ce22724 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -2030,7 +2030,7 @@ impl<'a> Builder<'a> {
         }
 
         #[cfg(feature = "build-metrics")]
-        self.metrics.enter_step(&step);
+        self.metrics.enter_step(&step, self);
 
         let (out, dur) = {
             let start = Instant::now();
@@ -2056,7 +2056,7 @@ impl<'a> Builder<'a> {
         }
 
         #[cfg(feature = "build-metrics")]
-        self.metrics.exit_step();
+        self.metrics.exit_step(self);
 
         {
             let mut stack = self.stack.borrow_mut();
diff --git a/src/bootstrap/metrics.rs b/src/bootstrap/metrics.rs
index 82b123ec8a5..e19d56ccd6a 100644
--- a/src/bootstrap/metrics.rs
+++ b/src/bootstrap/metrics.rs
@@ -4,7 +4,7 @@
 //! As this module requires additional dependencies not present during local builds, it's cfg'd
 //! away whenever the `build.metrics` config option is not set to `true`.
 
-use crate::builder::Step;
+use crate::builder::{Builder, Step};
 use crate::util::t;
 use crate::Build;
 use serde_derive::{Deserialize, Serialize};
@@ -33,7 +33,12 @@ impl BuildMetrics {
         BuildMetrics { state }
     }
 
-    pub(crate) fn enter_step<S: Step>(&self, step: &S) {
+    pub(crate) fn enter_step<S: Step>(&self, step: &S, builder: &Builder<'_>) {
+        // Do not record dry runs, as they'd be duplicates of the actual steps.
+        if builder.config.dry_run() {
+            return;
+        }
+
         let mut state = self.state.borrow_mut();
 
         // Consider all the stats gathered so far as the parent's.
@@ -56,7 +61,12 @@ impl BuildMetrics {
         });
     }
 
-    pub(crate) fn exit_step(&self) {
+    pub(crate) fn exit_step(&self, builder: &Builder<'_>) {
+        // Do not record dry runs, as they'd be duplicates of the actual steps.
+        if builder.config.dry_run() {
+            return;
+        }
+
         let mut state = self.state.borrow_mut();
 
         self.collect_stats(&mut *state);
@@ -74,7 +84,12 @@ impl BuildMetrics {
         }
     }
 
-    pub(crate) fn record_test(&self, name: &str, outcome: TestOutcome) {
+    pub(crate) fn record_test(&self, name: &str, outcome: TestOutcome, builder: &Builder<'_>) {
+        // Do not record dry runs, as they'd be duplicates of the actual steps.
+        if builder.config.dry_run() {
+            return;
+        }
+
         let mut state = self.state.borrow_mut();
         state
             .running_steps
diff --git a/src/bootstrap/render_tests.rs b/src/bootstrap/render_tests.rs
index 19019ad2c08..a56db9cccfe 100644
--- a/src/bootstrap/render_tests.rs
+++ b/src/bootstrap/render_tests.rs
@@ -124,6 +124,7 @@ impl<'a> Renderer<'a> {
                     ignore_reason: reason.map(|s| s.to_string()),
                 },
             },
+            self.builder,
         );
 
         if self.builder.config.verbose_tests {
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index aedf1ecab13..3814dc63ed4 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1804,6 +1804,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
 
         cmd.arg("--channel").arg(&builder.config.channel);
 
+        if !builder.config.omit_git_hash {
+            cmd.arg("--git-hash");
+        }
+
         if let Some(commit) = builder.config.download_rustc_commit() {
             cmd.env("FAKE_DOWNLOAD_RUSTC_PREFIX", format!("/rustc/{commit}"));
         }
diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
index c732fd7e833..79fab00efe7 100644
--- a/src/bootstrap/tool.rs
+++ b/src/bootstrap/tool.rs
@@ -194,6 +194,12 @@ pub fn prepare_tool_cargo(
     cargo.env("CFG_VERSION", builder.rust_version());
     cargo.env("CFG_RELEASE_NUM", &builder.version);
     cargo.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel());
+    if let Some(ref ver_date) = builder.rust_info().commit_date() {
+        cargo.env("CFG_VER_DATE", ver_date);
+    }
+    if let Some(ref ver_hash) = builder.rust_info().sha() {
+        cargo.env("CFG_VER_HASH", ver_hash);
+    }
 
     let info = GitInfo::new(builder.config.omit_git_hash, &dir);
     if let Some(sha) = info.sha() {