Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc: Spawn cmd /c emcc.bat explicitly #44542

Merged
merged 1 commit into from
Sep 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,32 @@ pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMet
pub fn get_linker(sess: &Session) -> (String, Command, Vec<(OsString, OsString)>) {
let envs = vec![("PATH".into(), command_path(sess))];

// If our linker looks like a batch script on Windows then to execute this
// we'll need to spawn `cmd` explicitly. This is primarily done to handle
// emscripten where the linker is `emcc.bat` and needs to be spawned as
// `cmd /c emcc.bat ...`.
//
// This worked historically but is needed manually since #42436 (regression
// was tagged as #42791) and some more info can be found on #44443 for
// emscripten itself.
let cmd = |linker: &str| {
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(ref linker) = sess.opts.cg.linker {
(linker.clone(), Command::new(linker), envs)
(linker.clone(), cmd(linker), envs)
} else if sess.target.target.options.is_like_msvc {
let (cmd, envs) = msvc_link_exe_cmd(sess);
("link.exe".to_string(), cmd, envs)
} else {
let linker = &sess.target.target.options.linker;
(linker.clone(), Command::new(&linker), envs)
(linker.clone(), cmd(linker), envs)
}
}

Expand Down