Skip to content

Commit 5f9a0d3

Browse files
committed
linker: Bail out of rpath logic early if the target doesn't support rpath
1 parent af31c33 commit 5f9a0d3

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,10 @@ fn add_rpath_args(
20962096
codegen_results: &CodegenResults,
20972097
out_filename: &Path,
20982098
) {
2099+
if !sess.target.has_rpath {
2100+
return;
2101+
}
2102+
20992103
// FIXME (#2397): At some point we want to rpath our guesses as to
21002104
// where extern libraries might live, based on the
21012105
// add_lib_search_paths
@@ -2114,7 +2118,6 @@ fn add_rpath_args(
21142118
let rpath_config = RPathConfig {
21152119
libs: &*libs,
21162120
out_filename: out_filename.to_path_buf(),
2117-
has_rpath: sess.target.has_rpath,
21182121
is_like_osx: sess.target.is_like_osx,
21192122
linker_is_gnu: sess.target.linker_flavor.is_gnu(),
21202123
};

compiler/rustc_codegen_ssa/src/back/rpath.rs

-6
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@ pub struct RPathConfig<'a> {
99
pub libs: &'a [&'a Path],
1010
pub out_filename: PathBuf,
1111
pub is_like_osx: bool,
12-
pub has_rpath: bool,
1312
pub linker_is_gnu: bool,
1413
}
1514

1615
pub fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
17-
// No rpath on windows
18-
if !config.has_rpath {
19-
return Vec::new();
20-
}
21-
2216
debug!("preparing the RPATH!");
2317

2418
let rpaths = get_rpaths(config);

compiler/rustc_codegen_ssa/src/back/rpath/tests.rs

-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ fn test_rpath_relative() {
3737
if cfg!(target_os = "macos") {
3838
let config = &mut RPathConfig {
3939
libs: &[],
40-
has_rpath: true,
4140
is_like_osx: true,
4241
linker_is_gnu: false,
4342
out_filename: PathBuf::from("bin/rustc"),
@@ -48,7 +47,6 @@ fn test_rpath_relative() {
4847
let config = &mut RPathConfig {
4948
libs: &[],
5049
out_filename: PathBuf::from("bin/rustc"),
51-
has_rpath: true,
5250
is_like_osx: false,
5351
linker_is_gnu: true,
5452
};
@@ -62,7 +60,6 @@ fn test_rpath_relative_issue_119571() {
6260
let config = &mut RPathConfig {
6361
libs: &[],
6462
out_filename: PathBuf::from("rustc"),
65-
has_rpath: true,
6663
is_like_osx: false,
6764
linker_is_gnu: true,
6865
};

0 commit comments

Comments
 (0)