Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upUse DT_RUNPATH instead of DT_RPATH for -C rpath #30378
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
This should probably be encoded somewhere in the Target config. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
geofft
Dec 15, 2015
Contributor
Oh hey, there's a linker_is_gnu. I'll post a PR if my local build works.
|
Oh hey, there's a |
added a commit
to geofft/rust
that referenced
this issue
Dec 15, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
geofft
Dec 15, 2015
Contributor
Seems to work on GNU/Linux, PR opened. My local build with ./configure --enable-rpath is still able to run directly out of x86_64-unknown-linux-gnu/stage2/bin/rustc, and the binary has DT_RUNPATH according to readelf -d.
I haven't tested with musl or non-Linux.
One thing worth noting for the record is that DT_RUNPATH is only used for direct dependencies; it does not apply to indirect/recursive dependencies the way that DT_RPATH and LD_LIBRARY_PATH do. This is undocumented but mentioned in random blog posts and mailing list threads. I think this is fine and arguably correct, since this is just about Rust binaries and libraries being able to find their own dependencies. You should tell your native library build process to also set rpaths, or you should set LD_LIBRARY_PATH. But maybe I'm missing a use case.
|
Seems to work on GNU/Linux, PR opened. My local build with I haven't tested with musl or non-Linux. One thing worth noting for the record is that |
added a commit
to geofft/rust
that referenced
this issue
Dec 16, 2015
added a commit
that referenced
this issue
Dec 19, 2015
added a commit
that referenced
this issue
Dec 19, 2015
added a commit
that referenced
this issue
Dec 19, 2015
bors
closed this
in
#30394
Dec 19, 2015
added a commit
to fhahn/rust
that referenced
this issue
Dec 28, 2015
added a commit
to jroesch/rust
that referenced
this issue
Jan 4, 2016
added a commit
to starlab-io/meta-rust
that referenced
this issue
Apr 6, 2016
added a commit
to starlab-io/meta-rust
that referenced
this issue
Apr 6, 2016
added a commit
to starlab-io/meta-rust
that referenced
this issue
Apr 11, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
MartinHusemann
Nov 23, 2017
Contributor
DT_RUNPATH is a Linuxism. Using it whenver config.linker_is_gnu is not correct.
|
DT_RUNPATH is a Linuxism. Using it whenver config.linker_is_gnu is not correct. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jethrogb
Nov 23, 2017
Contributor
@MartinHusemann a two year old closed ticket is not the correct place to discuss this. Additionally, I can't find any evidence in the glibc source that DT_RUNPATH is specific to Linux. If you have a problem related to this, can you open a new issue with
- the platform you're using
- why your platform is using GNU ld but not GNU rtld?
|
@MartinHusemann a two year old closed ticket is not the correct place to discuss this. Additionally, I can't find any evidence in the glibc source that DT_RUNPATH is specific to Linux. If you have a problem related to this, can you open a new issue with
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
geofft
Nov 23, 2017
Contributor
@MartinHusemann which specific OS (kernel + libc combination) are you noticing DT_RUNPATH absent on?
I guess the thing I really want is that the dynamic linker is GNU libc, not that the compile-time linker is GNU ld. But as far as I know, non-Linux kernels + GNU libc (e.g., Hurd, GNU/kFreeBSD) support DT_RUNPATH. And I think that passing --enable-new-dtags to GNU ld targeting a platform which doesn't support it does nothing, though it's been a while since I've tried.
... However, musl and bionic both seem to support DT_RUNPATH. So given that Rust doesn't support the Hurd yet and GNU/kFreeBSD is basically dead, maybe it's better in practice to look for a Linux kernel, even though DT_RUNPATH isn't a kernel feature.
|
@MartinHusemann which specific OS (kernel + libc combination) are you noticing I guess the thing I really want is that the dynamic linker is GNU libc, not that the compile-time linker is GNU ld. But as far as I know, non-Linux kernels + GNU libc (e.g., Hurd, GNU/kFreeBSD) support DT_RUNPATH. And I think that passing ... However, musl and bionic both seem to support DT_RUNPATH. So given that Rust doesn't support the Hurd yet and GNU/kFreeBSD is basically dead, maybe it's better in practice to look for a Linux kernel, even though DT_RUNPATH isn't a kernel feature. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
MartinHusemann
Nov 24, 2017
Contributor
Sorry, I missed the (prominent) "Closed" sign at the top. I did open a new ticket already, see #46204, let's keep further discussions there.
|
Sorry, I missed the (prominent) "Closed" sign at the top. I did open a new ticket already, see #46204, let's keep further discussions there. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
richfelker
Jan 26, 2018
Old issue, but for the record: musl treats DT_RPATH and DT_RUNPATH identically. Either is searched after LD_LIBRARY_PATH, and affects both direct and indirect dependency loading. So it doesn't matter which you use for musl targets.
richfelker
commented
Jan 26, 2018
|
Old issue, but for the record: musl treats DT_RPATH and DT_RUNPATH identically. Either is searched after LD_LIBRARY_PATH, and affects both direct and indirect dependency loading. So it doesn't matter which you use for musl targets. |
geofft commentedDec 14, 2015
On at least GNU/Linux, and possibly on other ELF-based systems, there are two types of rpath, one using the
DT_RPATHentry in the dynamic headers and one using theDT_RUNPATHone. The distinction is thatDT_RPATHtakes precedence over theLD_LIBRARY_PATHenvironment variable, whereasDT_RUNPATHdoes not. The latter is more convenient and means that rpaths are less likely to get in your way, since you can override them.DT_RPATHis also claimed to be deprecated by the ld.so manpage. So I think thatrustc -C rpathshould generateDT_RUNPATHwhere available.glibc has supported this since at least 1999. musl 1.1.6 (January 2015) seems to honor
DT_RUNPATHbut not treat it differently. You can emit both, and the GNU dynamic linker ignoresDT_RPATH.You can tell GNU ld to emit
DT_RUNPATHinstead ofDT_RPATHby adding--enable-new-dtags, probably something likeHowever, neither Apple's linker nor lld supports this, and I'm not really sure how to make this platform-conditional. Hence a bug instead of a PR.