Integrate LLD for MSVC targets via experimental CMake option LDC_WITH_LLD

Results in a 7.5% bigger RelWithDebInfo ldc2.exe on Win64 with LLVM 3.9.1.

LLD is currently enforced when building with LDC_WITH_LLD=ON. And LLD
still doesn't support debuginfo (.pdb) generation for MSVC targets.
This commit is contained in:
Martin 2017-05-27 15:47:12 +02:00
parent ede23642ef
commit 00d5f9b5b5
5 changed files with 62 additions and 32 deletions

View file

@ -12,6 +12,10 @@
#include "driver/tool.h"
#include "gen/logger.h"
#if LDC_WITH_LLD
#include "lld/Driver/Driver.h"
#endif
//////////////////////////////////////////////////////////////////////////////
static llvm::cl::opt<std::string> mscrtlib(
@ -160,6 +164,20 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath,
}
logstr << "\n"; // FIXME where's flush ?
#if LDC_WITH_LLD
const bool useInternalLinker = true; // TODO
if (useInternalLinker) {
const auto fullArgs =
getFullArgs("lld-link.exe", args, global.params.verbose);
const bool success = lld::coff::link(fullArgs);
if (!success)
error(Loc(), "linking with LLD failed");
return success ? 0 : 1;
}
#endif
// try to call linker
return executeToolAndWait(tool, args, global.params.verbose);
}