Skip to content

Commit 4dcd863

Browse files
committed
ci: fix Windows builds
Equivalent of argotorg/hevm#738
1 parent ec6cc7e commit 4dcd863

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

.github/scripts/install-libff.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ if [ "$HOST_OS" = "Linux" ] && [ "$(uname -m)" = "aarch64" ]; then
3535
fi
3636

3737
if [ "$HOST_OS" = "Windows" ]; then
38-
ARGS+=("-G" "Ninja")
38+
ARGS+=("-G" "Ninja" "-DCMAKE_TOOLCHAIN_FILE=$PWD/../.github/scripts/windows-ghc-toolchain.cmake")
3939
sed -i 's/find_library(GMP_LIBRARY gmp)/find_library(GMP_LIBRARY NAMES libgmp.a)/' CMakeLists.txt
4040

41+
# This ends up causing the system headers to be included with -I and
42+
# thus they override the GHC mingw compiler ones. So this removes it
43+
# and re-adds the include with idirafter via the toolchain file
44+
sed -i '/INCLUDE_DIRECTORIES.*OPENSSL_INCLUDE_DIR/d' CMakeLists.txt
45+
4146
# Apply windows-specific libff patch carried by hevm
4247
curl -fsSL https://raw.githubusercontent.com/ethereum/hevm/1abe4c79eeada928acc279b631c48eeb2a1376c2/.github/scripts/libff.patch | patch -p1
4348
fi
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(CMAKE_SYSTEM_NAME Windows)
2+
3+
set(CMAKE_C_COMPILER "$ENV{HASKELL_MINGW_PATH}/bin/cc.exe")
4+
set(CMAKE_CXX_COMPILER "$ENV{HASKELL_MINGW_PATH}/bin/c++.exe")
5+
6+
set(CMAKE_C_FLAGS "-idirafter $ENV{SYSTEM_MINGW_PATH}/include")
7+
set(CMAKE_CXX_FLAGS "-idirafter $ENV{SYSTEM_MINGW_PATH}/include")
8+
9+
set(CMAKE_FIND_ROOT_PATH "$ENV{HASKELL_MINGW_PATH}")
10+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
11+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
12+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
- name: Get Packages (Windows)
4141
uses: msys2/setup-msys2@v2
4242
if: runner.os == 'Windows'
43+
id: msys2
4344
with:
4445
msystem: CLANG64
4546
path-type: minimal
@@ -104,11 +105,16 @@ jobs:
104105
if: runner.os == 'Windows'
105106
run: |
106107
HASKELL_PATHS="$(cygpath -u "$GHC_PATH"):$(cygpath -u "$CABAL_PATH"):$(cygpath -u "$STACK_PATH")"
108+
HASKELL_MINGW_PATH="$(cygpath -u "$GHC_PATH/../mingw")"
109+
SYSTEM_MINGW_PATH="$(cygpath -m "$MSYS2_LOCATION/$MSYSTEM")"
107110
echo "HASKELL_PATHS=$HASKELL_PATHS" >> "$GITHUB_ENV"
111+
echo "HASKELL_MINGW_PATH=$HASKELL_MINGW_PATH" >> "$GITHUB_ENV"
112+
echo "SYSTEM_MINGW_PATH=$SYSTEM_MINGW_PATH" >> "$GITHUB_ENV"
108113
env:
109114
GHC_PATH: ${{ steps.stack.outputs.ghc-path }}
110115
CABAL_PATH: ${{ steps.stack.outputs.cabal-path }}
111116
STACK_PATH: ${{ steps.stack.outputs.stack-path }}
117+
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
112118

113119
- name: Checkout
114120
uses: actions/checkout@v4
@@ -140,7 +146,7 @@ jobs:
140146
- name: Build Libraries
141147
run: |
142148
if [ "$HOST_OS" = "Windows" ]; then
143-
export PATH="$(cygpath -u "$GHC_BIN_PATH/../mingw/bin"):$PATH"
149+
export PATH="$(cygpath -u "$HASKELL_MINGW_PATH/bin"):$PATH"
144150
fi
145151
.github/scripts/install-libsecp256k1.sh
146152
.github/scripts/install-libff.sh

0 commit comments

Comments
 (0)