Skip to content

Commit

Permalink
pass -Wl,-z,origin to set DF_ORIGIN when using rpath
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
semarie committed Dec 17, 2021
1 parent 16d8a91 commit c3da28e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
let rpaths = get_rpaths(config);
let mut flags = rpaths_to_flags(&rpaths);

// Use DT_RUNPATH instead of DT_RPATH if available
if config.linker_is_gnu {
// Use DT_RUNPATH instead of DT_RPATH if available
flags.push("-Wl,--enable-new-dtags".to_owned());

// Set DF_ORIGIN for substitute $ORIGIN
flags.push("-Wl,-z,origin".to_owned());
}

flags
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ impl<'a> Builder<'a> {
rustflags.arg("-Zosx-rpath-install-name");
Some("-Wl,-rpath,@loader_path/../lib")
} else if !target.contains("windows") {
rustflags.arg("-Clink-args=-Wl,-z,origin");
Some("-Wl,-rpath,$ORIGIN/../lib")
} else {
None
Expand Down

0 comments on commit c3da28e

Please sign in to comment.