about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back/command.rs
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2025-02-10 07:49:43 +0200
committerLaurențiu Nicola <lnicola@dend.ro>2025-02-10 07:49:43 +0200
commit15cd1f011c4f854f7a7cfbe2e727cc4b02b1d254 (patch)
treebdd9d79bd54ffe237db9c987d6c1e2ab12349e16 /compiler/rustc_codegen_ssa/src/back/command.rs
parent879dc387cde7ac4b85aa5a185158c9c3c488c5e7 (diff)
parentd9a4a47b8b3dc0bdff83360cea2013200d60d49c (diff)
downloadrust-15cd1f011c4f854f7a7cfbe2e727cc4b02b1d254.tar.gz
rust-15cd1f011c4f854f7a7cfbe2e727cc4b02b1d254.zip
Merge from rust-lang/rust
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back/command.rs')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/command.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/command.rs b/compiler/rustc_codegen_ssa/src/back/command.rs
index b3c5b86ccf4..63023fdba20 100644
--- a/compiler/rustc_codegen_ssa/src/back/command.rs
+++ b/compiler/rustc_codegen_ssa/src/back/command.rs
@@ -13,6 +13,7 @@ pub(crate) struct Command {
     args: Vec<OsString>,
     env: Vec<(OsString, OsString)>,
     env_remove: Vec<OsString>,
+    env_clear: bool,
 }
 
 #[derive(Clone)]
@@ -36,7 +37,13 @@ impl Command {
     }
 
     fn _new(program: Program) -> Command {
-        Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
+        Command {
+            program,
+            args: Vec::new(),
+            env: Vec::new(),
+            env_remove: Vec::new(),
+            env_clear: false,
+        }
     }
 
     pub(crate) fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
@@ -79,6 +86,11 @@ impl Command {
         self
     }
 
+    pub(crate) fn env_clear(&mut self) -> &mut Command {
+        self.env_clear = true;
+        self
+    }
+
     fn _env_remove(&mut self, key: &OsStr) {
         self.env_remove.push(key.to_owned());
     }
@@ -106,6 +118,9 @@ impl Command {
         for k in &self.env_remove {
             ret.env_remove(k);
         }
+        if self.env_clear {
+            ret.env_clear();
+        }
         ret
     }