Skip to content

Commit 206dd91

Browse files
committed
auto merge of #14832 : alexcrichton/rust/no-rpath, r=brson
This commit disables rustc's emission of rpath attributes into dynamic libraries and executables by default. The functionality is still preserved, but it must now be manually enabled via a `-C rpath` flag. This involved a few changes to the local build system: * --disable-rpath is now the default configure option * Makefiles now prefer our own LD_LIBRARY_PATH over the user's LD_LIBRARY_PATH in order to support building rust with rust already installed. * The compiletest program was taught to correctly pass through the aux dir as a component of LD_LIBRARY_PATH in more situations. The major impact of this change is that neither rustdoc nor rustc will work out-of-the-box in all situations because they are dynamically linked. It must be arranged to ensure that the libraries of a rust installation are part of the LD_LIBRARY_PATH. The default installation paths for all platforms ensure this, but if an installation is in a nonstandard location, then configuration may be necessary. Additionally, for all developers of rustc, it will no longer be possible to run $target/stageN/bin/rustc out-of-the-box. The old behavior can be regained through the `--enable-rpath` option to the configure script. This change brings linux/mac installations in line with windows installations where rpath is not possible. Closes #11747 [breaking-change]
2 parents 8bb34a3 + a0546de commit 206dd91

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
418418
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
419419
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
420420
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM"
421-
opt rpath 1 "build rpaths into rustc itself"
421+
opt rpath 0 "build rpaths into rustc itself"
422422
opt nightly 0 "build nightly packages"
423423
opt verify-install 1 "verify installed binaries work"
424424
opt jemalloc 1 "build liballoc with jemalloc"

man/rustc.1

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ A space-separated list of arguments to pass through to LLVM.
138138
If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated
139139
throughout compilation in the output directory.
140140
.TP
141-
\fBno-rpath\fR
142-
If specified, then the rpath value for dynamic libraries will not be set in
141+
\fBrpath\fR
142+
If specified, then the rpath value for dynamic libraries will be set in
143143
either dynamic library or executable outputs.
144144
.TP
145145
\fBno-prepopulate-passes\fR

mk/main.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ endif
122122
ifdef TRACE
123123
CFG_RUSTC_FLAGS += -Z trace
124124
endif
125-
ifdef CFG_DISABLE_RPATH
126-
CFG_RUSTC_FLAGS += -C no-rpath
125+
ifdef CFG_ENABLE_RPATH
126+
CFG_RUSTC_FLAGS += -C rpath
127127
endif
128128

129129
# The executables crated during this compilation process have no need to include

src/librustc/back/link.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ fn link_args(cmd: &mut Command,
13631363
if sess.targ_cfg.os == abi::OsMacos {
13641364
cmd.args(["-dynamiclib", "-Wl,-dylib"]);
13651365

1366-
if !sess.opts.cg.no_rpath {
1366+
if sess.opts.cg.rpath {
13671367
let mut v = Vec::from_slice("-Wl,-install_name,@rpath/".as_bytes());
13681368
v.push_all(out_filename.filename().unwrap());
13691369
cmd.arg(v.as_slice());
@@ -1382,7 +1382,7 @@ fn link_args(cmd: &mut Command,
13821382
// FIXME (#2397): At some point we want to rpath our guesses as to
13831383
// where extern libraries might live, based on the
13841384
// addl_lib_search_paths
1385-
if !sess.opts.cg.no_rpath {
1385+
if sess.opts.cg.rpath {
13861386
cmd.args(rpath::get_rpath_flags(sess, out_filename).as_slice());
13871387
}
13881388

src/librustc/driver/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ cgoptions!(
306306
"a list of arguments to pass to llvm (space separated)"),
307307
save_temps: bool = (false, parse_bool,
308308
"save all temporary output files during compilation"),
309-
no_rpath: bool = (false, parse_bool,
310-
"disables setting the rpath in libs/exes"),
309+
rpath: bool = (false, parse_bool,
310+
"set rpath values in libs/exes"),
311311
no_prepopulate_passes: bool = (false, parse_bool,
312312
"don't pre-populate the pass manager with a list of passes"),
313313
no_vectorize_loops: bool = (false, parse_bool,

0 commit comments

Comments
 (0)