<div dir="ltr"><div class="gmail_extra">> 2. Is there a simple way for me to get Clang 4.0's behavior back, where having cl.exe and link.exe on my PATH makes Clang automatically detect the correct -fms-compatibility-version and link.exe to be used?<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">I haven't figured out what changed, but that definitely seems like a regression.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 14, 2017 at 6:04 PM, Stephan T. Lavavej via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Clang devs,<br>
<br>
I'm trying to use Clang/LLVM with MSVC's STL in order to keep our code conformant and Clang-compatible, and I've encountered a problematic behavior change between Clang 4.0 and 5.0.<br>
<br>
The only Visual Studio installation on my machine is VS 2013. (I work on msvcp140.dll, so my life is easier if I avoid anything that installs it system-wide like VS 2015/2017.)<br>
<br>
I am NOT using a VS 2013 Developer Command Prompt.<br>
<br>
I'm starting with a plain command prompt, using a development build of VS 2017 (somewhat beyond 15.3) by adding it to PATH, INCLUDE, and LIB. (I'm NOT running an installer for this development build, nor am I modifying the registry in any way.) The directory structure of our development build is simple, although it does not correspond to the publicly distributed installer. On my machine, I have S:\binaries\x86ret, with S:\binaries\x86ret\bin\i386\<wbr>cl.exe containing the x86-native compiler, S:\binaries\x86ret\inc\vector containing my favorite header, and S:\binaries\x86ret\lib\i386\<wbr>libcpmt.lib containing the STL's static lib. (The CRT's headers and libs are in different directories, but Clang isn't having trouble with INCLUDE and LIB.)<br>
<br>
I've also used 7-Zip to extract Clang/LLVM 4.0.1 x64-hosted to a directory, WITHOUT running an installer.<br>
<br>
In this scenario, everything works fine, and we've been testing our STL with Clang/LLVM since June (originally 4.0.0, now 4.0.1):<br>
<br>
C:\Temp>echo %PATH%<br>
S:\WCFB01\vctools\nonship\bin\<wbr>x86;S:\binaries\x86ret\bin\<wbr>i386;S:\WCFB01\vctools\<wbr>Compiler\Regress\bin\AMD64\<wbr>xperf;S:\WCFB01\vctools\<wbr>NonShip\ClangLLVM\bin;C:\Temp\<wbr>Exec;C:\Temp\git\cmd;C:\<wbr>windows\system32;C:\windows;C:<wbr>\windows\System32\Wbem;C:\<wbr>windows\System32\<wbr>WindowsPowerShell\v1.0\;C:\<wbr>Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\<wbr>Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Users\<wbr>stl\AppData\Local\Microsoft\<wbr>WindowsApps;;S:\WCFB01\<wbr>vctools\Compiler\Regress\bin;<wbr>S:\WCFB01\vctools\Compiler\<wbr>Regress\bin\AMD64;;S:\WCFB01\<wbr>tools\perl\bin<br>
<br>
C:\Temp>echo %INCLUDE%<br>
S:\binaries\x86ret\atlmfc\<wbr>include;S:\binaries\x86ret\<wbr>inc;S:\WCFB01\ExternalApis\<wbr>Windows\10\sdk\inc;S:\WCFB01\<wbr>ExternalApis\UnifiedCRT\inc;S:<wbr>\WCFB01\ExternalAPIs\DirectX\<wbr>Jun2010\Include;<br>
<br>
C:\Temp>echo %LIB%<br>
S:\binaries\x86ret\atlmfc\lib\<wbr>i386;S:\binaries\x86ret\lib\<wbr>i386;S:\WCFB01\ExternalApis\<wbr>Windows\10\sdk\lib\x86;S:\<wbr>WCFB01\ExternalApis\<wbr>UnifiedCRT\lib\i386;S:\WCFB01\<wbr>ExternalApis\NetFX\v4.5\lib\<wbr>x86;S:\WCFB01\ExternalAPIs\<wbr>DirectX\Jun2010\Lib\x86;<br>
<br>
C:\Temp>type meow.cpp<br>
#include <iostream><br>
int main() {<br>
#ifdef __clang__<br>
    std::cout << "I am Clang: " << __clang_version__ << "\n";<br>
#elif defined(_MSC_VER)<br>
    std::cout << "I am C1XX: " << _MSC_FULL_VER << "\n";<br>
#else<br>
    std::cout << "I am something else.\n";<br>
#endif<br>
}<br>
<br>
C:\Temp>where cl<br>
S:\binaries\x86ret\bin\i386\<wbr>cl.exe<br>
<br>
C:\Temp>where link<br>
S:\binaries\x86ret\bin\i386\<wbr>link.exe<br>
<br>
C:\Temp>cl /EHsc /nologo /W4 /MT meow.cpp && meow<br>
meow.cpp<br>
I am C1XX: 191125614<br>
<br>
C:\Temp>where clang-cl<br>
S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\bin\clang-cl.exe<br>
<br>
C:\Temp>clang-cl -v -m32 /EHsc /nologo /W4 /MT meow.cpp && meow<br>
clang version 4.0.1 (tags/RELEASE_401/final)<br>
Target: i386-pc-windows-msvc<br>
Thread model: posix<br>
InstalledDir: S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\bin<br>
 "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\bin\\clang-cl.exe" -cc1 -triple i386-pc-windows-msvc19.11.<wbr>25614 -emit-obj -mrelax-all -mincremental-linker-<wbr>compatible -disable-free -main-file-name meow.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdiagnostics-format msvc -v -dwarf-column-info -debugger-tuning=gdb -resource-dir "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\bin\\..\\lib\\<wbr>clang\\4.0.1" -internal-isystem "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\bin\\..\\lib\\<wbr>clang\\4.0.1\\include" -internal-isystem "S:\\binaries\\x86ret\\atlmfc\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>Windows\\10\\sdk\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>UnifiedCRT\\inc" -internal-isystem "S:\\WCFB01\\ExternalAPIs\\<wbr>DirectX\\Jun2010\\Include" -WCL4 -fdeprecated-macro -fdebug-compilation-dir "C:\\Temp" -ferror-limit 19 -fmessage-length 120 -fms-extensions -fms-compatibility -fms-compatibility-version=19.<wbr>11.25614 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-291efe.<wbr>obj" -x c++ meow.cpp<br>
clang -cc1 version 4.0.1 based upon LLVM 4.0.1 default target x86_64-pc-windows-msvc<br>
#include "..." search starts here:<br>
#include <...> search starts here:<br>
 S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\bin\..\lib\clang\4.<wbr>0.1\include<br>
 S:\binaries\x86ret\atlmfc\<wbr>include<br>
 S:\binaries\x86ret\inc<br>
 S:\WCFB01\ExternalApis\<wbr>Windows\10\sdk\inc<br>
 S:\WCFB01\ExternalApis\<wbr>UnifiedCRT\inc<br>
 S:\WCFB01\ExternalAPIs\<wbr>DirectX\Jun2010\Include<br>
End of search list.<br>
 "S:\\binaries\\x86ret\\bin\\<wbr>i386\\link.exe" -out:meow.exe -nologo "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-291efe.<wbr>obj"<br>
I am Clang: 4.0.1 (tags/RELEASE_401/final)<br>
<br>
Observe that my C1XX version, 19.11.25614, is detected by Clang which passes -fms-compatibility-version=19.<wbr>11.25614 and defaults to -std=c++14. The linker from my development build is also used, S:\binaries\x86ret\bin\i386\<wbr>link.exe.<br>
<br>
Next, I deleted everything in S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\, downloaded <a href="http://prereleases.llvm.org/5.0.0/rc2/LLVM-5.0.0-rc2-win64.exe" rel="noreferrer" target="_blank">http://prereleases.llvm.org/5.<wbr>0.0/rc2/LLVM-5.0.0-rc2-win64.<wbr>exe</a> (grinding my teeth at non-secure HTTP), and extracted 5.0.0-rc2 there:<br>
<br>
S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM>dir /b<br>
<br>
S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM>7z x C:\Temp\LLVM-5.0.0-rc2-win64.<wbr>exe -x!Uninstall.exe -x!$PLUGINSDIR\*<br>
<br>
7-Zip [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04<br>
<br>
Scanning the drive for archives:<br>
1 file, 131097761 bytes (126 MiB)<br>
<br>
Extracting archive: C:\Temp\LLVM-5.0.0-rc2-win64.<wbr>exe<br>
--<br>
Path = C:\Temp\LLVM-5.0.0-rc2-win64.<wbr>exe<br>
Type = Nsis<br>
Physical Size = 131097761<br>
Method = LZMA:25<br>
Solid = +<br>
Headers Size = 205263<br>
Embedded Stub Size = 114176<br>
SubType = NSIS-3<br>
<br>
Everything is Ok<br>
<br>
Files: 291<br>
Size:       1096683135<br>
Compressed: 131097761<br>
<br>
S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM>dir /b<br>
bin<br>
include<br>
lib<br>
libexec<br>
msbuild-bin<br>
share<br>
tools<br>
<br>
Now in my usual command prompt (where PATH, INCLUDE, and LIB are unchanged):<br>
<br>
C:\Temp>where clang-cl<br>
S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\bin\clang-cl.exe<br>
<br>
C:\Temp>clang-cl -v -m32 /EHsc /nologo /W4 /MT meow.cpp && meow<br>
clang version 5.0.0 (tags/RELEASE_500/rc2)<br>
Target: i386-pc-windows-msvc<br>
Thread model: posix<br>
InstalledDir: S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\bin<br>
 "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\bin\\clang-cl.exe" -cc1 -triple i386-pc-windows-msvc18.0.40629 -emit-obj -mrelax-all -mincremental-linker-<wbr>compatible -disable-free -main-file-name meow.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdiagnostics-format msvc -v -dwarf-column-info -debugger-tuning=gdb -resource-dir "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\lib\\clang\\5.0.0" -internal-isystem "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\lib\\clang\\5.0.0\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\atlmfc\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>Windows\\10\\sdk\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>UnifiedCRT\\inc" -internal-isystem "S:\\WCFB01\\ExternalAPIs\\<wbr>DirectX\\Jun2010\\Include" -WCL4 -fdeprecated-macro -fdebug-compilation-dir "C:\\Temp" -ferror-limit 19 -fmessage-length 120 -fms-extensions -fms-compatibility -fms-compatibility-version=18.<wbr>0.40629 -std=c++11 -fno-threadsafe-statics -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-e93677.<wbr>obj" -x c++ meow.cpp<br>
clang -cc1 version 5.0.0 based upon LLVM 5.0.0-rc2 default target x86_64-pc-windows-msvc<br>
#include "..." search starts here:<br>
#include <...> search starts here:<br>
 S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\lib\clang\5.0.0\<wbr>include<br>
 S:\binaries\x86ret\atlmfc\<wbr>include<br>
 S:\binaries\x86ret\inc<br>
 S:\WCFB01\ExternalApis\<wbr>Windows\10\sdk\inc<br>
 S:\WCFB01\ExternalApis\<wbr>UnifiedCRT\inc<br>
 S:\WCFB01\ExternalAPIs\<wbr>DirectX\Jun2010\Include<br>
End of search list.<br>
In file included from meow.cpp:1:<br>
In file included from S:\binaries\x86ret\inc\<wbr>iostream:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>istream:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>ostream:6:<br>
In file included from S:\binaries\x86ret\inc\ios:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>xlocnum:7:<br>
In file included from S:\binaries\x86ret\inc\cmath:<wbr>617:<br>
In file included from S:\binaries\x86ret\inc\<wbr>xtgmath.h:9:<br>
S:\binaries\x86ret\inc\<wbr>xtr1common(199,22) :  error: use of undeclared identifier 'char16_t'<br>
        struct _Is_integral<char16_t><br>
                            ^<br>
S:\binaries\x86ret\inc\<wbr>xtr1common(205,22) :  error: use of undeclared identifier 'char32_t'<br>
        struct _Is_integral<char32_t><br>
                            ^<br>
In file included from meow.cpp:1:<br>
In file included from S:\binaries\x86ret\inc\<wbr>iostream:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>istream:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>ostream:6:<br>
In file included from S:\binaries\x86ret\inc\ios:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>xlocnum:10:<br>
In file included from S:\binaries\x86ret\inc\<wbr>streambuf:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>xiosbase:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>xlocale:8:<br>
In file included from S:\binaries\x86ret\inc\<wbr>stdexcept:6:<br>
In file included from S:\binaries\x86ret\inc\<wbr>exception:7:<br>
In file included from S:\binaries\x86ret\inc\type_<wbr>traits:6:<br>
S:\binaries\x86ret\inc\<wbr>xstddef(257,2) :  error: 'auto' return without trailing return type; deduced return types are a<br>
      C++14 extension<br>
        auto _Unfancy(_Ptrty _Ptr)<br>
        ^<br>
[...more errors...]<br>
<br>
Now I'm getting -fms-compatibility-version=18.<wbr>0.40629 -std=c++11 which is thoroughly incompatible with my development build's headers (in S:\binaries\x86ret\inc).<br>
<br>
Let's add -fms-compatibility-version=19.<wbr>11.25614 and see what happens:<br>
<br>
C:\Temp>clang-cl -v -m32 /EHsc /nologo /W4 /MT -fms-compatibility-version=19.<wbr>11.25614 meow.cpp && meow<br>
clang version 5.0.0 (tags/RELEASE_500/rc2)<br>
Target: i386-pc-windows-msvc<br>
Thread model: posix<br>
InstalledDir: S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\bin<br>
 "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\bin\\clang-cl.exe" -cc1 -triple i386-pc-windows-msvc19.11.<wbr>25614 -emit-obj -mrelax-all -mincremental-linker-<wbr>compatible -disable-free -main-file-name meow.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdiagnostics-format msvc -v -dwarf-column-info -debugger-tuning=gdb -resource-dir "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\lib\\clang\\5.0.0" -internal-isystem "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\lib\\clang\\5.0.0\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\atlmfc\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>Windows\\10\\sdk\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>UnifiedCRT\\inc" -internal-isystem "S:\\WCFB01\\ExternalAPIs\\<wbr>DirectX\\Jun2010\\Include" -WCL4 -fdeprecated-macro -fdebug-compilation-dir "C:\\Temp" -ferror-limit 19 -fmessage-length 120 -fms-extensions -fms-compatibility -fms-compatibility-version=19.<wbr>11.25614 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-06d238.<wbr>obj" -x c++ meow.cpp<br>
clang -cc1 version 5.0.0 based upon LLVM 5.0.0-rc2 default target x86_64-pc-windows-msvc<br>
#include "..." search starts here:<br>
#include <...> search starts here:<br>
 S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\lib\clang\5.0.0\<wbr>include<br>
 S:\binaries\x86ret\atlmfc\<wbr>include<br>
 S:\binaries\x86ret\inc<br>
 S:\WCFB01\ExternalApis\<wbr>Windows\10\sdk\inc<br>
 S:\WCFB01\ExternalApis\<wbr>UnifiedCRT\inc<br>
 S:\WCFB01\ExternalAPIs\<wbr>DirectX\Jun2010\Include<br>
End of search list.<br>
 "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\link.exe" -out:meow.exe -nologo "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-06d238.<wbr>obj"<br>
libcmt.lib(new_scalar.obj) : warning LNK4229: invalid directive '/ThrowingNew' encountered; ignored<br>
libvcruntime.lib(trnsctrl.obj) : warning LNK4229: invalid directive '/GUARDSYM:___CxxFrameHandler,<wbr>S' encountered; ignored<br>
libvcruntime.lib(trnsctrl.obj) : warning LNK4229: invalid directive '/GUARDSYM:___<wbr>CxxFrameHandler3,S' encountered; ignored<br>
libvcruntime.lib(trnsctrl.obj) : warning LNK4229: invalid directive '/GUARDSYM:___<wbr>CxxFrameHandler2,S' encountered; ignored<br>
libvcruntime.lib(trnsctrl.obj) : warning LNK4229: invalid directive '/GUARDSYM:___<wbr>CxxLongjmpUnwind@4,S' encountered; ignored<br>
libvcruntime.lib(chandler4.<wbr>obj) : warning LNK4229: invalid directive '/GUARDSYM:__except_handler4,<wbr>S' encountered; ignored<br>
libcmt.lib(loadcfg.obj) : error LNK2001: unresolved external symbol ___guard_iat_table<br>
libcmt.lib(loadcfg.obj) : error LNK2001: unresolved external symbol ___guard_iat_count<br>
libcmt.lib(loadcfg.obj) : error LNK2001: unresolved external symbol ___guard_longjmp_table<br>
libcmt.lib(loadcfg.obj) : error LNK2001: unresolved external symbol ___guard_longjmp_count<br>
meow.exe : fatal error LNK1120: 4 unresolved externals<br>
clang-cl.exe: error: linker command failed with exit code 1120 (use -v to see invocation)<br>
<br>
That additionally activates -std=c++14, and compilation succeeds. However, VS 2013's linker is used - that's the "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\link.exe" - and it's unable to understand various parts of VS 2017-era libraries.<br>
<br>
Trying to add -fuse-ld=S:\binaries\x86ret\<wbr>bin\i386\link.exe doesn't work:<br>
<br>
C:\Temp>clang-cl -v -m32 /EHsc /nologo /W4 /MT -fms-compatibility-version=19.<wbr>11.25614 -fuse-ld=S:\binaries\x86ret\<wbr>bin\i386\link.exe meow.cpp && meow<br>
clang version 5.0.0 (tags/RELEASE_500/rc2)<br>
Target: i386-pc-windows-msvc<br>
Thread model: posix<br>
InstalledDir: S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\bin<br>
 "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\bin\\clang-cl.exe" -cc1 -triple i386-pc-windows-msvc19.11.<wbr>25614 -emit-obj -mrelax-all -mincremental-linker-<wbr>compatible -disable-free -main-file-name meow.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdiagnostics-format msvc -v -dwarf-column-info -debugger-tuning=gdb -resource-dir "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\lib\\clang\\5.0.0" -internal-isystem "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\lib\\clang\\5.0.0\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\atlmfc\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>Windows\\10\\sdk\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>UnifiedCRT\\inc" -internal-isystem "S:\\WCFB01\\ExternalAPIs\\<wbr>DirectX\\Jun2010\\Include" -WCL4 -fdeprecated-macro -fdebug-compilation-dir "C:\\Temp" -ferror-limit 19 -fmessage-length 120 -fms-extensions -fms-compatibility -fms-compatibility-version=19.<wbr>11.25614 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-74e9f6.<wbr>obj" -x c++ meow.cpp<br>
clang -cc1 version 5.0.0 based upon LLVM 5.0.0-rc2 default target x86_64-pc-windows-msvc<br>
#include "..." search starts here:<br>
#include <...> search starts here:<br>
 S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\lib\clang\5.0.0\<wbr>include<br>
 S:\binaries\x86ret\atlmfc\<wbr>include<br>
 S:\binaries\x86ret\inc<br>
 S:\WCFB01\ExternalApis\<wbr>Windows\10\sdk\inc<br>
 S:\WCFB01\ExternalApis\<wbr>UnifiedCRT\inc<br>
 S:\WCFB01\ExternalAPIs\<wbr>DirectX\Jun2010\Include<br>
End of search list.<br>
 "x86_64-pc-windows-msvc-S:\\<wbr>binaries\\x86ret\\bin\\i386\\<wbr>link.exe" -out:meow.exe -nologo "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-74e9f6.<wbr>obj"<br>
clang-cl.exe: error: unable to execute command: program not executable<br>
clang-cl.exe: error: linker command failed with exit code 1 (use -v to see invocation)<br>
<br>
Some searching led me to <a href="https://github.com/llvm-mirror/clang/commit/635bc7fefc12cc1333ba6ec77e563b7c8af01265" rel="noreferrer" target="_blank">https://github.com/llvm-<wbr>mirror/clang/commit/<wbr>635bc7fefc12cc1333ba6ec77e563b<wbr>7c8af01265</a> "Accept absolute paths in the -fuse-ld option." so I'm not sure why this doesn't work.<br>
<br>
I'm not picky about the linker (and I don't need debug info), so let's try -fuse-ld=lld-link and see what happens:<br>
<br>
C:\Temp>clang-cl -v -m32 /EHsc /nologo /W4 /MT -fms-compatibility-version=19.<wbr>11.25614 -fuse-ld=lld-link meow.cpp && meow<br>
clang version 5.0.0 (tags/RELEASE_500/rc2)<br>
Target: i386-pc-windows-msvc<br>
Thread model: posix<br>
InstalledDir: S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\bin<br>
 "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\bin\\clang-cl.exe" -cc1 -triple i386-pc-windows-msvc19.11.<wbr>25614 -emit-obj -mrelax-all -mincremental-linker-<wbr>compatible -disable-free -main-file-name meow.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdiagnostics-format msvc -v -dwarf-column-info -debugger-tuning=gdb -resource-dir "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\lib\\clang\\5.0.0" -internal-isystem "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\lib\\clang\\5.0.0\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\atlmfc\<wbr>\include" -internal-isystem "S:\\binaries\\x86ret\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>Windows\\10\\sdk\\inc" -internal-isystem "S:\\WCFB01\\ExternalApis\\<wbr>UnifiedCRT\\inc" -internal-isystem "S:\\WCFB01\\ExternalAPIs\\<wbr>DirectX\\Jun2010\\Include" -WCL4 -fdeprecated-macro -fdebug-compilation-dir "C:\\Temp" -ferror-limit 19 -fmessage-length 120 -fms-extensions -fms-compatibility -fms-compatibility-version=19.<wbr>11.25614 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-1d7183.<wbr>obj" -x c++ meow.cpp<br>
clang -cc1 version 5.0.0 based upon LLVM 5.0.0-rc2 default target x86_64-pc-windows-msvc<br>
#include "..." search starts here:<br>
#include <...> search starts here:<br>
 S:\WCFB01\vctools\NonShip\<wbr>ClangLLVM\lib\clang\5.0.0\<wbr>include<br>
 S:\binaries\x86ret\atlmfc\<wbr>include<br>
 S:\binaries\x86ret\inc<br>
 S:\WCFB01\ExternalApis\<wbr>Windows\10\sdk\inc<br>
 S:\WCFB01\ExternalApis\<wbr>UnifiedCRT\inc<br>
 S:\WCFB01\ExternalAPIs\<wbr>DirectX\Jun2010\Include<br>
End of search list.<br>
 "S:\\WCFB01\\vctools\\NonShip\<wbr>\ClangLLVM\\bin\\lld-link" -out:meow.exe -nologo "C:\\Users\\stl\\AppData\\<wbr>Local\\Temp\\1\\meow-1d7183.<wbr>obj"<br>
I am Clang: 5.0.0 (tags/RELEASE_500/rc2)<br>
<br>
That works, although I'm a little nervous about using this for our whole test suite when it isn't the default.<br>
<br>
So my questions are:<br>
<br>
1. Why is Clang 5.0 behaving differently from Clang 4.0 here? I see <a href="https://github.com/llvm-mirror/clang/blob/master/lib/Driver/ToolChains/MSVC.cpp" rel="noreferrer" target="_blank">https://github.com/llvm-<wbr>mirror/clang/blob/master/lib/<wbr>Driver/ToolChains/MSVC.cpp</a> trying to detect VS 2017 and other versions.<br>
<br>
2. Is there a simple way for me to get Clang 4.0's behavior back, where having cl.exe and link.exe on my PATH makes Clang automatically detect the correct -fms-compatibility-version and link.exe to be used?<br>
<br>
Thanks,<br>
STL<br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>