]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Spawn `cmd /c` for `.bat` scripts
authorAlex Crichton <alex@alexcrichton.com>
Tue, 16 Jan 2018 23:49:58 +0000 (15:49 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 16 Jan 2018 23:52:24 +0000 (15:52 -0800)
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).

src/librustc_trans/back/link.rs

index 13a319d31bf0663832e7a31140062168b409ede6..f53c5b3f58131399d78887013b99e26512674926 100644 (file)
@@ -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 {