Skip to content

Commit 4904b9c

Browse files
committed
Detect Chocolatey MinGW installation
1 parent b3b252b commit 4904b9c

File tree

1 file changed

+10
-3
lines changed
  • src/librustc_codegen_ssa/back

1 file changed

+10
-3
lines changed

src/librustc_codegen_ssa/back/link.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1002,15 +1002,22 @@ fn get_crt_libs_path(sess: &Session) -> Option<PathBuf> {
10021002
x if x == "x86" => "i686",
10031003
x => x,
10041004
};
1005+
let mingw_bits = &sess.target.target.target_pointer_width;
10051006
let mingw_dir = format!("{}-w64-mingw32", mingw_arch);
10061007
// Here we have path/bin/gcc but we need path/
10071008
let mut path = linker_path;
10081009
path.pop();
10091010
path.pop();
1010-
// Based on Clang MinGW driver
1011-
let probe_paths = vec!["lib", "sys-root/mingw/lib"];
1011+
// Loosely based on Clang MinGW driver
1012+
let probe_paths = vec![
1013+
path.join(&mingw_dir).join("lib"), // Typical path
1014+
path.join(&mingw_dir).join("sys-root/mingw/lib"), // Rare path
1015+
path.join(format!(
1016+
"lib/mingw/tools/install/mingw{}/{}/lib",
1017+
&mingw_bits, &mingw_dir
1018+
)), // Chocolatey is creative
1019+
];
10121020
for probe_path in probe_paths {
1013-
let probe_path = path.join(&mingw_dir).join(&probe_path);
10141021
if probe_path.join("crt2.o").exists() {
10151022
return Some(probe_path);
10161023
};

0 commit comments

Comments
 (0)