Auto merge of #1684 - RalfJung:env, r=oli-obk
prefer build-time env vars over run-time values Fixes https://github.com/rust-lang/miri/issues/1661
This commit is contained in:
commit
e3ca994a6d
@ -286,6 +286,8 @@ different Miri binaries, and as such worth documenting:
|
||||
directory after loading all the source files, but before commencing
|
||||
interpretation. This is useful if the interpreted program wants a different
|
||||
working directory at run-time than at build-time.
|
||||
* `MIRI_VERBOSE` when set to any value tells the various `cargo-miri` phases to
|
||||
perform verbose logging.
|
||||
|
||||
[testing-miri]: CONTRIBUTING.md#testing-the-miri-driver
|
||||
|
||||
|
@ -655,16 +655,21 @@ fn phase_cargo_runner(binary: &Path, binary_args: env::Args) {
|
||||
let info: CrateRunInfo = serde_json::from_reader(file)
|
||||
.unwrap_or_else(|_| show_error(format!("file {:?} contains outdated or invalid JSON; try `cargo clean`", binary)));
|
||||
|
||||
// Set missing env vars. Looks like `build.rs` vars are still set at run-time, but
|
||||
// `CARGO_BIN_EXE_*` are not. This means we can give the run-time environment precedence,
|
||||
// to rather do too little than too much.
|
||||
let mut cmd = miri();
|
||||
|
||||
// Set missing env vars. We prefer build-time env vars over run-time ones; see
|
||||
// <https://github.com/rust-lang/miri/issues/1661> for the kind of issue that fixes.
|
||||
for (name, val) in info.env {
|
||||
if env::var_os(&name).is_none() {
|
||||
env::set_var(name, val);
|
||||
if verbose {
|
||||
if let Some(old_val) = env::var_os(&name) {
|
||||
if old_val != val {
|
||||
eprintln!("[cargo-miri runner] Overwriting run-time env var {:?}={:?} with build-time value {:?}", name, old_val, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
cmd.env(name, val);
|
||||
}
|
||||
|
||||
let mut cmd = miri();
|
||||
// Forward rustc arguments.
|
||||
// We need to patch "--extern" filenames because we forced a check-only
|
||||
// build without cargo knowing about that: replace `.rlib` suffix by
|
||||
|
Loading…
x
Reference in New Issue
Block a user