This is useful in downstream toolchain builds that only support a single
(or maybe two) output formats. For CHERI LLVM, most users compile
the toolchain from source, so disabling the non-ELF linkers reduces
build time (about 100 C++ source files fewer to compile) and reduces
the lld binary size by about 4MB (106MB -> 102MB) for a statically
linked build.
Another example where this can be useful is the FreeBSD lld build,
which has a local patch to only include ELF support in lld.cpp.
This change will allow removing the downstream patch and
instead use the relevant LLD_ENABLE_*_LINKER defines.
This patch should not result in any long-term maintainance issues,
as it only adds a few if() lines to the CMake build and skips tests
for some subdirectories.
The header is not needed. Many config.h.cmake files don't use the header.