This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Do not enable 'new dtags' on NetBSD by default
Needs ReviewPublic

Authored by mgorny on Jan 3 2019, 12:18 PM.

Details

Summary

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.

Diff Detail

Event Timeline

mgorny created this revision.Jan 3 2019, 12:18 PM

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.

ruiu added a comment.Jan 3 2019, 2:38 PM

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.

mgorny added a comment.Jan 7 2019, 6:12 AM

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?

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.

ruiu added a comment.Jan 7 2019, 11:15 AM

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.

krytarowski added a comment.EditedJan 7 2019, 12:27 PM

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.

mgorny updated this revision to Diff 180718.Jan 8 2019, 12:41 PM

Updating for completeness.

grimar added a subscriber: grimar.Jan 9 2019, 7:37 AM