Skip to content

Commit f7ca987

Browse files
authored
Merge pull request #738 from ethereum/fix-windows-ci
Fix Windows CI build
2 parents f838735 + cc61a45 commit f7ca987

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

.github/scripts/install-libff.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ git checkout "v$INSTALL_VERSION" && git submodule init && git submodule update
2121
patch -p1 < ../.github/scripts/libff.patch
2222

2323
sed -i 's/find_library(GMP_LIBRARY gmp)/find_library(GMP_LIBRARY NAMES libgmp.a)/' CMakeLists.txt
24+
# This ends up causing the system headers to be included with -I and
25+
# thus they override the GHC mingw compiler ones. So this removes it
26+
# and re-adds the include with idirafter via the toolchain file
27+
sed -i '/INCLUDE_DIRECTORIES.*OPENSSL_INCLUDE_DIR/d' CMakeLists.txt
2428
PREFIX="$HOME/.local"
25-
ARGS=("-DCMAKE_INSTALL_PREFIX=$PREFIX" "-DWITH_PROCPS=OFF" "-G" "Ninja")
29+
ARGS=("-DCMAKE_INSTALL_PREFIX=$PREFIX" "-DWITH_PROCPS=OFF" "-G" "Ninja" "-DCMAKE_TOOLCHAIN_FILE=$PWD/../.github/scripts/windows-ghc-toolchain.cmake")
2630
CXXFLAGS="-fPIC"
2731

2832
mkdir -p build
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/build.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ jobs:
111111
echo FOUNDRY_PATH="$(dirname "$(which forge)")" >> "$GITHUB_ENV"
112112
shell: bash
113113
- uses: msys2/setup-msys2@v2
114+
id: msys2
114115
with:
115116
msystem: CLANG64
116117
path-type: minimal
@@ -141,11 +142,14 @@ jobs:
141142
run: |
142143
HASKELL_PATHS="$(cygpath -u "$GHC_PATH"):$(cygpath -u "$CABAL_PATH")"
143144
HASKELL_MINGW_PATH="$(cygpath -u "$GHC_PATH/../mingw")"
145+
SYSTEM_MINGW_PATH="$(cygpath -m "$MSYS2_LOCATION/$MSYSTEM")"
144146
echo "HASKELL_PATHS=$HASKELL_PATHS" >> "$GITHUB_ENV"
145147
echo "HASKELL_MINGW_PATH=$HASKELL_MINGW_PATH" >> "$GITHUB_ENV"
148+
echo "SYSTEM_MINGW_PATH=$SYSTEM_MINGW_PATH" >> "$GITHUB_ENV"
146149
env:
147150
GHC_PATH: ${{ steps.setup.outputs.ghc-path }}
148151
CABAL_PATH: ${{ steps.setup.outputs.cabal-path }}
152+
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
149153

150154
- name: build and install c dependencies
151155
run: |
@@ -160,11 +164,11 @@ jobs:
160164
run: |
161165
export PATH="$HASKELL_PATHS:$PATH"
162166
cabal configure --disable-documentation --enable-executable-static --enable-executable-stripping \
163-
--extra-include-dirs="$(cygpath -m "$HASKELL_MINGW_PATH/x86_64-w64-mingw32/include")" --extra-lib-dirs="$(cygpath -m "$HASKELL_MINGW_PATH/x86_64-w64-mingw32/lib")" \
164-
--extra-include-dirs="$(cygpath -m "$HASKELL_MINGW_PATH/include")" --extra-lib-dirs="$(cygpath -m "$HASKELL_MINGW_PATH/lib")" \
165-
--extra-include-dirs="D:/a/_temp/msys64/clang64/include" --extra-lib-dirs="D:/a/_temp/msys64/clang64/lib" \
167+
--extra-lib-dirs="$(cygpath -m "$HASKELL_MINGW_PATH/x86_64-w64-mingw32/lib")" \
168+
--extra-lib-dirs="$(cygpath -m "$HASKELL_MINGW_PATH/lib")" \
169+
--extra-lib-dirs="$SYSTEM_MINGW_PATH/lib" \
166170
--extra-include-dirs="$HOME/.local/include" --extra-lib-dirs="$HOME/.local/lib" \
167-
--ghc-options=-pgml="$(cygpath -m "$HASKELL_MINGW_PATH/bin/clang.exe")" -fstatic-secp256k1 --constraint="zlib +bundled-c-zlib"
171+
--ghc-options=-pgml="$(cygpath -m "$HASKELL_MINGW_PATH/bin/clang.exe") -optc-idirafter -optc$SYSTEM_MINGW_PATH/include -optcxx-idirafter -optcxx$SYSTEM_MINGW_PATH/include" -fstatic-secp256k1 --constraint="zlib +bundled-c-zlib"
168172
cabal build --dry-run
169173
# The last step generates dist-newstyle/cache/plan.json for the cache key.
170174

0 commit comments

Comments
 (0)