[PATCH] D70048: [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 9 13:49:48 PST 2019


krytarowski created this revision.
krytarowski added reviewers: joerg, mgorny, ruiu, MaskRay.
krytarowski added a project: lld.
Herald added subscribers: llvm-commits, cfe-commits, mstorsjo, 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 netbsd::link()
module wrapper that mutates arguments in argv[] and calls
elf::link().

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

There is no code-duplication between the NetBSD and ELF modules.
The NetBSD driver for debugging purposes prints the Target string
for the -v|-V|--version command line argument. 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. There is a prior
art with the MinGW target that similarly wraps coff:link().

This change is a starting point for development of NetBSD support
in LLD.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70048

Files:
  clang/lib/Driver/ToolChain.cpp
  lld/CMakeLists.txt
  lld/NetBSD/CMakeLists.txt
  lld/NetBSD/Driver.cpp
  lld/NetBSD/Options.td
  lld/include/lld/Common/Driver.h
  lld/tools/lld/CMakeLists.txt
  lld/tools/lld/lld.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70048.228590.patch
Type: text/x-patch
Size: 11559 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191109/4e9149cf/attachment.bin>


More information about the llvm-commits mailing list