mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Allow opting-out of rpath usage
By default, the compiler and libraries are all still built with rpaths, but this can be opted out of with --disable-rpath to ./configure or --no-rpath to rustc. cc #5219
This commit is contained in:
parent
fce792249e
commit
e715cdba31
21
Makefile.in
21
Makefile.in
@ -124,6 +124,12 @@ endif
|
||||
ifdef TRACE
|
||||
CFG_RUSTC_FLAGS += -Z trace
|
||||
endif
|
||||
ifdef DISABLE_RPATH
|
||||
# NOTE: make this CFG_RUSTC_FLAGS after stage0 snapshot
|
||||
RUSTFLAGS_STAGE1 += --no-rpath
|
||||
RUSTFLAGS_STAGE2 += --no-rpath
|
||||
RUSTFLAGS_STAGE3 += --no-rpath
|
||||
endif
|
||||
|
||||
# The executables crated during this compilation process have no need to include
|
||||
# static copies of libstd and libextra. We also generate dynamic versions of all
|
||||
@ -541,8 +547,21 @@ CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef CFG_DISABLE_RPATH
|
||||
ifeq ($$(OSTYPE_$(3)),apple-darwin)
|
||||
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
|
||||
DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(HLIB$(1)_H_$(3))"
|
||||
else
|
||||
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
|
||||
LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(HLIB$(1)_H_$(3))"
|
||||
endif
|
||||
else
|
||||
RPATH_VAR$(1)_T_$(2)_H_$(3) :=
|
||||
endif
|
||||
|
||||
STAGE$(1)_T_$(2)_H_$(3) := \
|
||||
$$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
|
||||
$$(Q)$$(RPATH_VAR$(1)_T_$(2)_H_$(3)) \
|
||||
$$(call CFG_RUN_TARG_$(3),$(1), \
|
||||
$$(CFG_VALGRIND_COMPILE$(1)) \
|
||||
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
|
||||
--cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
|
||||
|
1
configure
vendored
1
configure
vendored
@ -382,6 +382,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 pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
|
||||
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
|
||||
opt rpath 1 "build rpaths into rustc itself"
|
||||
valopt prefix "/usr/local" "set installation prefix"
|
||||
valopt local-rust-root "/usr/local" "set prefix for local rust binary"
|
||||
valopt llvm-root "" "set LLVM root"
|
||||
|
@ -1089,8 +1089,10 @@ fn link_args(sess: Session,
|
||||
args.push(~"-dynamiclib");
|
||||
args.push(~"-Wl,-dylib");
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
args.push(~"-Wl,-install_name,@rpath/" +
|
||||
out_filename.filename_str().unwrap());
|
||||
if !sess.opts.no_rpath {
|
||||
args.push(~"-Wl,-install_name,@rpath/" +
|
||||
out_filename.filename_str().unwrap());
|
||||
}
|
||||
} else {
|
||||
args.push(~"-shared")
|
||||
}
|
||||
@ -1108,7 +1110,9 @@ fn link_args(sess: Session,
|
||||
// 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
|
||||
args.push_all(rpath::get_rpath_flags(sess, out_filename));
|
||||
if !sess.opts.no_rpath {
|
||||
args.push_all(rpath::get_rpath_flags(sess, out_filename));
|
||||
}
|
||||
|
||||
// Finally add all the linker arguments provided on the command line along
|
||||
// with any #[link_args] attributes found inside the crate
|
||||
|
@ -734,6 +734,7 @@ pub fn build_session_options(binary: ~str,
|
||||
let parse_only = matches.opt_present("parse-only");
|
||||
let no_trans = matches.opt_present("no-trans");
|
||||
let no_analysis = matches.opt_present("no-analysis");
|
||||
let no_rpath = matches.opt_present("no-rpath");
|
||||
|
||||
let lint_levels = [lint::allow, lint::warn,
|
||||
lint::deny, lint::forbid];
|
||||
@ -888,6 +889,7 @@ pub fn build_session_options(binary: ~str,
|
||||
parse_only: parse_only,
|
||||
no_trans: no_trans,
|
||||
no_analysis: no_analysis,
|
||||
no_rpath: no_rpath,
|
||||
debugging_opts: debugging_opts,
|
||||
android_cross_path: android_cross_path,
|
||||
write_dependency_info: write_dependency_info,
|
||||
@ -995,6 +997,7 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
|
||||
\"list\" will list all of the available passes", "NAMES"),
|
||||
optopt("", "llvm-args", "A list of arguments to pass to llvm, comma \
|
||||
separated", "ARGS"),
|
||||
optflag("", "no-rpath", "Disables setting the rpath in libs/exes"),
|
||||
optopt( "", "out-dir",
|
||||
"Write output to compiler-chosen filename
|
||||
in <dir>", "DIR"),
|
||||
|
@ -170,6 +170,7 @@ pub struct Options {
|
||||
parse_only: bool,
|
||||
no_trans: bool,
|
||||
no_analysis: bool,
|
||||
no_rpath: bool,
|
||||
debugging_opts: u64,
|
||||
android_cross_path: Option<~str>,
|
||||
/// Whether to write dependency files. It's (enabled, optional filename).
|
||||
@ -388,6 +389,7 @@ pub fn basic_options() -> @Options {
|
||||
parse_only: false,
|
||||
no_trans: false,
|
||||
no_analysis: false,
|
||||
no_rpath: false,
|
||||
debugging_opts: 0,
|
||||
android_cross_path: None,
|
||||
write_dependency_info: (false, None),
|
||||
|
Loading…
Reference in New Issue
Block a user