Use vcpkg LLVM for Windows build

This commit is contained in:
Luke Street 2021-06-11 21:05:23 -04:00
parent 37c56eec07
commit 37206e5301
3 changed files with 94 additions and 30 deletions

View File

@ -4,10 +4,19 @@ on:
push: push:
pull_request: pull_request:
env:
BUILDCACHE_VERSION: v0.27.0
BUILDCACHE_ACCURACY: STRICT
BUILDCACHE_MAX_CACHE_SIZE: 1073741824 # 1GiB
jobs: jobs:
build-linux-x86_64: build-linux-x86_64:
name: Build Linux (GCC x86_64) name: Build Linux (GCC x86_64)
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
env:
BUILDCACHE_DIR: ${{github.workspace}}/.buildcache
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -17,22 +26,33 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt-get -y update sudo apt-get -y update
sudo apt-get -y install cmake ninja-build ccache llvm-11-dev libclang-11-dev clang-11 sudo apt-get -y install cmake ninja-build llvm-11-dev libclang-11-dev clang-11
- name: Configure ccache # setup buildcache
uses: hendrikmuhs/ccache-action@v1 curl -LSfs https://github.com/mbitsnbites/buildcache/releases/download/$BUILDCACHE_VERSION/buildcache-linux.tar.gz | tar xz -C "$RUNNER_WORKSPACE"
echo "$RUNNER_WORKSPACE"/buildcache/bin >> $GITHUB_PATH
- name: Restore buildcache
uses: actions/cache@v2
with: with:
key: ubuntu-20.04-gcc path: ${{env.BUILDCACHE_DIR}}
max-size: 1G key: buildcache-ubuntu-20.04-x86_64
- name: Configure CMake - name: Configure CMake
run: | run: |
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DClang_DIR=/usr/lib/cmake/clang-11 \ cmake -B build . -GNinja \
-DATDNA_DYNAMIC_LLVM=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DATDNA_DYNAMIC_LLVM=OFF \
-DClang_DIR:PATH=/usr/lib/cmake/clang-11 \
-DCMAKE_C_COMPILER_LAUNCHER:STRING=buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=buildcache
- name: Build - name: Build
run: cmake --build build --target package --verbose run: cmake --build build --target package --verbose
- name: Print buildcache stats
run: buildcache -s
- name: Test - name: Test
working-directory: build working-directory: build
run: ./atdna-test run: ./atdna-test
@ -47,6 +67,7 @@ jobs:
build-linux-aarch64: build-linux-aarch64:
name: Build Linux (GCC aarch64) name: Build Linux (GCC aarch64)
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -65,8 +86,10 @@ jobs:
apt-get -y update apt-get -y update
apt-get -y install build-essential cmake ninja-build llvm-11-dev libclang-11-dev clang-11 apt-get -y install build-essential cmake ninja-build llvm-11-dev libclang-11-dev clang-11
run: | run: |
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \ cmake -B build . -GNinja \
-DClang_DIR=/usr/lib/cmake/clang-11 -DATDNA_DYNAMIC_LLVM=OFF -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DATDNA_DYNAMIC_LLVM:BOOL=OFF \
-DClang_DIR:PATH=/usr/lib/cmake/clang-11
cmake --build build --target package --verbose cmake --build build --target package --verbose
build/atdna-test build/atdna-test
@ -80,6 +103,10 @@ jobs:
build-macos-universal: build-macos-universal:
name: Build macOS (AppleClang universal) name: Build macOS (AppleClang universal)
runs-on: macos-10.15 runs-on: macos-10.15
env:
BUILDCACHE_DIR: ${{github.workspace}}/.buildcache
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -89,26 +116,38 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
brew update brew update
brew install ninja ccache brew install ninja
# universal clang+llvm from macports # universal clang+llvm from macports
curl -LSfs https://axiodl.com/files/clang-11-11.1.0_1.mpkg -o /tmp/clang-11-11.1.0_1.mpkg curl -LSfs https://axiodl.com/files/clang-11-11.1.0_1.mpkg -o /tmp/clang-11-11.1.0_1.mpkg
sudo installer -pkg /tmp/clang-11-11.1.0_1.mpkg -target / sudo installer -pkg /tmp/clang-11-11.1.0_1.mpkg -target /
- name: Configure ccache # setup buildcache
uses: hendrikmuhs/ccache-action@v1 curl -LSfs https://github.com/mbitsnbites/buildcache/releases/download/$BUILDCACHE_VERSION/buildcache-macos.zip -o /tmp/buildcache-macos.zip
unzip /tmp/buildcache-macos.zip -d "$RUNNER_WORKSPACE"
echo "$RUNNER_WORKSPACE"/buildcache/bin >> $GITHUB_PATH
- name: Restore buildcache
uses: actions/cache@v2
with: with:
key: macos-10.15-appleclang path: ${{env.BUILDCACHE_DIR}}
max-size: 1G key: buildcache-macos-10.15
- name: Configure CMake - name: Configure CMake
run: | run: |
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \ cmake -B build . -GNinja \
-DLLVM_ROOT_DIR=/opt/local/libexec/llvm-11 \ -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_OSX_ARCHITECTURES:STRING="x86_64;arm64" \
-DLLVM_ROOT_DIR:PATH=/opt/local/libexec/llvm-11 \
-DCMAKE_C_COMPILER_LAUNCHER:STRING=buildcache \
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=buildcache
- name: Build - name: Build
run: cmake --build build --target package --verbose run: cmake --build build --target package --verbose
- name: Print buildcache stats
run: buildcache -s
- name: Test - name: Test
working-directory: build working-directory: build
run: ./atdna-test run: ./atdna-test
@ -123,8 +162,11 @@ jobs:
build-win32-amd64: build-win32-amd64:
name: Build Windows (MSVC AMD64) name: Build Windows (MSVC AMD64)
runs-on: windows-2019 runs-on: windows-2019
env: env:
LLVM_VERSION: 10.0.1 LLVM_VERSION: 11.1.0
BUILDCACHE_DIR: C:\buildcache
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -133,28 +175,46 @@ jobs:
- name: Install LLVM - name: Install LLVM
run: | run: |
$TempDir = "$env:RUNNER_WORKSPACE\temp" $TempDir = "C:\temp" # C: has more space
$Filename = "LLVM-$env:LLVM_VERSION-win64.exe" $Filename = "vcpkg-llvm-$env:LLVM_VERSION-full.7z"
New-Item -Path "$TempDir" -ItemType Directory -ea 0 New-Item -Path "$TempDir" -ItemType Directory -ea 0
(New-Object Net.WebClient).DownloadFile("https://axiodl.com/files/$Filename", "$TempDir\$Filename") (New-Object Net.WebClient).DownloadFile("https://axiodl.com/files/$Filename", "$TempDir\$Filename")
Start-Process "$TempDir\$Filename" -ArgumentList "/S /D=$env:RUNNER_WORKSPACE\LLVM" -Wait 7z x "-o$TempDir" -aos "$TempDir\$Filename"
- name: Install dependencies - name: Install dependencies
run: choco install ninja run: |
choco install ninja
# set up buildcache
$TempDir = "$env:RUNNER_WORKSPACE\temp"
New-Item -Path "$TempDir" -ItemType Directory -ea 0
(New-Object Net.WebClient).DownloadFile("https://github.com/mbitsnbites/buildcache/releases/download/$env:BUILDCACHE_VERSION/buildcache-windows.zip", "$TempDir\buildcache.zip")
Expand-Archive -LiteralPath "$TempDir\buildcache.zip" -DestinationPath "$TempDir"
echo "$TempDir\buildcache\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Restore buildcache
uses: actions/cache@v2
with:
path: ${{env.BUILDCACHE_DIR}}
key: buildcache-windows-2019-msvc-amd64
- name: Enable Visual Studio environment - name: Enable Visual Studio environment
uses: ilammy/msvc-dev-cmd@v1 uses: ilammy/msvc-dev-cmd@v1
- name: Configure CMake - name: Configure CMake
run: | run: |
$workspace = $env:RUNNER_WORKSPACE -replace '\\', '/' cmake -B build . -GNinja `
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo ` -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo `
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ` -DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded `
-DLLVM_ROOT_DIR="$workspace/LLVM" -DCMAKE_TOOLCHAIN_FILE:PATH="C:\temp\vcpkg-llvm-$env:LLVM_VERSION\scripts\buildsystems\vcpkg.cmake" `
-DVCPKG_TARGET_TRIPLET:STRING=x64-windows-static
- name: Build - name: Build
run: cmake --build build --target package --verbose run: cmake --build build --target package --verbose
- name: Print buildcache stats
run: buildcache -s
- name: Test - name: Test
working-directory: build working-directory: build
run: ./atdna-test.exe run: ./atdna-test.exe
@ -169,6 +229,7 @@ jobs:
release: release:
name: Release name: Release
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
if: if:
contains(' contains('
refs/heads/master refs/heads/master

3
.gitignore vendored
View File

@ -21,4 +21,5 @@ PKGBUILD
/build /build
/out /out
/cmake-build-* /cmake-build-*
/.idea /.idea
/.buildcache

View File

@ -101,9 +101,11 @@ target_include_directories(atdna PRIVATE ${CLANG_INCLUDE_DIRS})
# Clang 10.0.x headers currently broken with C++20 # Clang 10.0.x headers currently broken with C++20
set_property(TARGET atdna PROPERTY CXX_STANDARD 17) set_property(TARGET atdna PROPERTY CXX_STANDARD 17)
if(MSVC) if(MSVC)
# Allow linking against release-built LLVM libraries if (NOT VCPKG_TOOLCHAIN)
target_compile_options(atdna PRIVATE /GR- /D_ITERATOR_DEBUG_LEVEL=0) # Allow linking against release-built LLVM libraries
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") target_compile_options(atdna PRIVATE /GR- /D_ITERATOR_DEBUG_LEVEL=0)
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif ()
else() else()
target_compile_options(atdna PRIVATE -fno-rtti -fvisibility=hidden -Wno-error) target_compile_options(atdna PRIVATE -fno-rtti -fvisibility=hidden -Wno-error)
endif() endif()