Re-land [LLD] Allow usage of LLD as a library
commit6f2e92c10cebca51f9bc98b99fa3b5583ff396c4
authorAlexandre Ganea <alex_toresh@yahoo.fr>
Mon, 19 Jun 2023 11:32:34 +0000 (19 07:32 -0400)
committerAlexandre Ganea <alex_toresh@yahoo.fr>
Mon, 19 Jun 2023 11:35:11 +0000 (19 07:35 -0400)
treeca95b464ea79937019f1a23928ade2f10679c49b
parent9ef73f2f58ecfce21bdeb27f68b224d9be97cfe6
Re-land [LLD] Allow usage of LLD as a library

This reverts commit aa495214b39d475bab24b468de7a7c676ce9e366.

As discussed in https://github.com/llvm/llvm-project/issues/53475 this patch
allows for using LLD-as-a-lib. It also lets clients link only the drivers that
they want (see unit tests).

This also adds the unit test infra as in the other LLVM projects. Among the
test coverage, I've added the original issue from @krzysz00, see:
https://github.com/ROCmSoftwarePlatform/D108850-lld-bug-reproduction

Important note: this doesn't allow (yet) linking in parallel. This will come a
bit later hopefully, in subsequent patches, for COFF at least.

Differential revision: https://reviews.llvm.org/D119049
24 files changed:
lld/CMakeLists.txt
lld/COFF/Driver.cpp
lld/Common/CMakeLists.txt
lld/Common/DriverDispatcher.cpp [new file with mode: 0644]
lld/ELF/Driver.cpp
lld/MachO/Driver.cpp
lld/MinGW/Driver.cpp
lld/docs/NewLLD.rst
lld/docs/index.rst
lld/include/lld/Common/Driver.h
lld/test/CMakeLists.txt
lld/test/Unit/lit.cfg.py [new file with mode: 0644]
lld/test/Unit/lit.site.cfg.py.in [new file with mode: 0644]
lld/tools/lld/lld.cpp
lld/unittests/AsLibAll/AllDrivers.cpp [new file with mode: 0644]
lld/unittests/AsLibAll/CMakeLists.txt [new file with mode: 0644]
lld/unittests/AsLibELF/CMakeLists.txt [new file with mode: 0644]
lld/unittests/AsLibELF/Inputs/kernel1.o [new file with mode: 0644]
lld/unittests/AsLibELF/Inputs/kernel2.o [new file with mode: 0644]
lld/unittests/AsLibELF/ROCm.cpp [new file with mode: 0644]
lld/unittests/AsLibELF/SomeDrivers.cpp [new file with mode: 0644]
lld/unittests/CMakeLists.txt [new file with mode: 0644]
lld/wasm/Driver.cpp
llvm/cmake/modules/AddLLVM.cmake