Invoking lld for PE/COFF (Windows) linking using clang++
I build llvm/clang/lld from source on Windows using mingw-64/gcc-6.3. I
use the appropriate target triple to compile clang targeting VC++ and am
now trying to use lld to link the object file(s) into an exe. To do that
I use the clang option -fuse-ld=lld. According to the llvm doc on using
lld with PE/COFF on Windows at
"LLD supports Windows operating system. When invoked as lld-link.exe or
with -flavor link, the driver for Windows operating system is used to
parse command line options, and it drives further linking processes. LLD
accepts almost all command line options that the linker shipped with
Microsoft Visual C++ (link.exe) supports."
If I try passing to clang++ "-fuse-ld=lld-link" the compiler tells me it
is an invalid option, so I pass "-fuse-ld=lld" instead which the
compiler accepts. I then attempt to pass "-flavor link" on the clang++
command line, but that does not work either as clang++ sees it as two
separate options and complains that "link" is not a valid filename.
Alternatively I can successfully pass "-flavor=link" on the clang++
command line to the lld linker but then the linker tells me that
"-flavor=link" is an unknown argument.
What is the "magic" invocation that will allow me to invoke the lld
linker from the clang++ command, but get the linker to work in PE/COFF
mode rather than in ELF mode, so it will link object files created by
clang targeting VC++ ?