linker: Avoid calling linker_and_flavor
twice
This commit is contained in:
parent
43653c1835
commit
27e95f95e6
1 changed files with 9 additions and 6 deletions
|
@ -670,7 +670,7 @@ fn link_natively(
|
|||
) {
|
||||
info!("preparing {:?} to {:?}", crate_type, out_filename);
|
||||
let (linker_path, flavor) = linker_and_flavor(sess);
|
||||
let self_contained_components = self_contained_components(sess, crate_type);
|
||||
let self_contained_components = self_contained_components(sess, crate_type, &linker_path);
|
||||
|
||||
// On AIX, we ship all libraries as .a big_af archive
|
||||
// the expected format is lib<name>.a(libname.so) for the actual
|
||||
|
@ -1788,8 +1788,7 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
|
|||
}
|
||||
|
||||
// Returns true if linker is located within sysroot
|
||||
fn detect_self_contained_mingw(sess: &Session) -> bool {
|
||||
let (linker, _) = linker_and_flavor(sess);
|
||||
fn detect_self_contained_mingw(sess: &Session, linker: &Path) -> bool {
|
||||
// Assume `-C linker=rust-lld` as self-contained mode
|
||||
if linker == Path::new("rust-lld") {
|
||||
return true;
|
||||
|
@ -1797,7 +1796,7 @@ fn detect_self_contained_mingw(sess: &Session) -> bool {
|
|||
let linker_with_extension = if cfg!(windows) && linker.extension().is_none() {
|
||||
linker.with_extension("exe")
|
||||
} else {
|
||||
linker
|
||||
linker.to_path_buf()
|
||||
};
|
||||
for dir in env::split_paths(&env::var_os("PATH").unwrap_or_default()) {
|
||||
let full_path = dir.join(&linker_with_extension);
|
||||
|
@ -1812,7 +1811,11 @@ fn detect_self_contained_mingw(sess: &Session) -> bool {
|
|||
/// Various toolchain components used during linking are used from rustc distribution
|
||||
/// instead of being found somewhere on the host system.
|
||||
/// We only provide such support for a very limited number of targets.
|
||||
fn self_contained_components(sess: &Session, crate_type: CrateType) -> LinkSelfContainedComponents {
|
||||
fn self_contained_components(
|
||||
sess: &Session,
|
||||
crate_type: CrateType,
|
||||
linker: &Path,
|
||||
) -> LinkSelfContainedComponents {
|
||||
// Turn the backwards compatible bool values for `self_contained` into fully inferred
|
||||
// `LinkSelfContainedComponents`.
|
||||
let self_contained =
|
||||
|
@ -1841,7 +1844,7 @@ fn self_contained_components(sess: &Session, crate_type: CrateType) -> LinkSelfC
|
|||
LinkSelfContainedDefault::InferredForMingw => {
|
||||
sess.host == sess.target
|
||||
&& sess.target.vendor != "uwp"
|
||||
&& detect_self_contained_mingw(sess)
|
||||
&& detect_self_contained_mingw(sess, linker)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue