Skip to content

Commit a3205a6

Browse files
committed
Use sysroot instead of CFG_PREFIX for the rpath
CFG_PREFIX is incorrect for rustup installed rustc versions. It also causes unnecessary recompilation when changing the install prefix.
1 parent 016e9b5 commit a3205a6

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1567,13 +1567,12 @@ fn add_rpath_args(
15671567
) {
15681568
// FIXME (#2397): At some point we want to rpath our guesses as to
15691569
// where extern libraries might live, based on the
1570-
// addl_lib_search_paths
1570+
// add_lib_search_paths
15711571
if sess.opts.cg.rpath {
15721572
let target_triple = sess.opts.target_triple.triple();
15731573
let mut get_install_prefix_lib_path = || {
1574-
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
15751574
let tlib = rustc_target::target_rustlib_path(&sess.sysroot, target_triple).join("lib");
1576-
let mut path = PathBuf::from(install_prefix);
1575+
let mut path = PathBuf::from(&sess.sysroot);
15771576
path.push(&tlib);
15781577

15791578
path

src/bootstrap/compile.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
629629
cargo
630630
.env("CFG_RELEASE", builder.rust_release())
631631
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
632-
.env("CFG_VERSION", builder.rust_version())
633-
.env("CFG_PREFIX", builder.config.prefix.clone().unwrap_or_default());
632+
.env("CFG_VERSION", builder.rust_version());
634633

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

0 commit comments

Comments
 (0)