Skip to content

Commit a0546de

Browse files
committed
rustc: Disable rpath settings by default
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]
1 parent 0996766 commit a0546de

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
@@ -120,8 +120,8 @@ endif
120120
ifdef TRACE
121121
CFG_RUSTC_FLAGS += -Z trace
122122
endif
123-
ifdef CFG_DISABLE_RPATH
124-
CFG_RUSTC_FLAGS += -C no-rpath
123+
ifdef CFG_ENABLE_RPATH
124+
CFG_RUSTC_FLAGS += -C rpath
125125
endif
126126

127127
# 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
@@ -1327,7 +1327,7 @@ fn link_args(cmd: &mut Command,
13271327
if sess.targ_cfg.os == abi::OsMacos {
13281328
cmd.args(["-dynamiclib", "-Wl,-dylib"]);
13291329

1330-
if !sess.opts.cg.no_rpath {
1330+
if sess.opts.cg.rpath {
13311331
let mut v = Vec::from_slice("-Wl,-install_name,@rpath/".as_bytes());
13321332
v.push_all(out_filename.filename().unwrap());
13331333
cmd.arg(v.as_slice());
@@ -1346,7 +1346,7 @@ fn link_args(cmd: &mut Command,
13461346
// FIXME (#2397): At some point we want to rpath our guesses as to
13471347
// where extern libraries might live, based on the
13481348
// addl_lib_search_paths
1349-
if !sess.opts.cg.no_rpath {
1349+
if sess.opts.cg.rpath {
13501350
cmd.args(rpath::get_rpath_flags(sess, out_filename).as_slice());
13511351
}
13521352

src/librustc/driver/config.rs

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

0 commit comments

Comments
 (0)