diff options
| author | Jorge Aparicio <jorge@japaric.io> | 2018-08-19 12:35:58 +0200 |
|---|---|---|
| committer | Jorge Aparicio <jorge@japaric.io> | 2018-08-19 12:35:58 +0200 |
| commit | 98e4cd50f9908dcf2330196baa756a775343e47d (patch) | |
| tree | 34050e178c7ea9cc78c5a0124a2887988106315b /src/librustc_codegen_llvm/back | |
| parent | c8ef8b6602732e5448cfd0d9d05c955aa1815aed (diff) | |
| download | rust-98e4cd50f9908dcf2330196baa756a775343e47d.tar.gz rust-98e4cd50f9908dcf2330196baa756a775343e47d.zip | |
fix: use detected MSVC's link.exe
Diffstat (limited to 'src/librustc_codegen_llvm/back')
| -rw-r--r-- | src/librustc_codegen_llvm/back/link.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index 227ae22e693..afbcaf4c659 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -61,6 +61,8 @@ pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default // path for MSVC to find its DLLs, and gcc to find its bundled // toolchain pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathBuf, Command) { + let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe"); + // 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 @@ -73,12 +75,13 @@ pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathB Some(linker) if cfg!(windows) && linker.ends_with(".bat") => Command::bat_script(linker), _ => match flavor { LinkerFlavor::Lld(f) => Command::lld(linker, f), + LinkerFlavor::Msvc => { + Command::new(msvc_tool.as_ref().map(|t| t.path()).unwrap_or(linker)) + }, _ => Command::new(linker), } }; - let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe"); - // The compiler's sysroot often has some bundled tools, so add it to the // PATH for the child. let mut new_path = sess.host_filesearch(PathKind::All) |
