about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-01-18 01:57:30 +0800
committerGitHub <noreply@github.com>2018-01-18 01:57:30 +0800
commit54299e2eb7463231f22731cbb8a4dbbdc7669bd8 (patch)
treeae410ae396c7a8aaf220be5d0f37194f90fe84c7 /src
parentfb1f01dc0557c621d5fda7046a2a218b15b24dfe (diff)
parent6defae31f6bf548f75974c555b4cceaef4b8ef15 (diff)
Rollup merge of #47505 - alexcrichton:fix-bat-spawn-regression, r=estebank
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).
Diffstat (limited to 'src')
-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 {