summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-lang/rust/files')
-rw-r--r--dev-lang/rust/files/1.53.0-miri-vergen.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/dev-lang/rust/files/1.53.0-miri-vergen.patch b/dev-lang/rust/files/1.53.0-miri-vergen.patch
new file mode 100644
index 000000000000..347f147c9942
--- /dev/null
+++ b/dev-lang/rust/files/1.53.0-miri-vergen.patch
@@ -0,0 +1,53 @@
+From 64f128c45687d18d64fc6856a30fde585b007e00 Mon Sep 17 00:00:00 2001
+From: Ralf Jung <post@ralfj.de>
+Date: Sat, 15 May 2021 14:17:30 +0200
+Subject: [PATCH] support building Miri outside a git repo
+
+---
+ cargo-miri/bin.rs | 14 ++++++++------
+ cargo-miri/build.rs | 2 +-
+ 2 files changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/cargo-miri/bin.rs b/cargo-miri/bin.rs
+index e29bdc771..84447b3a1 100644
+--- a/src/tools/miri/cargo-miri/bin.rs
++++ b/src/tools/miri/cargo-miri/bin.rs
+@@ -6,6 +6,7 @@ use std::io::{self, BufRead, BufReader, BufWriter, Read, Write};
+ use std::ops::Not;
+ use std::path::{Path, PathBuf};
+ use std::process::Command;
++use std::fmt::{Write as _};
+
+ use serde::{Deserialize, Serialize};
+
+@@ -90,12 +91,13 @@ fn show_help() {
+ }
+
+ fn show_version() {
+- println!(
+- "miri {} ({} {})",
+- env!("CARGO_PKG_VERSION"),
+- env!("VERGEN_GIT_SHA_SHORT"),
+- env!("VERGEN_GIT_COMMIT_DATE")
+- );
++ let mut version = format!("miri {}", env!("CARGO_PKG_VERSION"));
++ // Only use `option_env` on vergen variables to ensure the build succeeds
++ // when vergen failed to find the git info.
++ if let Some(sha) = option_env!("VERGEN_GIT_SHA_SHORT") {
++ write!(&mut version, " ({} {})", sha, option_env!("VERGEN_GIT_COMMIT_DATE").unwrap()).unwrap();
++ }
++ println!("{}", version);
+ }
+
+ fn show_error(msg: String) -> ! {
+diff --git a/cargo-miri/build.rs b/cargo-miri/build.rs
+index cff135fe4..ebd8e7003 100644
+--- a/src/tools/miri/cargo-miri/build.rs
++++ b/src/tools/miri/cargo-miri/build.rs
+@@ -7,5 +7,5 @@ fn main() {
+ let mut gen_config = vergen::Config::default();
+ *gen_config.git_mut().sha_kind_mut() = vergen::ShaKind::Short;
+ *gen_config.git_mut().commit_timestamp_kind_mut() = vergen::TimestampKind::DateOnly;
+- vergen(gen_config).expect("Unable to generate vergen keys!");
++ vergen(gen_config).ok(); // Ignore failure (in case we are built outside a git repo)
+ }