about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-01-16 15:49:58 -0800
committerAlex Crichton <alex@alexcrichton.com>2018-01-18 12:05:18 -0800
commita32a9e4544314f7cb1b7947ba851fdfc416248f5 (patch)
tree02294bc9bc891986ae30fb7a9d8de0dd5c07c013
parentd7638b65bea1c340d7f5b74f28342eba9a1e12b5 (diff)
downloadrust-a32a9e4544314f7cb1b7947ba851fdfc416248f5.tar.gz
rust-a32a9e4544314f7cb1b7947ba851fdfc416248f5.zip
rustc: Spawn `cmd /c` for `.bat` scripts
This fixes an accidental regression #46335 where the behavior of
`Path::ends_with` is different from `str::ends_with` (paths operate over
components, strs operate over chars).
-rw-r--r--src/librustc_trans/back/link.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
index 42538c5a3ad..896acad6754 100644
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -69,13 +69,14 @@ pub fn get_linker(sess: &Session) -> (PathBuf, Command, Vec<(OsString, OsString)
     // was tagged as #42791) and some more info can be found on #44443 for
     // emscripten itself.
     let cmd = |linker: &Path| {
-        if cfg!(windows) && linker.ends_with(".bat") {
-            let mut cmd = Command::new("cmd");
-            cmd.arg("/c").arg(linker);
-            cmd
-        } else {
-            Command::new(linker)
+        if let Some(linker) = linker.to_str() {
+            if cfg!(windows) && linker.ends_with(".bat") {
+                let mut cmd = Command::new("cmd");
+                cmd.arg("/c").arg(linker);
+                return cmd
+            }
         }
+        Command::new(linker)
     };
 
     if let Some(ref linker) = sess.opts.cg.linker {