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-16 15:52:24 -0800
commit6defae31f6bf548f75974c555b4cceaef4b8ef15 (patch)
treed3c252c91edb0f2babde5d942b1e0b6273865a93
parent3f92e8d89861f0f5408ad9381a7467ec6e7d76bc (diff)
downloadrust-6defae31f6bf548f75974c555b4cceaef4b8ef15.tar.gz
rust-6defae31f6bf548f75974c555b4cceaef4b8ef15.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 13a319d31bf..f53c5b3f581 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 {