Switch to llvm-mingw for faster Windows CI (#5729)

* Switch to llvm-mingw for faster Windows CI

* Enable ubsan of Windows CI
This commit is contained in:
andri lim 2024-01-13 16:45:20 +07:00 committed by GitHub
parent 00d05f8170
commit a45609c4a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 17 deletions

View File

@ -56,19 +56,16 @@ jobs:
- target: - target:
os: linux os: linux
builder: ['self-hosted','ubuntu-22.04'] builder: ['self-hosted','ubuntu-22.04']
shell: bash
- target: - target:
os: macos os: macos
builder: macos-11 builder: macos-11
shell: bash
- target: - target:
os: windows os: windows
builder: windows-2019 builder: windows-2019
shell: msys2 {0}
defaults: defaults:
run: run:
shell: ${{ matrix.shell }} shell: bash
name: ${{ matrix.target.os }}-${{ matrix.target.cpu }}${{ matrix.branch != '' && ' (Nim ' || '' }}${{ matrix.branch-short }}${{ matrix.branch != '' && ')' || '' }} name: ${{ matrix.target.os }}-${{ matrix.target.cpu }}${{ matrix.branch != '' && ' (Nim ' || '' }}${{ matrix.branch-short }}${{ matrix.branch != '' && ')' || '' }}
runs-on: ${{ matrix.builder }} runs-on: ${{ matrix.builder }}
@ -76,16 +73,25 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: MSYS2 (Windows amd64) - name: Restore llvm-mingw (Windows) from cache
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64' if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2 id: windows-mingw-cache
uses: actions/cache@v3
with: with:
path-type: inherit path: external/mingw-${{ matrix.target.cpu }}
install: >- key: 'mingw-llvm-17-${{ matrix.target.cpu }}'
base-devel
git - name: Install llvm-mingw dependency (Windows)
mingw-w64-x86_64-toolchain if: >
mingw-w64-x86_64-cmake steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
mkdir -p external
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905"
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-x86_64.zip"
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip"
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }}
- name: Restore Nim DLLs dependencies (Windows) from cache - name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows' if: runner.os == 'Windows'
@ -108,6 +114,7 @@ jobs:
if: > if: >
runner.os == 'Windows' runner.os == 'Windows'
run: | run: |
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
# for miniupnp that runs "wingenminiupnpcstrings.exe" from the current dir # for miniupnp that runs "wingenminiupnpcstrings.exe" from the current dir
echo "." >> $GITHUB_PATH echo "." >> $GITHUB_PATH

View File

@ -1,4 +1,4 @@
# Copyright (c) 2019-2023 Status Research & Development GmbH. Licensed under # Copyright (c) 2019-2024 Status Research & Development GmbH. Licensed under
# either of: # either of:
# - Apache License, version 2.0 # - Apache License, version 2.0
# - MIT license # - MIT license
@ -775,7 +775,6 @@ libnimbus_lc.a: | build deps
echo -e $(BUILD_END_MSG) "build/$@" echo -e $(BUILD_END_MSG) "build/$@"
# `-Wno-maybe-uninitialized` in Linux: https://github.com/nim-lang/Nim/issues/22246 # `-Wno-maybe-uninitialized` in Linux: https://github.com/nim-lang/Nim/issues/22246
# `-fsanitize=undefined` in Windows: https://github.com/msys2/MINGW-packages/issues/3163
# `-Wl,--stack,0x0000000000800000` in Windows: MinGW default of 2 MB leads to `SIGSEGV` in `___chkstk_ms` in Nim 2.0 # `-Wl,--stack,0x0000000000800000` in Windows: MinGW default of 2 MB leads to `SIGSEGV` in `___chkstk_ms` in Nim 2.0
test_libnimbus_lc: libnimbus_lc.a test_libnimbus_lc: libnimbus_lc.a
+ echo -e $(BUILD_MSG) "build/$@" && \ + echo -e $(BUILD_MSG) "build/$@" && \
@ -789,9 +788,9 @@ test_libnimbus_lc: libnimbus_lc.a
;; \ ;; \
MINGW64_*) \ MINGW64_*) \
if (( $${WITH_UBSAN:-0} )); then \ if (( $${WITH_UBSAN:-0} )); then \
echo "MINGW cannot find -lubsan." && exit 1; \ EXTRA_FLAGS+=('-fsanitize=undefined'); \
fi; \ fi; \
gcc -D__DIR__="\"beacon_chain/libnimbus_lc\"" --std=c17 -Wall -Wextra -pedantic -Werror -pedantic-errors -flto -Wl,--stack,0x0000000000800000 -o build/test_libnimbus_lc -D_CRT_SECURE_NO_WARNINGS beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a "$${EXTRA_FLAGS[@]}"; \ gcc -D__DIR__="\"beacon_chain/libnimbus_lc\"" --std=c17 -Wall -Wextra -pedantic -Werror -pedantic-errors -flto -Wno-nullability-extension -Wl,--stack,0x0000000000800000 -o build/test_libnimbus_lc -D_CRT_SECURE_NO_WARNINGS beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a "$${EXTRA_FLAGS[@]}"; \
;; \ ;; \
*) \ *) \
if (( $${WITH_UBSAN:-0} )); then \ if (( $${WITH_UBSAN:-0} )); then \