[MSVC] CMake: Prepare for LLVM 5.0#2279
Conversation
Some LLVM libs were missing from the linker flags for current LLVM 5.0. It was only during troubleshooting that I noticed the MSVC special case in FindLLVM.cmake. Getting rid of it entirely made the issues disappear. I checked llvm-config.exe, and it's returning appropriate switches for the MS toolchain, no need for special processing. This apparently also leads to LLVM_CXXFLAGS being used for the first time when building with MSVC. These include /W4, a level further up from CMake's default /W3, so I disabled a few more frequent warnings. I also had to link in a lib from Microsoft's Debug Info Access SDK manually. As the VS command prompt unfortunately doesn't even include the DIA SDK dir in the LIBPATH environment variable, I even had to specify a full path, relying on the `VSINSTALLDIR` environment variable.
|
AppVeyor: |
One advantage is that the D modules aren't recompiled if only .cpp files have been modified. Another advantage is that the 2 separate command lines are shorter than the single combined one, preventing issues on Windows wrt. max command line length.
I never had trouble with this when building with LLVM master. I guess that's because I'm not compiling with LLD integration. Does it have debug info support now? |
| if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-9][\\.0-9A-Za-z]*") | ||
| # Versions below 4.0 do not support component debuginfomsf | ||
| list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfomsf" index) | ||
| endif() |
There was a problem hiding this comment.
Removing this list is very much appreciated. I had to add the binaryformat library recently, too (probably caused by the selected targets).
|
Yep binaryformat was missing for me too. I disabled the LLD integration (needs #2148 otherwise to work) but still needed |
|
The remaining AppVeyor issue is unrelated btw, realizing that cost me some hours yesterday - they probably changed something in their image (and once again didn't mention anything in their blog/Twitter feed/...). I built this PR yesterday successfully with both LLVM 5.0 and 4.0.1. |
|
AppVeyor upgraded to the latest VS + WinSDK update and since then master has been red. Upgrading myself right now... |
|
I have the same issue now, even after rebuilding LLVM. LDC segfaults during a GC collection triggered by a druntime module ctor, in |
|
Might have something to do with the |
Oh, boy. Sounds like this will break every program linked against/with v15.3.1 ;-(
I'll have a look... |
|
The problem seems to be that .tls is no longer an image section, but only a segment in the .data section. TLS access seems to be ok, but _tls_start and _tls_end are now evaluated relative to the .data section: prints i.e. the variable is not in the TLS range (but it's the range that is wrong here). Happens with dmd, too, if using V2017 v15.3.1. This seems to be a linker issue as exchanging the vc library with the one from VS2015 doesn't help. |
|
Thanks for the analysis. So if we were to work around that, the host compiler's druntime would have to be patched first, thanks MS, very much appreciated. |
Depends on the workaround. Maybe we can enforce moving the segment back into the .tls section.
I guess my VS2017 is broken now, too. (I mostly use 2013 and 2015, though). They also changed the vcvars64.bat to always switch to %HOME%\source. That breaks a good deal of my batches, probably also some builds by Visual D. |
From https://llvm.org/docs/CMake.html#llvm-specific-variables: Don't know what that means exactly and don't have time to dig into it right now, but I take it as a good sign. ;) |
|
Btw, Microsoft released 15.3.2 4 days later. I don't dare testing that yet though.
Yep, mine too. Additionally, the |
I tried it, no improvement for our issues. cv2pdb also doesn't work anymore... |
I have not found any work around, so here is the runtime change: dlang/druntime#1910 |
I stumbled over a workaround: there is a hidden linker switch /noopttls that restores the old behaveour. Seems to exist starting with VS2015. |
|
Oh wow, how did you find out about that one? No single Google hit... ;) |
Staring at strings in link.exe. You can find a quite some more undocumented switches this way. |
Some LLVM libs were missing from the linker flags for current LLVM 5.0. It was only during troubleshooting that I noticed the MSVC special case in
FindLLVM.cmake. Getting rid of it entirely made the issues disappear. I checkedllvm-config.exe, and it's returning appropriate switches for the MS toolchain, no need for special processing.This apparently also leads to
LLVM_CXXFLAGSbeing used for the first time when building with MSVC. These include/W4, a level further up from CMake's default/W3, so I disabled a few more frequent warnings.I also had to link in a lib from Microsoft's Debug Info Access SDK manually. As the VS command prompt unfortunately doesn't even include the DIA SDK dir in the
LIBPATHenvironment variable, I even had to specify a full path, relying on theVSINSTALLDIRenvironment variable.