Skip to content

Commit

Permalink
Switch to llvm-mingw for faster Windows CI (status-im#5729)
Browse files Browse the repository at this point in the history
* Switch to llvm-mingw for faster Windows CI

* Enable ubsan of Windows CI
  • Loading branch information
jangko authored Jan 13, 2024
1 parent 00d05f8 commit a45609c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,42 @@ jobs:
- target:
os: linux
builder: ['self-hosted','ubuntu-22.04']
shell: bash
- target:
os: macos
builder: macos-11
shell: bash
- target:
os: windows
builder: windows-2019
shell: msys2 {0}

defaults:
run:
shell: ${{ matrix.shell }}
shell: bash

name: ${{ matrix.target.os }}-${{ matrix.target.cpu }}${{ matrix.branch != '' && ' (Nim ' || '' }}${{ matrix.branch-short }}${{ matrix.branch != '' && ')' || '' }}
runs-on: ${{ matrix.builder }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: MSYS2 (Windows amd64)
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
uses: msys2/setup-msys2@v2
- name: Restore llvm-mingw (Windows) from cache
if: runner.os == 'Windows'
id: windows-mingw-cache
uses: actions/cache@v3
with:
path-type: inherit
install: >-
base-devel
git
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
path: external/mingw-${{ matrix.target.cpu }}
key: 'mingw-llvm-17-${{ matrix.target.cpu }}'

- name: Install llvm-mingw dependency (Windows)
if: >
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
if: runner.os == 'Windows'
Expand All @@ -108,6 +114,7 @@ jobs:
if: >
runner.os == 'Windows'
run: |
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
# for miniupnp that runs "wingenminiupnpcstrings.exe" from the current dir
echo "." >> $GITHUB_PATH
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
# - Apache License, version 2.0
# - MIT license
Expand Down Expand Up @@ -775,7 +775,6 @@ libnimbus_lc.a: | build deps
echo -e $(BUILD_END_MSG) "build/$@"

# `-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
test_libnimbus_lc: libnimbus_lc.a
+ echo -e $(BUILD_MSG) "build/$@" && \
Expand All @@ -789,9 +788,9 @@ test_libnimbus_lc: libnimbus_lc.a
;; \
MINGW64_*) \
if (( $${WITH_UBSAN:-0} )); then \
echo "MINGW cannot find -lubsan." && exit 1; \
EXTRA_FLAGS+=('-fsanitize=undefined'); \
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 \
Expand Down

0 comments on commit a45609c

Please sign in to comment.