diff options
| author | bors <bors@rust-lang.org> | 2020-02-23 12:52:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-23 12:52:48 +0000 |
| commit | 87b0d83745c0cc5b3679e406fbdbf0e8a8bfd3c6 (patch) | |
| tree | dc9a33c0ca3fc29cde9fdbd382674069dc81c5ee | |
| parent | 9c230f39c159cf7645bc4dbab511b9586d033021 (diff) | |
| parent | 4904b9c228317a9cba963afb87425754a586acf2 (diff) | |
| download | rust-87b0d83745c0cc5b3679e406fbdbf0e8a8bfd3c6.tar.gz rust-87b0d83745c0cc5b3679e406fbdbf0e8a8bfd3c6.zip | |
Auto merge of #69351 - mati865:mingw-ultimate-fix, r=cramertj
Improve external MinGW detection Fixes #68872
| -rw-r--r-- | src/librustc_codegen_ssa/back/link.rs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index aaa4448fc19..78aacc56ea4 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -1002,20 +1002,26 @@ fn get_crt_libs_path(sess: &Session) -> Option<PathBuf> { x if x == "x86" => "i686", x => x, }; + let mingw_bits = &sess.target.target.target_pointer_width; let mingw_dir = format!("{}-w64-mingw32", mingw_arch); // Here we have path/bin/gcc but we need path/ let mut path = linker_path; path.pop(); path.pop(); - // Based on Clang MinGW driver - let probe_path = path.join(&mingw_dir).join("lib"); - if probe_path.exists() { - return Some(probe_path); - }; - let probe_path = path.join(&mingw_dir).join("sys-root/mingw/lib"); - if probe_path.exists() { - return Some(probe_path); - }; + // Loosely based on Clang MinGW driver + let probe_paths = vec![ + path.join(&mingw_dir).join("lib"), // Typical path + path.join(&mingw_dir).join("sys-root/mingw/lib"), // Rare path + path.join(format!( + "lib/mingw/tools/install/mingw{}/{}/lib", + &mingw_bits, &mingw_dir + )), // Chocolatey is creative + ]; + for probe_path in probe_paths { + if probe_path.join("crt2.o").exists() { + return Some(probe_path); + }; + } }; }; None |
