Skip to content

Commit 9f92112

Browse files
committed
address review feedback
1 parent f6fbe04 commit 9f92112

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

compiler/rustc_codegen_cranelift/src/toolchain.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ use std::path::PathBuf;
44

55
use rustc_codegen_ssa::back::link::linker_and_flavor;
66
use rustc_session::Session;
7+
use rustc_target::spec::LinkSelfContainedComponents;
78

89
/// Tries to infer the path of a binary for the target toolchain from the linker name.
910
pub(crate) fn get_toolchain_binary(sess: &Session, tool: &str) -> PathBuf {
10-
let (mut linker, _linker_flavor) = linker_and_flavor(sess, false);
11+
let (mut linker, _linker_flavor) =
12+
linker_and_flavor(sess, &LinkSelfContainedComponents::empty());
1113
let linker_file_name =
1214
linker.file_name().unwrap().to_str().expect("linker filename should be valid UTF-8");
1315

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,7 @@ fn link_natively(
686686
) {
687687
info!("preparing {:?} to {:?}", crate_type, out_filename);
688688
let self_contained_components = self_contained_components(sess, crate_type);
689-
let (linker_path, flavor) =
690-
linker_and_flavor(sess, self_contained_components.is_linker_enabled());
689+
let (linker_path, flavor) = linker_and_flavor(sess, &self_contained_components);
691690

692691
// On AIX, we ship all libraries as .a big_af archive
693692
// the expected format is lib<name>.a(libname.so) for the actual
@@ -1319,7 +1318,10 @@ pub fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool
13191318
}
13201319

13211320
/// This functions tries to determine the appropriate linker (and corresponding LinkerFlavor) to use
1322-
pub fn linker_and_flavor(sess: &Session, self_contained: bool) -> (PathBuf, LinkerFlavor) {
1321+
pub fn linker_and_flavor(
1322+
sess: &Session,
1323+
self_contained_components: &LinkSelfContainedComponents,
1324+
) -> (PathBuf, LinkerFlavor) {
13231325
fn infer_from(
13241326
sess: &Session,
13251327
linker: Option<PathBuf>,
@@ -1418,11 +1420,11 @@ pub fn linker_and_flavor(sess: &Session, self_contained: bool) -> (PathBuf, Link
14181420
return ret;
14191421
}
14201422

1421-
// When using a supported target in self-contained mode, we want to use rust-lld directly.
1423+
// When using a supported target in self-contained linker mode, we want to use rust-lld directly.
14221424
let self_contained_target = sess.target.os == "windows"
14231425
&& sess.target.env == "gnu"
14241426
&& sess.target.abi == "llvm"
1425-
&& self_contained;
1427+
&& self_contained_components.is_linker_enabled();
14261428
if self_contained_target
14271429
&& let Some(ret) =
14281430
infer_from(sess, None, Some(LinkerFlavor::Gnu(Cc::No, Lld::Yes)), features)

0 commit comments

Comments
 (0)