Skip to content

Commit fa38fad

Browse files
authored
Rollup merge of #86025 - bjorn3:no_rpath_cfg_prefix, r=jackh726
Remove the install prefix from the rpath set when using -Crpath It was broken anyway for rustup installs and nobody seems to have noticed. Fixes #82392
2 parents 4144019 + 6b45d59 commit fa38fad

File tree

4 files changed

+6
-38
lines changed

4 files changed

+6
-38
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -1715,24 +1715,14 @@ fn add_rpath_args(
17151715
) {
17161716
// FIXME (#2397): At some point we want to rpath our guesses as to
17171717
// where extern libraries might live, based on the
1718-
// addl_lib_search_paths
1718+
// add_lib_search_paths
17191719
if sess.opts.cg.rpath {
1720-
let target_triple = sess.opts.target_triple.triple();
1721-
let mut get_install_prefix_lib_path = || {
1722-
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
1723-
let tlib = rustc_target::target_rustlib_path(&sess.sysroot, target_triple).join("lib");
1724-
let mut path = PathBuf::from(install_prefix);
1725-
path.push(&tlib);
1726-
1727-
path
1728-
};
17291720
let mut rpath_config = RPathConfig {
17301721
used_crates: &codegen_results.crate_info.used_crates_dynamic,
17311722
out_filename: out_filename.to_path_buf(),
17321723
has_rpath: sess.target.has_rpath,
17331724
is_like_osx: sess.target.is_like_osx,
17341725
linker_is_gnu: sess.target.linker_is_gnu,
1735-
get_install_prefix_lib_path: &mut get_install_prefix_lib_path,
17361726
};
17371727
cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
17381728
}

compiler/rustc_codegen_ssa/src/back/rpath.rs

+4-23
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub struct RPathConfig<'a> {
1313
pub is_like_osx: bool,
1414
pub has_rpath: bool,
1515
pub linker_is_gnu: bool,
16-
pub get_install_prefix_lib_path: &'a mut dyn FnMut() -> PathBuf,
1716
}
1817

1918
pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
@@ -63,24 +62,13 @@ fn get_rpaths(config: &mut RPathConfig<'_>, libs: &[PathBuf]) -> Vec<String> {
6362
// Use relative paths to the libraries. Binaries can be moved
6463
// as long as they maintain the relative relationship to the
6564
// crates they depend on.
66-
let rel_rpaths = get_rpaths_relative_to_output(config, libs);
65+
let rpaths = get_rpaths_relative_to_output(config, libs);
6766

68-
// And a final backup rpath to the global library location.
69-
let fallback_rpaths = vec![get_install_prefix_rpath(config)];
70-
71-
fn log_rpaths(desc: &str, rpaths: &[String]) {
72-
debug!("{} rpaths:", desc);
73-
for rpath in rpaths {
74-
debug!(" {}", *rpath);
75-
}
67+
debug!("rpaths:");
68+
for rpath in &rpaths {
69+
debug!(" {}", rpath);
7670
}
7771

78-
log_rpaths("relative", &rel_rpaths);
79-
log_rpaths("fallback", &fallback_rpaths);
80-
81-
let mut rpaths = rel_rpaths;
82-
rpaths.extend_from_slice(&fallback_rpaths);
83-
8472
// Remove duplicates
8573
minimize_rpaths(&rpaths)
8674
}
@@ -113,13 +101,6 @@ fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf> {
113101
diff_paths(path, base)
114102
}
115103

116-
fn get_install_prefix_rpath(config: &mut RPathConfig<'_>) -> String {
117-
let path = (config.get_install_prefix_lib_path)();
118-
let path = env::current_dir().unwrap().join(&path);
119-
// FIXME (#9639): This needs to handle non-utf8 paths
120-
path.to_str().expect("non-utf8 component in rpath").to_owned()
121-
}
122-
123104
fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
124105
let mut set = FxHashSet::default();
125106
let mut minimized = Vec::new();

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

-2
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@ fn test_rpath_relative() {
4040
is_like_osx: true,
4141
linker_is_gnu: false,
4242
out_filename: PathBuf::from("bin/rustc"),
43-
get_install_prefix_lib_path: &mut || panic!(),
4443
};
4544
let res = get_rpath_relative_to_output(config, Path::new("lib/libstd.so"));
4645
assert_eq!(res, "@loader_path/../lib");
4746
} else {
4847
let config = &mut RPathConfig {
4948
used_crates: &[],
5049
out_filename: PathBuf::from("bin/rustc"),
51-
get_install_prefix_lib_path: &mut || panic!(),
5250
has_rpath: true,
5351
is_like_osx: false,
5452
linker_is_gnu: true,

src/bootstrap/compile.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
636636
cargo
637637
.env("CFG_RELEASE", builder.rust_release())
638638
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
639-
.env("CFG_VERSION", builder.rust_version())
640-
.env("CFG_PREFIX", builder.config.prefix.clone().unwrap_or_default());
639+
.env("CFG_VERSION", builder.rust_version());
641640

642641
let libdir_relative = builder.config.libdir_relative().unwrap_or_else(|| Path::new("lib"));
643642
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);

0 commit comments

Comments
 (0)