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]
This commit is contained in:
Alex Crichton 2014-06-11 14:52:38 -07:00
parent 09967665ea
commit a0546ded10
5 changed files with 9 additions and 9 deletions

2
configure vendored
View File

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

View File

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

View File

@ -120,8 +120,8 @@ endif
ifdef TRACE
CFG_RUSTC_FLAGS += -Z trace
endif
ifdef CFG_DISABLE_RPATH
CFG_RUSTC_FLAGS += -C no-rpath
ifdef CFG_ENABLE_RPATH
CFG_RUSTC_FLAGS += -C rpath
endif
# The executables crated during this compilation process have no need to include

View File

@ -1327,7 +1327,7 @@ fn link_args(cmd: &mut Command,
if sess.targ_cfg.os == abi::OsMacos {
cmd.args(["-dynamiclib", "-Wl,-dylib"]);
if !sess.opts.cg.no_rpath {
if sess.opts.cg.rpath {
let mut v = Vec::from_slice("-Wl,-install_name,@rpath/".as_bytes());
v.push_all(out_filename.filename().unwrap());
cmd.arg(v.as_slice());
@ -1346,7 +1346,7 @@ fn link_args(cmd: &mut Command,
// FIXME (#2397): At some point we want to rpath our guesses as to
// where extern libraries might live, based on the
// addl_lib_search_paths
if !sess.opts.cg.no_rpath {
if sess.opts.cg.rpath {
cmd.args(rpath::get_rpath_flags(sess, out_filename).as_slice());
}

View File

@ -300,8 +300,8 @@ cgoptions!(
"a list of arguments to pass to llvm (space separated)"),
save_temps: bool = (false, parse_bool,
"save all temporary output files during compilation"),
no_rpath: bool = (false, parse_bool,
"disables setting the rpath in libs/exes"),
rpath: bool = (false, parse_bool,
"set rpath values in libs/exes"),
no_prepopulate_passes: bool = (false, parse_bool,
"don't pre-populate the pass manager with a list of passes"),
no_vectorize_loops: bool = (false, parse_bool,