Skip to content

Commit

Permalink
Add Windows llvm debug build
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbarton committed Dec 16, 2024
1 parent 693b1bd commit 20a7117
Showing 1 changed file with 105 additions and 18 deletions.
123 changes: 105 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ jobs:
compiler: msvc
clang-runtime: '18'

- name: win2022-msvc-runtime18-debug
os: windows-2022
compiler: clang
clang-runtime: '18'
debug_build: true

- name: ubu22-clang15-runtime16-debug
os: ubuntu-22.04
compiler: clang-15
Expand Down Expand Up @@ -493,12 +499,26 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Save PR Info
if: ${{ matrix.coverage == true }}
- name: Save PR Info on Unix systems
if: ${{ runner.os != 'windows' }}
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
echo ${{ github.repository }} > ./pr/REPO
export LLVM_HASH=$(git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x | tr '\t' '-')
echo "LLVM_HASH=$LLVM_HASH" >> $GITHUB_ENV
- name: Save PR Info on Windows systems
if: ${{ runner.os == 'windows' }}
run: |
#can be found
mkdir ./pr
echo "${{ github.event.number }}" > ./pr/NR
echo ${{ github.repository }} > ./pr/REPO
$env:LLVM_HASH_TEMP = (git ls-remote https://github.com/llvm/llvm-project.git refs/heads/release/${{ matrix.clang-runtime}}.x )
$env:LLVM_HASH = $env:LLVM_HASH_TEMP -replace "\t","-"
echo "LLVM_HASH=$env:LLVM_HASH" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
if: ${{ matrix.coverage == true }}
with:
Expand All @@ -511,17 +531,32 @@ jobs:
run: |
echo "BUILD_TYPE=Release" >> $GITHUB_ENV
echo "CLAD_CODE_COVERAGE=0" >> $GITHUB_ENV
if [[ "${os}" == "macos"* ]]; then
echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
else
echo "ncpus=$(nproc --all)" >> $GITHUB_ENV
fi
- name: Setup default Build Type on *nux (build_debug & asserts)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') }}
run: |
echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
if [[ "${os}" == "macos"* ]]; then
echo "ncpus=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
else
echo "ncpus=$(nproc --all)" >> $GITHUB_ENV
fi
- name: Setup default Build Type on Windows
if: runner.os == 'windows'
run: |
$env:BUILD_TYPE="Release"
$env:CLAD_CODE_COVERAGE="0"
echo "BUILD_TYPE=Release" >> $env:GITHUB_ENV
echo "CLAD_CODE_COVERAGE=0" >> $env:GITHUB_ENV
$env:ncpus=$([Environment]::ProcessorCount)
echo "ncpus=$env:ncpus" >> $env:GITHUB_ENV
- name: Download Coverity Build Tool - Linux
if: ${{ (matrix.coverity == true) && (runner.os == 'Linux') }}
run: |
Expand Down Expand Up @@ -594,10 +629,10 @@ jobs:
echo "PATH_TO_LLVM_BUILD=$env:PATH_TO_LLVM_BUILD" >> $env:GITHUB_ENV
clang --version
#
$env:CC="clang"
$env:CXX="clang++"
echo "CC=clang" >> $env:GITHUB_ENV
echo "CXX=clang++" >> $env:GITHUB_ENV
$env:CC="clang-cl"
$env:CXX="clang-cl"
echo "CC=clang-cl" >> $env:GITHUB_ENV
echo "CXX=clang-cl" >> $env:GITHUB_ENV
}
elseif ( "${{ matrix.compiler }}" -imatch "msvc" )
{
Expand All @@ -608,7 +643,7 @@ jobs:
echo "Unsupported compiler - fix YAML file"
}
- name: Setup LLVM/Clang on macOS
if: runner.os == 'macOS'
if: ${{ runner.os == 'macOS' && (matrix.debug_build != true) }}
run: |
#brew update
brew install --ignore-dependencies llvm
Expand Down Expand Up @@ -666,14 +701,23 @@ jobs:
# We need PATH_TO_LLVM_BUILD later
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD" >> $GITHUB_ENV
- name: Install deps on Windows
if: ${{ runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' && matrix.debug_build == true }}
run: |
choco install ninja findutils
choco upgrade cmake
$env:PATH="C:\Program Files (x86)\GnuWin32\bin;$env:PATH"
$env:PATH="C:\Program Files (x86)\Ninja\bin;$env:PATH"
- name: Restore Cache LLVM/Clang runtime build directory (debug_build==true)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') }}
if: ${{ (matrix.debug_build == true) }}
uses: actions/cache/restore@v4
id: cache
with:
path: |
llvm-project
key: ${{ matrix.os }}-clang-${{ matrix.clang-runtime }}.x-${{ env.BUILD_TYPE }}
key: ${{ env.LLVM_HASH }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}.x

- name: Build LLVM/Cling on Unix if the cache is invalid (debug_build==true)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') && (steps.cache.outputs.cache-hit != 'true') }}
run: |
Expand All @@ -683,7 +727,6 @@ jobs:
# Build
mkdir build
cd build
export CPU_COUNT="$(nproc --all)"
cmake \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
Expand All @@ -699,15 +742,43 @@ jobs:
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
../llvm
cmake --build . --target clang FileCheck llvm-config clang-repl --parallel ${CPU_COUNT}
cmake --build . --target clang FileCheck llvm-config clang-repl --parallel ${{ env.ncpus }}
cd ../../
- name: Build LLVM/Cling on Windows systems if the cache is invalid
if: ${{ (matrix.debug_build == true) && runner.os == 'windows' && steps.cache.outputs.cache-hit != 'true' }}
run: |
git clone --depth=1 -b llvm-export-api-18.0 https://github.com/fsfod/llvm-project.git
cd llvm-project
cmake -S ./llvm/ -B build -G Ninja `
-DCMAKE_ASM_MASM_FLAGS="-m64" `
-DLLVM_ENABLE_PROJECTS="clang" `
-DLLVM_ENABLE_PLUGINS=On `
-DLLVM_TARGETS_TO_BUILD="host" `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_CXX_COMPILER=clang-cl `
-DCMAKE_C_COMPILER=clang-cl `
-DCMAKE_ASM_MASM_COMPILER=llvm-ml `
-DLLVM_BUILD_LLVM_DYLIB_VIS=On `
-DLLVM_LINK_LLVM_DYLIB=On `
-DCLANG_LINK_CLANG_DYLIB=On
cmake --build build --config RelWithDebInfo --parallel ${{ env.ncpus }}
rm -r -force $(find.exe . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".")
cd .\llvm\
rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ..\clang\
rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ..\..
- name: Save Cache LLVM/Clang runtime build directory (debug_build==true)
uses: actions/cache/save@v4
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') && (steps.cache.outputs.cache-hit != 'true') }}
if: ${{ (matrix.debug_build == true) && (steps.cache.outputs.cache-hit != 'true') }}
with:
path: |
llvm-project
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Set LLVM/Cling build path on Unix (debug_build==true)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') }}
run: |
Expand Down Expand Up @@ -739,8 +810,9 @@ jobs:
pip3 install lit # LLVM lit is not part of the llvm releases...
# We need PATH_TO_LLVM_BUILD later
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD" >> $GITHUB_ENV
- name: Setup LLVM/Clang on Windows
if: ${{ runner.os == 'windows' }}
if: ${{ runner.os == 'windows' && (matrix.debug_build != true) }}
run: |
C:\Miniconda\condabin\conda.bat install -y -c conda-forge "clangdev=${{ matrix.clang-runtime }}"
$env:PATH_TO_LLVM_BUILD="$env:CONDA\Library"
Expand Down Expand Up @@ -821,7 +893,7 @@ jobs:
if: ${{ matrix.coverity == false && runner.os == 'windows' }}
run: |
mkdir obj
cd obj
cd obj
if ( "$env:BUILD_TYPE" -eq "" )
{
$env:BUILD_TYPE="RelWithDebInfo"
Expand All @@ -830,10 +902,25 @@ jobs:
{
$env:CLAD_CODE_COVERAGE="0"
}
((Get-Content -path C:/Miniconda/Library/lib/cmake/llvm/LLVMConfig.cmake -Raw) -replace 'LLVM_ENABLE_DIA_SDK ON','LLVM_ENABLE_DIA_SDK OFF') | Set-Content -Path C:/Miniconda/Library/lib/cmake/llvm/LLVMConfig.cmake
$lit = @(which lit)
cmake -DClang_DIR="$env:PATH_TO_LLVM_BUILD" -DLLVM_DIR="$env:PATH_TO_LLVM_BUILD" -DCMAKE_BUILD_TYPE="$env:BUILD_TYPE" -DCLAD_CODE_COVERAGE="$env:CLAD_CODE_COVERAGE" -DCLAD_BUILD_STATIC_ONLY="ON" -DLLVM_EXTERNAL_LIT="$lit" "$env:GITHUB_WORKSPACE" ${{ matrix.extra_cmake_options }}
cmake --build . --config Release
if ( "${{ matrix.debug_build }}" -imatch "true" )
{
((Get-Content -path $env:GITHUB_WORKSPACE/llvm-project/build/lib/cmake/llvm/LLVMConfig.cmake -Raw) -replace 'LLVM_ENABLE_DIA_SDK ON','LLVM_ENABLE_DIA_SDK OFF') | Set-Content -Path $env:GITHUB_WORKSPACE/llvm-project/build/lib/cmake/llvm/LLVMConfig.cmake
$env:PATH_TO_LLVM_BUILD="$env:GITHUB_WORKSPACE\llvm-project\build"
echo "PATH_TO_LLVM_BUILD=$env:PATH_TO_LLVM_BUILD"
echo "PATH_TO_LLVM_BUILD=$env:PATH_TO_LLVM_BUILD" >> $env:GITHUB_ENV
$lit = @(which lit)
cmake -G Ninja -DCMAKE_BUILD_TYPE="$env:BUILD_TYPE" -DClang_DIR="$env:PATH_TO_LLVM_BUILD" -DLLVM_DIR="$env:PATH_TO_LLVM_BUILD" -DLLVM_BUILD_LLVM_DYLIB_VIS=On -DLLVM_LINK_LLVM_DYLIB=On -DCLANG_LINK_CLANG_DYLIB=On -DCLAD_CODE_COVERAGE="$env:CLAD_CODE_COVERAGE" -DCLAD_BUILD_STATIC_ONLY="ON" -DLLVM_EXTERNAL_LIT="$lit" "$env:GITHUB_WORKSPACE" ${{ matrix.extra_cmake_options }}
cmake --build . --config "$env:BUILD_TYPE" --parallel ${{ env.ncpus }}
}
else
{
((Get-Content -path C:/Miniconda/Library/lib/cmake/llvm/LLVMConfig.cmake -Raw) -replace 'LLVM_ENABLE_DIA_SDK ON','LLVM_ENABLE_DIA_SDK OFF') | Set-Content -Path C:/Miniconda/Library/lib/cmake/llvm/LLVMConfig.cmake
$lit = @(which lit)
cmake -DClang_DIR="$env:PATH_TO_LLVM_BUILD" -DLLVM_DIR="$env:PATH_TO_LLVM_BUILD" -DCMAKE_BUILD_TYPE="$env:BUILD_TYPE" -DCLAD_CODE_COVERAGE="$env:CLAD_CODE_COVERAGE" -DCLAD_BUILD_STATIC_ONLY="ON" -DLLVM_EXTERNAL_LIT="$lit" "$env:GITHUB_WORKSPACE" ${{ matrix.extra_cmake_options }}
cmake --build . --config Release --parallel ${{ env.ncpus }}
}
- name: Build Clad for Coverity Scan
if: ${{ matrix.coverity == true }}
run: |
Expand Down

0 comments on commit 20a7117

Please sign in to comment.