| Both sides previous revision Previous revision Next revision | Previous revision |
| lld [2021/03/26 00:47] – Rename sections, link to lld homepage, remove LLD version (out of date) KubilayKocak | lld [2022/02/10 03:13] (current) – Add Category: Project KubilayKocak |
|---|
| ====== Introduction ====== | ====== Introduction ====== |
| |
| [[https://lld.llvm.org/|lld]], part of the LLVM family of projects, is a high-performance linker for the ELF, COFF, and Mach-O object formats. This page describes the ongoing project to use lld as %%FreeBSD%%'s base system linker. | [[https://lld.llvm.org/|lld]], part of the LLVM family of projects, is a high-performance linker for the ELF, COFF, and Mach-O object formats. This page describes the now-completed project to use lld as %%FreeBSD%%'s base system linker. |
| |
| ===== LLD in Base ===== | ===== LLD in Base ===== |
| |
| LLD is currently the default system linker on amd64, arm*, aarch64, and powerpc64. On i386 LLD is ''%%/usr/bin/ld.lld%%'' but ''%%/usr/bin/ld%%'' is still GNU BFD ld. | As of 13, lld is now the default system linker on all supported architectures. |
| |
| On other architectures, to build world and kernel with LLD and install LLD as /usr/bin/ld, add to /etc/src.conf: | Prior to this, lld was in use on i386, amd64, arm*, aarch64, and riscv64*, with other architectures still using GNU BFD ld. For more information, see arch(7) in the manual for your particular %%FreeBSD%% version. |
| | |
| | To forcibly build world and kernel with LLD and install LLD as /usr/bin/ld in pre-13 versions, add to /etc/src.conf: |
| |
| <code> | <code> |
| ''%%WITH_LLD_BOOTSTRAP=yes%%'' uses lld as the linker for building the %%FreeBSD%% world, and has no effect on the linker installed in ''%%/usr/bin/ld%%''. ''%%WITH_LLD_IS_LD=yes%%'' installes lld as ''%%/usr/bin/ld%%'', and has no effect on the linker used for building world. | ''%%WITH_LLD_BOOTSTRAP=yes%%'' uses lld as the linker for building the %%FreeBSD%% world, and has no effect on the linker installed in ''%%/usr/bin/ld%%''. ''%%WITH_LLD_IS_LD=yes%%'' installes lld as ''%%/usr/bin/ld%%'', and has no effect on the linker used for building world. |
| |
| ===== Upstream LLD ===== | ====== Historical Issues ====== |
| |
| ==== Building ==== | ===== LLD patches ===== |
| |
| <code> | |
| git clone https://github.com/llvm-mirror/llvm | |
| cd llvm/tools | |
| git clone https://github.com/llvm-mirror/lld | |
| mkdir ../build && cd ../build | |
| cmake -G "Unix Makefiles" ../ | |
| make -j8 | |
| </code> | |
| |
| ==== LLD as default linker ==== | |
| |
| <code> | |
| cd build/bin | |
| ln -s lld ld | |
| setenv PATH /path/to/llvm/build/bin:$PATH | |
| setenv LD /path/to/llvm/build/bin | |
| rehash | |
| </code> | |
| |
| To check if the changes took effect: | |
| |
| <code> | |
| davide@rabbit1:/home/davide/llvm/build/bin $ ld --help | head -n 1 | |
| OVERVIEW: LLVM Linker | |
| </code> | |
| |
| ====== Per-arch status (in HEAD) ====== | |
| |
| ^ Architecture ^ World ^ Kernel ^ Bootstrap linker ^ /usr/bin/ld ^ | |
| | amd64 | OK | OK | lld | lld | | |
| | arm64 | OK | OK | lld | lld | | |
| | i386 | OK | OK | lld | bfd | | |
| | arm | libc fails to link | LLD targets v7l+ | bfd | bfd | | |
| | armv6 | libc fails to link | LLD targets v7l+ | bfd | bfd | | |
| | armv7 | OK | OK | lld | bfd | | |
| | mips64 | Most links, untested | Link fails | bfd | bfd | | |
| | mips | Most links, untested | Link fails | bfd | bfd | | |
| | powerpc64 | OK | OK | lld | lld | | |
| | powerpc | libc fails to link | Untested | bfd | bfd | | |
| | sparc64 | no support | no support | bfd | bfd | | |
| | riscv | OK | OK | lld | lld | | |
| |
| ====== TODO ====== | |
| |
| ===== WIP patches ===== | |
| |
| ==== lld ==== | |
| * <del>[[https://reviews.llvm.org/D41037|Create reserved symbols early so they can be versioned]]</del> | * <del>[[https://reviews.llvm.org/D41037|Create reserved symbols early so they can be versioned]]</del> |
| |
| * <del>[[https://reviews.llvm.org/D34692|Add support for multiple passes to createThunks]] (2017-06-27)</del> | * <del>[[https://reviews.llvm.org/D34692|Add support for multiple passes to createThunks]] (2017-06-27)</del> |
| |
| ==== FreeBSD ==== | ===== Ports ===== |
| | |
| ====== Known Issues ====== | |
| |
| A %%FreeBSD%% ports exp-run is tracked in [[https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214864|PR214864]]. | A %%FreeBSD%% ports exp-run is tracked in [[https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214864|PR214864]]. |
| * print/gl2ps needs explicit -L/usr/lib [[https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=218399|PR218399]]. | * print/gl2ps needs explicit -L/usr/lib [[https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=218399|PR218399]]. |
| |
| ===== Common issues in ports ===== | Common issues in ports: |
| - Passing compiler flags, such as ''%%-fPIC%%'', to the linker. | - Passing compiler flags, such as ''%%-fPIC%%'', to the linker. |
| - lld has no built-in search paths (''%%/lib, /usr/lib%%''). Normally the linker is invoked from the compiler driver, which adds the library search paths. If lld is invoked directly then library search paths must be explicitly specified, with ''%%-L/lib -L/usr/lib%%''. | - lld has no built-in search paths (''%%/lib, /usr/lib%%''). Normally the linker is invoked from the compiler driver, which adds the library search paths. If lld is invoked directly then library search paths must be explicitly specified, with ''%%-L/lib -L/usr/lib%%''. |
| * [[http://lists.llvm.org/pipermail/llvm-dev/2016-March/096449.html|Linking the FreeBSD base system with LLD]] status update from March 2016 | * [[http://lists.llvm.org/pipermail/llvm-dev/2016-March/096449.html|Linking the FreeBSD base system with LLD]] status update from March 2016 |
| * [[https://docs.google.com/document/d/1GcTY7kDKmvSYFAkJdUjLbHwoMHZlpbGG49wdWuaEnrg/edit?usp=sharing|lld as the FreeBSD base system linker]] Google Doc | * [[https://docs.google.com/document/d/1GcTY7kDKmvSYFAkJdUjLbHwoMHZlpbGG49wdWuaEnrg/edit?usp=sharing|lld as the FreeBSD base system linker]] Google Doc |
| | |
| | ---- |
| | |
| | {{tag>Historical}} |
| | {{tag>Project}} |
| |