]> git.lizzy.rs Git - rust.git/commitdiff
remove Windows TERM env var hack and -Zmiri-env-exclude
authorRalf Jung <post@ralfj.de>
Tue, 20 Sep 2022 06:42:45 +0000 (08:42 +0200)
committerRalf Jung <post@ralfj.de>
Tue, 20 Sep 2022 06:51:13 +0000 (08:51 +0200)
README.md
src/bin/miri.rs
src/eval.rs
src/shims/env.rs
tests/pass/shims/env/var-exclude.rs [deleted file]

index eedc6c7c3c33071cf6da56f66459c9deb09ebd2d..72081f45499b86d674c9473e6823d6513a7bfa41 100644 (file)
--- a/README.md
+++ b/README.md
@@ -288,14 +288,9 @@ environment variable. We first document the most relevant and most commonly used
   execution with a "permission denied" error being returned to the program.
   `warn` prints a full backtrace when that happens; `warn-nobacktrace` is less
   verbose. `hide` hides the warning entirely.
-* `-Zmiri-env-exclude=<var>` keeps the `var` environment variable isolated from the host so that it
-  cannot be accessed by the program. Can be used multiple times to exclude several variables. The
-  `TERM` environment variable is excluded by default in Windows to prevent the libtest harness from
-  accessing the file system. This has no effect unless `-Zmiri-disable-isolation` is also set.
 * `-Zmiri-env-forward=<var>` forwards the `var` environment variable to the interpreted program. Can
-  be used multiple times to forward several variables. This takes precedence over
-  `-Zmiri-env-exclude`: if a variable is both forwarded and exluced, it *will* get forwarded. This
-  means in particular `-Zmiri-env-forward=TERM` overwrites the default exclusion of `TERM`.
+  be used multiple times to forward several variables. Execution will still be deterministic if the
+  value of forwarded variables stays the same. Has no effect if `-Zmiri-disable-isolation` is set.
 * `-Zmiri-ignore-leaks` disables the memory leak checker, and also allows some
   remaining threads to exist when the main thread exits.
 * `-Zmiri-permissive-provenance` disables the warning for integer-to-pointer casts and
index d9e91951a92291fe67f8ff7b6a6f98b534410084..644a8129eee7f659f56bccff685d19d9ecb2ac39 100644 (file)
@@ -441,8 +441,10 @@ fn main() {
                             "-Zmiri-seed should only contain valid hex digits [0-9a-fA-F] and must fit into a u64 (max 16 characters)"
                         ));
             miri_config.seed = Some(seed);
-        } else if let Some(param) = arg.strip_prefix("-Zmiri-env-exclude=") {
-            miri_config.excluded_env_vars.push(param.to_owned());
+        } else if let Some(_param) = arg.strip_prefix("-Zmiri-env-exclude=") {
+            show_error!(
+                "`-Zmiri-env-exclude` has been removed; unset env vars before starting Miri instead"
+            );
         } else if let Some(param) = arg.strip_prefix("-Zmiri-env-forward=") {
             miri_config.forwarded_env_vars.push(param.to_owned());
         } else if let Some(param) = arg.strip_prefix("-Zmiri-track-pointer-tag=") {
index 1be2a8990a68b55123ed80677f92569e2a49ea2c..819d71dc69fb9bfb71e3e4da56de1beae433f484 100644 (file)
@@ -74,7 +74,7 @@ pub enum BacktraceStyle {
 #[derive(Clone)]
 pub struct MiriConfig {
     /// The host environment snapshot to use as basis for what is provided to the interpreted program.
-    /// (This is still subject to isolation as well as `excluded_env_vars` and `forwarded_env_vars`.)
+    /// (This is still subject to isolation as well as `forwarded_env_vars`.)
     pub env: Vec<(OsString, OsString)>,
     /// Determine if validity checking is enabled.
     pub validate: bool,
@@ -88,8 +88,6 @@ pub struct MiriConfig {
     pub isolated_op: IsolatedOp,
     /// Determines if memory leaks should be ignored.
     pub ignore_leaks: bool,
-    /// Environment variables that should always be isolated from the host.
-    pub excluded_env_vars: Vec<String>,
     /// Environment variables that should always be forwarded from the host.
     pub forwarded_env_vars: Vec<String>,
     /// Command-line arguments passed to the interpreted program.
@@ -146,7 +144,6 @@ fn default() -> MiriConfig {
             check_abi: true,
             isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
             ignore_leaks: false,
-            excluded_env_vars: vec![],
             forwarded_env_vars: vec![],
             args: vec![],
             seed: None,
index 084433fab74cac2b5529bee0bb835ce6ba515535..5b2d645c174a89769e46a65b43a635a397b60591 100644 (file)
@@ -42,19 +42,12 @@ pub(crate) fn init<'mir>(
         config: &MiriConfig,
     ) -> InterpResult<'tcx> {
         let target_os = ecx.tcx.sess.target.os.as_ref();
-        let mut excluded_env_vars = config.excluded_env_vars.clone();
-        if target_os == "windows" {
-            // HACK: Exclude `TERM` var to avoid terminfo trying to open the termcap file.
-            excluded_env_vars.push("TERM".to_owned());
-        }
 
         // Skip the loop entirely if we don't want to forward anything.
         if ecx.machine.communicate() || !config.forwarded_env_vars.is_empty() {
             for (name, value) in &config.env {
-                // Always forward what is in `forwarded_env_vars`; that list can take precedence over excluded_env_vars.
-                let forward = config.forwarded_env_vars.iter().any(|v| **v == *name)
-                    || (ecx.machine.communicate()
-                        && !excluded_env_vars.iter().any(|v| **v == *name));
+                let forward = ecx.machine.communicate()
+                    || config.forwarded_env_vars.iter().any(|v| **v == *name);
                 if forward {
                     let var_ptr = match target_os {
                         target if target_os_is_unix(target) =>
diff --git a/tests/pass/shims/env/var-exclude.rs b/tests/pass/shims/env/var-exclude.rs
deleted file mode 100644 (file)
index 14ad827..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-//@compile-flags: -Zmiri-disable-isolation -Zmiri-env-exclude=MIRI_ENV_VAR_TEST
-
-fn main() {
-    assert!(std::env::var("MIRI_ENV_VAR_TEST").is_err());
-}