NetBSD strongly prefers using 'old' dtag (RPATH) over Linux-specific
RUNPATH, and did not support the latter until very recently. Therefore,
defaulting to RUNPATH causes lld to produce non-working executables
by default. Switch the default appropriately when building on NetBSD.
Details
- Reviewers
ruiu krytarowski joerg • espindola
Diff Detail
Event Timeline
We want to keep it disabled by default on NetBSD.. but it would be to keep dynamic detection of target NetBSD rather than hardcoded ifdef.
GNU ld sets it by default to false, following it would be the easiest option.
The compiler driver should pass -disable-new-tags to the linker, but let's discuss that in https://reviews.llvm.org/D56215 instead of here.
Ok, maybe I'm being silly but since clang driver has to pass --enable-new-dtags for GNU ld compatibility anyway, wouldn't it make sense to keep the default as disabled in order to match GNU ld behavior?
This would be the best especially in the context of philosophical issues of builtin knowledge in LLD and difficulty to resolve it.
Most Linux software doesn't need RPATH/RUNPATH as there is ld-config.. but it's completely the opposite on NetBSD where almost everything needs proper RPATH setting due to lack of Linux style ld-config.
I think when we implemented the feature, there was an understanding that the "new dtags" might be "new" 20 years ago but they are not new at all now. This is not the only example of changing the default in lld; one example being that text segments are not writable by default (-z text is default as opposed to -z notext).
We could argue that making the text segment writable is a total nonsense today, but new/old dtags are different story. Bug even if that's the case, changing the default at this point has perhaps too much impact to existing lld users.
On NetBSD the 'new' semantics was already implemented with 'old' RPATH. I don't know the timing whether there already existed RUNPATH, but the result is that we never implemented it and never needed it. The core of NetBSD was convinced to add an alias as it was very difficult in some examples (probably due to Rust) to rollback to 'old' RPATH.