[PATCH] D56650: [lld] [ELF] Support customizing behavior on target triple

Kamil Rytarowski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 30 12:09:31 PST 2019


krytarowski added a comment.

If we pass flags from clang, we sacrifice:

- lld usable as a standalone executable
- gcc capable to use lld as a functional linker
- clang driver not capable to call unpatched gnu ld/gold as we grow local flags to workaroud the customization (such as -z nognustack)
- compat with a number of programs programs that call linker directly and we customize the passed flags (gcc itself is one of them)

We just gain clang+lld tandem to work and we must retain GCC/LD interoperability (which as I understand isn't a priority/interesting for other OSes).

In theory we can patch:

- GCC to pass lld flags
- GNU LD (/gold) to accept new flags
- all the programs using linker to stop doing so (like the GCC project)

We need to tune in lld at least for start (out of my head, likely not a finished list):

- tune the DT_NEEDED behavior,
- rpath behavior,
- GNU stack generation
- specify default target/emulation search paths
- disable 3 segments (disable ro one)

We can address all the issues either in lld or in all the other projects around which certainly doesn't scale (and I expect in particular problems to push e.g. -z nognustack to GNU ld(1)).

OpenBSD indeed patches downstream their linkers for additional flags and accidentally it works better in the lld design. In NetBSD we struggle to get sane defaults rather than a set of additional flags. GNU stack is unwanted also on at least OpenBSD(/Fuchsia..) and there is no way to disable it in lld as of now (a proposal is to grow a custom flag). All OSes need to pass default paths for standalone linker usage (I've listed a dozen of examples from FreeBSD ports in other review).

The current feeling in the project is that if we cannot set the defaults we should fork the lld driver downstream and patch it there, which is a lose as the upstream version will keep to be unusable.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56650/new/

https://reviews.llvm.org/D56650





More information about the cfe-commits mailing list