Skip to content

Commit

Permalink
Detect Chocolatey MinGW installation
Browse files Browse the repository at this point in the history
  • Loading branch information
mati865 committed Feb 21, 2020
1 parent b3b252b commit 4904b9c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,15 +1002,22 @@ 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_paths = vec!["lib", "sys-root/mingw/lib"];
// 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 {
let probe_path = path.join(&mingw_dir).join(&probe_path);
if probe_path.join("crt2.o").exists() {
return Some(probe_path);
};
Expand Down

0 comments on commit 4904b9c

Please sign in to comment.