<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 30, 2017 at 6:08 AM, Edward Diener via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Are you saying that once lld is built with mingw-64/gcc on Windows it is impossible to tell it to handle PE/COFF files when invoking it from clang++ using the -fuse-ld=lld parameter ? That would indeed be limiting, considering that on Windows I can build clang either with mingw-64/gcc or with Visual C++, and the -target parameter allows clang to generate the appropriate object files.</blockquote><div><br></div><div>The logic to construct an lld-link command line is part of the MSVC toolchain in the clang driver, so you can get clang++ to make a coff file if you tell it you're targetting MSVC like this:</div><div>$ clang++ t.cpp -fuse-ld=lld -o t.exe --target=x86_64-windows-msvc</div><div><br></div><div>Of course, that will look for libraries and headers in the wrong places if you really want to target mingw. If I split it up like this, I get link errors:</div><div><div>$ clang++ -c t.cpp -o t.o --target=x86_64-windows-gnu</div><div>$ clang++ t.o -o t.exe --target=x86_64-windows-msvc -fuse-ld=lld<br></div><div>C:\src\llvm-project\build_mingw\bin\lld-link.exe: warning: t.o: undefined symbol: _ZNSt8ios_base4InitC1Ev</div><div>C:\src\llvm-project\build_mingw\bin\lld-link.exe: warning: t.o: undefined symbol: _ZNSt8ios_base4InitD1Ev</div><div>C:\src\llvm-project\build_mingw\bin\lld-link.exe: warning: t.o: undefined symbol: __main</div><div>C:\src\llvm-project\build_mingw\bin\lld-link.exe: warning: t.o: undefined symbol: _ZSt4cout</div><div>C:\src\llvm-project\build_mingw\bin\lld-link.exe: warning: t.o: undefined symbol: _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc</div><div>error: link failed</div><div>clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)</div></div><div><br></div><div>If you pile on enough link options, you can probably make it work, but at that point you're basically reconstructing a link.exe / lld-link.exe command line. To fix this, someone should add mingw toolchain logic to clang's driver to support constructing lld-link command lines.</div></div></div></div>