Skip to content

Commit 761922f

Browse files
committed
AppVeyor: Build with clang (incl. LLVM)
When experimenting with the MinGW-w64 based libs, there was a problem - an undefined reference to function `_(_)chkstk`, emitted by LLVM for stack probing (e.g., after an `alloca`) and not provided by MinGW-w64. Initially, I used the symbol exported by ntdll.dll; normal user apps aren't supposed to depend on that system DLL though, and it also led to duplicate symbols for 32-bit code. After some digging, I found that LLVM's builtins compiler-rt library contains 2 implementations (1 MS-compatible, 1 for MinGW/Cygwin, both with different names than the MS one). Our library didn't contain it though, so I digged deeper. I found the culprit in the builtins CMake script; when using an MSVC toolchain, the builtins lib on Windows only contains very few C files and none of the various ASM ones, because they use AT&T syntax. So I decided to try building LLVM & compiler-rt with clang instead. That works fine, but I had to fix the CMake script, as the ASM files are excluded for MS-*compatible* toolchains, incl. clang. So I forked compiler-rt to fix this and some more annoyances. When compiling LLVM with clang-cl, the LLVM C++ compile flags include some clang-specific ones, so building LDC with MSVC didn't work. While that can be fixed at some point (stripping the clang-specific ones), I decided to build LDC (and the C/ASM files in our default libs) with clang too. That required some adaptations, as it started out with > 5k warnings. ;) So this commit switches to clang for compiling C/C++/ASM, but still uses Microsoft's linker.
1 parent 868642b commit 761922f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

appveyor.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ install:
8787
#echo 'Using LLVM with enabled assertions'
8888
#$assertsSuffix = '-withAsserts'
8989
}
90-
appveyor DownloadFile "https://github.com/ldc-developers/llvm/releases/download/ldc-v$Env:LLVM_VERSION/llvm-$Env:LLVM_VERSION-windows-$Env:APPVEYOR_JOB_ARCH$assertsSuffix.7z" -FileName llvm.7z
90+
appveyor DownloadFile "https://github.com/ldc-developers/llvm/releases/download/ldc-v$Env:LLVM_VERSION/llvm-$Env:LLVM_VERSION-windows-$Env:APPVEYOR_JOB_ARCH$assertsSuffix-clang.7z" -FileName llvm.7z
9191
- md llvm
9292
- cd llvm
9393
- 7z x ..\llvm.7z > nul
@@ -98,6 +98,8 @@ install:
9898
- set PATH=%CD%\llvm\bin;%CD%\ninja;%CD%\make;C:\Program Files\Git\usr\bin;%PATH%
9999
- if "%APPVEYOR_BUILD_WORKER_IMAGE:~-4%" == "2017" call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=%APPVEYOR_JOB_ARCH%
100100
- if "%APPVEYOR_BUILD_WORKER_IMAGE:~-4%" == "2015" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %APPVEYOR_JOB_ARCH%
101+
# Let CMake configure 64-bit clang-cl for 32-bit code emission
102+
- if "%APPVEYOR_JOB_ARCH%" == "x86" ( set "CFLAGS=-m32" && set "CXXFLAGS=-m32" && set "ASMFLAGS=-m32" )
101103
# Print environment info
102104
- set
103105
- msbuild /version
@@ -113,13 +115,13 @@ build_script:
113115
# Build bootstrap LDC
114116
- md bootstrap
115117
- cd bootstrap
116-
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ROOT_DIR=c:/projects/llvm ..\ldc
118+
- cmake -G Ninja -DCMAKE_C_COMPILER:PATH=clang-cl.exe -DCMAKE_CXX_COMPILER:PATH=clang-cl.exe -DCMAKE_BUILD_TYPE=Release -DLLVM_ROOT_DIR=c:/projects/llvm ..\ldc
117119
- ninja -j2 all
118120
- cd ..
119121
# Build LDC and stdlib unittest runners
120122
- md ninja-ldc
121123
- cd ninja-ldc
122-
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Release %EXTRA_CMAKE_FLAGS% -DCMAKE_INSTALL_PREFIX=c:\projects\ldc2-%APPVEYOR_JOB_ARCH% -DINCLUDE_INSTALL_DIR=c:/projects/ldc2-%APPVEYOR_JOB_ARCH%/import -DLLVM_ROOT_DIR=c:/projects/llvm -DD_COMPILER=c:\projects\bootstrap\bin\ldmd2.exe ..\ldc
124+
- cmake -G Ninja -DCMAKE_C_COMPILER:PATH=clang-cl.exe -DCMAKE_CXX_COMPILER:PATH=clang-cl.exe -DCMAKE_BUILD_TYPE=Release %EXTRA_CMAKE_FLAGS% -DCMAKE_INSTALL_PREFIX=c:\projects\ldc2-%APPVEYOR_JOB_ARCH% -DINCLUDE_INSTALL_DIR=c:/projects/ldc2-%APPVEYOR_JOB_ARCH%/import -DLLVM_ROOT_DIR=c:/projects/llvm -DD_COMPILER=c:\projects\bootstrap\bin\ldmd2.exe ..\ldc
123125
- ninja -j2 all all-test-runners
124126

125127
#---------------------------------#

0 commit comments

Comments
 (0)