Skip to content

Commit

Permalink
Remove get_install_prefix_lib_path completely
Browse files Browse the repository at this point in the history
It was broken anyway for rustup installs and nobody seems to have noticed.
  • Loading branch information
bjorn3 committed Jun 5, 2021
1 parent a3205a6 commit 6b45d59
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
9 changes: 0 additions & 9 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,21 +1569,12 @@ fn add_rpath_args(
// where extern libraries might live, based on the
// add_lib_search_paths
if sess.opts.cg.rpath {
let target_triple = sess.opts.target_triple.triple();
let mut get_install_prefix_lib_path = || {
let tlib = rustc_target::target_rustlib_path(&sess.sysroot, target_triple).join("lib");
let mut path = PathBuf::from(&sess.sysroot);
path.push(&tlib);

path
};
let mut rpath_config = RPathConfig {
used_crates: &codegen_results.crate_info.used_crates_dynamic,
out_filename: out_filename.to_path_buf(),
has_rpath: sess.target.has_rpath,
is_like_osx: sess.target.is_like_osx,
linker_is_gnu: sess.target.linker_is_gnu,
get_install_prefix_lib_path: &mut get_install_prefix_lib_path,
};
cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
}
Expand Down
27 changes: 4 additions & 23 deletions compiler/rustc_codegen_ssa/src/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub struct RPathConfig<'a> {
pub is_like_osx: bool,
pub has_rpath: bool,
pub linker_is_gnu: bool,
pub get_install_prefix_lib_path: &'a mut dyn FnMut() -> PathBuf,
}

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

// And a final backup rpath to the global library location.
let fallback_rpaths = vec![get_install_prefix_rpath(config)];

fn log_rpaths(desc: &str, rpaths: &[String]) {
debug!("{} rpaths:", desc);
for rpath in rpaths {
debug!(" {}", *rpath);
}
debug!("rpaths:");
for rpath in &rpaths {
debug!(" {}", rpath);
}

log_rpaths("relative", &rel_rpaths);
log_rpaths("fallback", &fallback_rpaths);

let mut rpaths = rel_rpaths;
rpaths.extend_from_slice(&fallback_rpaths);

// Remove duplicates
minimize_rpaths(&rpaths)
}
Expand Down Expand Up @@ -113,13 +101,6 @@ fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf> {
diff_paths(path, base)
}

fn get_install_prefix_rpath(config: &mut RPathConfig<'_>) -> String {
let path = (config.get_install_prefix_lib_path)();
let path = env::current_dir().unwrap().join(&path);
// FIXME (#9639): This needs to handle non-utf8 paths
path.to_str().expect("non-utf8 component in rpath").to_owned()
}

fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
let mut set = FxHashSet::default();
let mut minimized = Vec::new();
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/rpath/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ fn test_rpath_relative() {
is_like_osx: true,
linker_is_gnu: false,
out_filename: PathBuf::from("bin/rustc"),
get_install_prefix_lib_path: &mut || panic!(),
};
let res = get_rpath_relative_to_output(config, Path::new("lib/libstd.so"));
assert_eq!(res, "@loader_path/../lib");
} else {
let config = &mut RPathConfig {
used_crates: &[],
out_filename: PathBuf::from("bin/rustc"),
get_install_prefix_lib_path: &mut || panic!(),
has_rpath: true,
is_like_osx: false,
linker_is_gnu: true,
Expand Down

0 comments on commit 6b45d59

Please sign in to comment.