
This should fix a number of concurrency/threading issues. I had to force-disable concurrency in the linker using a hack. I'm not entirely sure what the cause is, possibly the MinGW version (version 12 appears to work for me, while version 11 as used on the GitHub runner image seems to be broken). There are a few ways to fix this in a better way: * Fix the underlying cause (possibly by upgrading to MinGW-w64 12). * Add the `--threads` flag to the LLD MinGW linker, so we can use a regular parameter instead of this hack.
43 строки
1,2 КиБ
C++
43 строки
1,2 КиБ
C++
//go:build byollvm
|
|
|
|
// This file provides C wrappers for liblld.
|
|
|
|
#include <lld/Common/Driver.h>
|
|
#include <llvm/Support/Parallel.h>
|
|
|
|
extern "C" {
|
|
|
|
static void configure() {
|
|
#if _WIN64
|
|
// This is a hack to work around a hang in the LLD linker on Windows, with
|
|
// -DLLVM_ENABLE_THREADS=ON. It has a similar effect as the -threads=1
|
|
// linker flag, but with support for the COFF linker.
|
|
llvm::parallel::strategy = llvm::hardware_concurrency(1);
|
|
#endif
|
|
}
|
|
|
|
bool tinygo_link_elf(int argc, char **argv) {
|
|
configure();
|
|
std::vector<const char*> args(argv, argv + argc);
|
|
return lld::elf::link(args, llvm::outs(), llvm::errs(), false, false);
|
|
}
|
|
|
|
bool tinygo_link_macho(int argc, char **argv) {
|
|
configure();
|
|
std::vector<const char*> args(argv, argv + argc);
|
|
return lld::macho::link(args, llvm::outs(), llvm::errs(), false, false);
|
|
}
|
|
|
|
bool tinygo_link_mingw(int argc, char **argv) {
|
|
configure();
|
|
std::vector<const char*> args(argv, argv + argc);
|
|
return lld::mingw::link(args, llvm::outs(), llvm::errs(), false, false);
|
|
}
|
|
|
|
bool tinygo_link_wasm(int argc, char **argv) {
|
|
configure();
|
|
std::vector<const char*> args(argv, argv + argc);
|
|
return lld::wasm::link(args, llvm::outs(), llvm::errs(), false, false);
|
|
}
|
|
|
|
} // external "C"
|