Improve linker-flavor detection · rust-lang/rust@3bc2970 (original) (raw)

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -1231,12 +1231,21 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
1231 1231 sess.emit_fatal(errors::LinkerFileStem);
1232 1232 });
1233 1233
1234 +// Remove any version postfix.
1235 +let stem = stem
1236 +.rsplit_once('-')
1237 +.and_then(|(lhs, rhs)
1238 +.unwrap_or(stem);
1239 +
1240 +// GCC can have an optional target prefix.
1234 1241 let flavor = if stem == "emcc" {
1235 1242 LinkerFlavor::EmCc
1236 1243 } else if stem == "gcc"
1237 1244 |
1245 + |
1246 + |
1238 1247 |
1239 - |
1248 + |
1240 1249 {
1241 1250 LinkerFlavor::from_cli(LinkerFlavorCli::Gcc, &sess.target)
1242 1251 } else if stem == "wasm-ld" |