Skip to content

Commit 9b356de

Browse files
authored
Rollup merge of rust-lang#91858 - semarie:runpath, r=petrochenkov
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](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#df_flags) and do [substitution](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#substitution) for $ORIGIN if present (whatever DF_ORIGIN presence or not) like glibc. But some others mandate the present of DF_ORIGIN for the substitution (like OpenBSD). Set the flag inconditionally if rpath is wanted. One possible fallout is if the linker rejects `-z origin` option.
2 parents 6e90e8b + 8ae5780 commit 9b356de

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

compiler/rustc_codegen_ssa/src/back/rpath.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
3434
fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
3535
let mut ret = Vec::with_capacity(rpaths.len()); // the minimum needed capacity
3636

37+
ret.push(String::from("-Wl,-z,origin"));
3738
for rpath in rpaths {
3839
if rpath.contains(',') {
3940
ret.push("-Wl,-rpath".into());

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)