[PATCH] D69755: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 2 14:45:39 PDT 2019


krytarowski created this revision.
krytarowski added reviewers: ruiu, joerg, mgorny, MaskRay.
krytarowski added a project: lld.
Herald added subscribers: llvm-commits, cfe-commits, fedor.sergeev, aheejin, emaste, dschuff.
Herald added projects: clang, LLVM.

The NetBSD target wraps the default Linux/ELF target with OS specific
customization. It is implemented as a light nb.lld program that
mutates arguments in argv[] and spawns ld.lld.

This flavor detects the native/current and target Triple based on
argv[0] parsing. This is prerequisite for cross-compilation, in
particular the NetBSD distribution is cross-built always.

The default configuration of the ELF target is tuned for Linux and
there is no way to costomize in-place for the NetBSD target in the
same way as FreeBSD/OpenBSD. FreeBSD whenever needed can check
emulation name ("*_fbsd") and OpenBSD calls its extensions
"PT_OPENBSD_*".

This distinct flavor is needed for NetBSD as:

- the linker MUST work in the standalone mode
- it must be useful with gcc/pcc/others out of the box
- clang NetBSD driver shall not hardcode LLD specific options
- the linker must have support for cross-building
- LLD shall be a drop-in replacement for (NetBSD-patched) GNU ld

nb.lld calls internally ld.lld and there is no code-duplication
between nb.lld and ld.lld. There is no functional or code
maintenance change for other Operating Systems, especially the ELF
ones.

Equivalent customization is already done for the Darwin mode. For
instance there are hardcoded default search paths such as "/usr/lib"
and "/Library/Frameworks" in DarwinLdDriver.cpp.

This change is a starting point for development of NetBSD support
in LLD. This is also another approach to achieve the same goal as
mutating the default LLD/ELF target based on Triple, but in a
less invasive way as everything is moved out of LLD to nb.lld now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69755

Files:
  clang/lib/Driver/ToolChain.cpp
  lld/CMakeLists.txt
  lld/tools/lld/lld.cpp
  lld/tools/nb.lld/CMakeLists.txt
  lld/tools/nb.lld/Options.td
  lld/tools/nb.lld/nb.lld.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69755.227591.patch
Type: text/x-patch
Size: 12760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191102/5fddc9cc/attachment.bin>


More information about the llvm-commits mailing list