Skip to content

Commit

Permalink
rust: fix for rust-lang/rust#86436
Browse files Browse the repository at this point in the history
  • Loading branch information
moubctez committed Jun 22, 2021
1 parent db6d8f0 commit 13fac88
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rust/distinfo
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ SHA1 (patch-src_llvm-project_llvm_include_llvm_Analysis_ConstantFolding.h) = 977
SHA1 (patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp) = 2675b93a1d636b297a3e1e84b915a15a3da67939
SHA1 (patch-src_tools_cargo_src_cargo_core_profiles.rs) = 3aac5d54a6fe96b9559552e67e497488142d4e80
SHA1 (patch-src_tools_cargo_tests_testsuite_build.rs) = 10e6c1253adac0262b000aec7636fa0d2ebb666c
SHA1 (patch-src_tools_miri_cargo-miri_bin.rs) = d0a9c01e1ade98b8074784f9451efdec8e323532
SHA1 (patch-src_tools_miri_cargo-miri_build.rs) = 9d4e29a2be3caf815810acad1572fcb48756a0cb
SHA1 (patch-src_tools_rls_rls_src_cmd.rs) = fade3e60fecac5c4e4d4ee5bee82659b4eb385b7
SHA1 (patch-src_tools_rls_rls_src_server_io.rs) = 51af64526db55abcf6b4b3165df314a16cf62e34
SHA1 (patch-src_tools_rust-installer_install-template.sh) = f2533c2ae0d45d48b5ebea5d36842b4a1b9009af
Expand Down
34 changes: 34 additions & 0 deletions rust/patches/patch-src_tools_miri_cargo-miri_bin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
$NetBSD$

https://github.com/rust-lang/miri/commit/e5b340017e39dc90e3f9cf9966244faa585321b5

--- src/tools/miri/cargo-miri/bin.rs.orig 2021-06-22 08:33:05.000000000 +0000
+++ src/tools/miri/cargo-miri/bin.rs
@@ -6,6 +6,7 @@ use std::io::{self, BufRead, BufReader,
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) -> ! {
13 changes: 13 additions & 0 deletions rust/patches/patch-src_tools_miri_cargo-miri_build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$NetBSD$

https://github.com/rust-lang/miri/commit/e5b340017e39dc90e3f9cf9966244faa585321b5

--- src/tools/miri/cargo-miri/build.rs.orig 2021-06-22 08:31:31.000000000 +0000
+++ 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)
}

0 comments on commit 13fac88

Please sign in to comment.