Skip to content

Commit c3da28e

Browse files
committed
pass -Wl,-z,origin to set DF_ORIGIN when using rpath
DF_ORIGIN flag signifies that the object being loaded may make reference to the $ORIGIN substitution string. Some implementations are just ignoring DF_ORIGIN and do substitution for $ORIGIN if present (whatever DF_ORIGIN pr Set the flag inconditionally if rpath is wanted.
1 parent 16d8a91 commit c3da28e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/rustc_codegen_ssa/src/back/rpath.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
2323
let rpaths = get_rpaths(config);
2424
let mut flags = rpaths_to_flags(&rpaths);
2525

26-
// Use DT_RUNPATH instead of DT_RPATH if available
2726
if config.linker_is_gnu {
27+
// Use DT_RUNPATH instead of DT_RPATH if available
2828
flags.push("-Wl,--enable-new-dtags".to_owned());
29+
30+
// Set DF_ORIGIN for substitute $ORIGIN
31+
flags.push("-Wl,-z,origin".to_owned());
2932
}
3033

3134
flags

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,7 @@ impl<'a> Builder<'a> {
11761176
rustflags.arg("-Zosx-rpath-install-name");
11771177
Some("-Wl,-rpath,@loader_path/../lib")
11781178
} else if !target.contains("windows") {
1179+
rustflags.arg("-Clink-args=-Wl,-z,origin");
11791180
Some("-Wl,-rpath,$ORIGIN/../lib")
11801181
} else {
11811182
None

0 commit comments

Comments
 (0)