Skip to content

Commit 54299e2

Browse files
authored
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).
2 parents fb1f01d + 6defae3 commit 54299e2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/librustc_trans/back/link.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ pub fn get_linker(sess: &Session) -> (PathBuf, Command, Vec<(OsString, OsString)
6969
// was tagged as #42791) and some more info can be found on #44443 for
7070
// emscripten itself.
7171
let cmd = |linker: &Path| {
72-
if cfg!(windows) && linker.ends_with(".bat") {
73-
let mut cmd = Command::new("cmd");
74-
cmd.arg("/c").arg(linker);
75-
cmd
76-
} else {
77-
Command::new(linker)
72+
if let Some(linker) = linker.to_str() {
73+
if cfg!(windows) && linker.ends_with(".bat") {
74+
let mut cmd = Command::new("cmd");
75+
cmd.arg("/c").arg(linker);
76+
return cmd
77+
}
7878
}
79+
Command::new(linker)
7980
};
8081

8182
if let Some(ref linker) = sess.opts.cg.linker {

0 commit comments

Comments
 (0)