1 //go:build byollvm
2 3 // This file provides C wrappers for liblld.
4 5 #include <lld/Common/Driver.h>
6 #include <llvm/Support/Parallel.h>
7 8 LLD_HAS_DRIVER(coff)
9 LLD_HAS_DRIVER(elf)
10 LLD_HAS_DRIVER(mingw)
11 LLD_HAS_DRIVER(macho)
12 LLD_HAS_DRIVER(wasm)
13 14 static void configure() {
15 #if _WIN64
16 // This is a hack to work around a hang in the LLD linker on Windows, with
17 // -DLLVM_ENABLE_THREADS=ON. It has a similar effect as the -threads=1
18 // linker flag, but with support for the COFF linker.
19 llvm::parallel::strategy = llvm::hardware_concurrency(1);
20 #endif
21 }
22 23 extern "C" {
24 25 bool moxie_link(int argc, char **argv) {
26 configure();
27 std::vector<const char*> args(argv, argv + argc);
28 lld::Result r = lld::lldMain(args, llvm::outs(), llvm::errs(), LLD_ALL_DRIVERS);
29 return !r.retCode;
30 }
31 32 } // external "C"
33