Skip to content

Commit bacf131

Browse files
committed
remove Windows TERM env var hack and -Zmiri-env-exclude
1 parent 4b9463c commit bacf131

File tree

5 files changed

+9
-27
lines changed

5 files changed

+9
-27
lines changed

README.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,9 @@ environment variable. We first document the most relevant and most commonly used
288288
execution with a "permission denied" error being returned to the program.
289289
`warn` prints a full backtrace when that happens; `warn-nobacktrace` is less
290290
verbose. `hide` hides the warning entirely.
291-
* `-Zmiri-env-exclude=<var>` keeps the `var` environment variable isolated from the host so that it
292-
cannot be accessed by the program. Can be used multiple times to exclude several variables. The
293-
`TERM` environment variable is excluded by default in Windows to prevent the libtest harness from
294-
accessing the file system. This has no effect unless `-Zmiri-disable-isolation` is also set.
295291
* `-Zmiri-env-forward=<var>` forwards the `var` environment variable to the interpreted program. Can
296-
be used multiple times to forward several variables. This takes precedence over
297-
`-Zmiri-env-exclude`: if a variable is both forwarded and exluced, it *will* get forwarded. This
298-
means in particular `-Zmiri-env-forward=TERM` overwrites the default exclusion of `TERM`.
292+
be used multiple times to forward several variables. Execution will still be deterministic if the
293+
value of forwarded variables stays the same. Has no effect if `-Zmiri-disable-isolation` is set.
299294
* `-Zmiri-ignore-leaks` disables the memory leak checker, and also allows some
300295
remaining threads to exist when the main thread exits.
301296
* `-Zmiri-permissive-provenance` disables the warning for integer-to-pointer casts and

src/bin/miri.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,10 @@ fn main() {
441441
"-Zmiri-seed should only contain valid hex digits [0-9a-fA-F] and must fit into a u64 (max 16 characters)"
442442
));
443443
miri_config.seed = Some(seed);
444-
} else if let Some(param) = arg.strip_prefix("-Zmiri-env-exclude=") {
445-
miri_config.excluded_env_vars.push(param.to_owned());
444+
} else if let Some(_param) = arg.strip_prefix("-Zmiri-env-exclude=") {
445+
show_error!(
446+
"`-Zmiri-env-exclude` has been removed; unset env vars before starting Miri instead"
447+
);
446448
} else if let Some(param) = arg.strip_prefix("-Zmiri-env-forward=") {
447449
miri_config.forwarded_env_vars.push(param.to_owned());
448450
} else if let Some(param) = arg.strip_prefix("-Zmiri-track-pointer-tag=") {

src/eval.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub enum BacktraceStyle {
7474
#[derive(Clone)]
7575
pub struct MiriConfig {
7676
/// The host environment snapshot to use as basis for what is provided to the interpreted program.
77-
/// (This is still subject to isolation as well as `excluded_env_vars` and `forwarded_env_vars`.)
77+
/// (This is still subject to isolation as well as `forwarded_env_vars`.)
7878
pub env: Vec<(OsString, OsString)>,
7979
/// Determine if validity checking is enabled.
8080
pub validate: bool,
@@ -88,8 +88,6 @@ pub struct MiriConfig {
8888
pub isolated_op: IsolatedOp,
8989
/// Determines if memory leaks should be ignored.
9090
pub ignore_leaks: bool,
91-
/// Environment variables that should always be isolated from the host.
92-
pub excluded_env_vars: Vec<String>,
9391
/// Environment variables that should always be forwarded from the host.
9492
pub forwarded_env_vars: Vec<String>,
9593
/// Command-line arguments passed to the interpreted program.
@@ -146,7 +144,6 @@ impl Default for MiriConfig {
146144
check_abi: true,
147145
isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
148146
ignore_leaks: false,
149-
excluded_env_vars: vec![],
150147
forwarded_env_vars: vec![],
151148
args: vec![],
152149
seed: None,

src/shims/env.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,12 @@ impl<'tcx> EnvVars<'tcx> {
4242
config: &MiriConfig,
4343
) -> InterpResult<'tcx> {
4444
let target_os = ecx.tcx.sess.target.os.as_ref();
45-
let mut excluded_env_vars = config.excluded_env_vars.clone();
46-
if target_os == "windows" {
47-
// HACK: Exclude `TERM` var to avoid terminfo trying to open the termcap file.
48-
excluded_env_vars.push("TERM".to_owned());
49-
}
5045

5146
// Skip the loop entirely if we don't want to forward anything.
5247
if ecx.machine.communicate() || !config.forwarded_env_vars.is_empty() {
5348
for (name, value) in &config.env {
54-
// Always forward what is in `forwarded_env_vars`; that list can take precedence over excluded_env_vars.
55-
let forward = config.forwarded_env_vars.iter().any(|v| **v == *name)
56-
|| (ecx.machine.communicate()
57-
&& !excluded_env_vars.iter().any(|v| **v == *name));
49+
let forward = ecx.machine.communicate()
50+
|| config.forwarded_env_vars.iter().any(|v| **v == *name);
5851
if forward {
5952
let var_ptr = match target_os {
6053
target if target_os_is_unix(target) =>

tests/pass/shims/env/var-exclude.rs

-5
This file was deleted.

0 commit comments

Comments
 (0)