]> git.lizzy.rs Git - rust.git/commitdiff
fix: use detected MSVC's link.exe
authorJorge Aparicio <jorge@japaric.io>
Sun, 19 Aug 2018 10:35:58 +0000 (12:35 +0200)
committerJorge Aparicio <jorge@japaric.io>
Sun, 19 Aug 2018 10:35:58 +0000 (12:35 +0200)
src/librustc_codegen_llvm/back/link.rs

index 227ae22e6935991e38caca52cf8873e7c5d382ff..afbcaf4c659d771ca25eb5a7f757d5a89e4a7724 100644 (file)
@@ -61,6 +61,8 @@
 // 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)