linker: Bail out of rpath logic early if the target doesn't support r… · rust-lang/rust@5f9a0d3 (original) (raw)

File tree

3 files changed

lines changed

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -2096,6 +2096,10 @@ fn add_rpath_args(
2096 2096 codegen_results: &CodegenResults,
2097 2097 out_filename: &Path,
2098 2098 ) {
2099 +if !sess.target.has_rpath {
2100 +return;
2101 +}
2102 +
2099 2103 // FIXME (#2397): At some point we want to rpath our guesses as to
2100 2104 // where extern libraries might live, based on the
2101 2105 // add_lib_search_paths
@@ -2114,7 +2118,6 @@ fn add_rpath_args(
2114 2118 let rpath_config = RPathConfig {
2115 2119 libs: &*libs,
2116 2120 out_filename: out_filename.to_path_buf(),
2117 -has_rpath: sess.target.has_rpath,
2118 2121 is_like_osx: sess.target.is_like_osx,
2119 2122 linker_is_gnu: sess.target.linker_flavor.is_gnu(),
2120 2123 };
Original file line number Diff line number Diff line change
@@ -9,16 +9,10 @@ pub struct RPathConfig<'a> {
9 9 pub libs: &'a [&'a Path],
10 10 pub out_filename: PathBuf,
11 11 pub is_like_osx: bool,
12 -pub has_rpath: bool,
13 12 pub linker_is_gnu: bool,
14 13 }
15 14
16 15 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 -
22 16 debug!("preparing the RPATH!");
23 17
24 18 let rpaths = get_rpaths(config);
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ fn test_rpath_relative() {
37 37 if cfg!(target_os = "macos") {
38 38 let config = &mut RPathConfig {
39 39 libs: &[],
40 -has_rpath: true,
41 40 is_like_osx: true,
42 41 linker_is_gnu: false,
43 42 out_filename: PathBuf::from("bin/rustc"),
@@ -48,7 +47,6 @@ fn test_rpath_relative() {
48 47 let config = &mut RPathConfig {
49 48 libs: &[],
50 49 out_filename: PathBuf::from("bin/rustc"),
51 -has_rpath: true,
52 50 is_like_osx: false,
53 51 linker_is_gnu: true,
54 52 };
@@ -62,7 +60,6 @@ fn test_rpath_relative_issue_119571() {
62 60 let config = &mut RPathConfig {
63 61 libs: &[],
64 62 out_filename: PathBuf::from("rustc"),
65 -has_rpath: true,
66 63 is_like_osx: false,
67 64 linker_is_gnu: true,
68 65 };