Skip to content

Commit

Permalink
Build CVC{4,5} natively on Windows
Browse files Browse the repository at this point in the history
Fixes #4.
  • Loading branch information
RyanGlScott committed Mar 11, 2023
1 parent d80c125 commit 63c282a
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 22 deletions.
43 changes: 27 additions & 16 deletions .github/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,23 @@ build_boolector() {

build_cvc4() {
pushd repos/CVC4-archived
./contrib/get-antlr-3.4
./contrib/get-symfpu
if $IS_WIN ; then
echo "Downloading pre-built CVC4 binary for Windows"
curl -o cvc4$EXT -sL "https://github.com/CVC4/CVC4/releases/download/1.8/cvc4-1.8-win64-opt.exe"
cp cvc4$EXT $BIN
# Backport changes from https://github.com/cvc5/cvc5/pull/7512 needed to
# build CVC4 natively on Windows.
patch -p1 -i $PATCHES/cvc4-win64-native.patch
# GitHub Actions comes preinstalled with Chocolatey's mingw package, which
# includes the ld.gold linker. This does not play nicely with MSYS2's
# mingw-w64-x86_64-gcc, so we must prevent CMake from using ld.gold.
patch -p1 -i $PATCHES/cvc4-no-ld-gold.patch
./configure.sh --static --static-binary --symfpu --win64-native production
else
./contrib/get-antlr-3.4
./contrib/get-symfpu
./configure.sh --static --no-static-binary --symfpu production
cd build
make -j4
cp bin/cvc4$EXT $BIN
fi
cd build
make -j4
cp bin/cvc4$EXT $BIN
(cd $BIN && ./cvc4$EXT --version && deps cvc4$EXT && ./cvc4$EXT $PROBLEM)
popd
cleanup_bins
Expand All @@ -82,17 +87,23 @@ build_cvc4() {
build_cvc5() {
pushd repos/cvc5
if $IS_WIN ; then
# TODO: Once https://github.com/cvc5/cvc5/pull/7512 lands, build a native
# Windows version of CVC5 instead.
echo "Downloading pre-built CVC5 binary for Windows"
curl -o cvc5$EXT -sL "https://github.com/cvc5/cvc5/releases/download/cvc5-1.0.2/cvc5-Win64.exe"
cp cvc5$EXT $BIN
# TODO RGS: File upstream issue about this
patch -p1 -i $PATCHES/cvc5-win64-native.patch
# GitHub Actions comes preinstalled with Chocolatey's mingw package, which
# includes the ld.gold linker. This does not play nicely with MSYS2's
# mingw-w64-x86_64-gcc, so we must prevent CMake from using ld.gold.
patch -p1 -i $PATCHES/cvc5-no-ld-gold.patch
# Why do we manually override Python_EXECUTABLE below? GitHub Actions comes
# with multiple versions of Python pre-installed, and for some bizarre
# reason, CMake always tries to pick the latest version, even if it is not
# on the PATH. Manually overriding this option avoids this oddity.
./configure.sh -DPython_EXECUTABLE=${pythonLocation}/python.exe --static --static-binary --auto-download --win64-native production
else
./configure.sh --static --no-static-binary --auto-download production
cd build
make -j4
cp bin/cvc5$EXT $BIN
fi
cd build
make -j4
cp bin/cvc5$EXT $BIN
(cd $BIN && ./cvc5$EXT --version && deps cvc5$EXT && ./cvc5$EXT $PROBLEM)
popd
cleanup_bins
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ jobs:
with:
update: true
msystem: MINGW64
path-type: inherit
install: |
autoconf
automake
curl
dos2unix
flex
git
gperf
lzip
Expand All @@ -59,19 +61,25 @@ jobs:
mingw-w64-x86_64-gcc
mingw-w64-x86_64-ninja
patch
python
tar
unzip
if: runner.os == 'Windows'

- uses: actions/setup-python@v2
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- uses: BSFishy/pip-action@v1
- name: Install Python libraries
run: |
python -m pip install --upgrade pip
pip install toml
- name: Install Java
uses: actions/setup-java@v3
with:
packages: |
toml
distribution: 'temurin'
java-version: '17'

- name: build_solver (non-Windows)
shell: bash
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Currently, `what4-solvers` offers the following solver versions:
* Boolector - [3.2.2](https://github.com/Boolector/boolector/tree/e7aba964f69cd52dbe509e46e818a4411b316cd3)
* CVC4 - [1.8](https://github.com/CVC4/CVC4-archived/tree/5247901077efbc7b9016ba35fded7a6ab459a379)
* CVC5 - [1.0.2](https://github.com/cvc5/cvc5/tree/ef35c1131976e5a3d981dace510d90aed2d11cef)
(TODO RGS: Change this)
* Yices - [2.6.2](https://github.com/SRI-CSL/yices2/tree/8509cfb5c294df3c0ac3a4814483f39c58879606)
* Z3 - [4.8.8](https://github.com/Z3Prover/z3/tree/ad55a1f1c617a7f0c3dd735c0780fc758424c7f1) and
[4.8.14](https://github.com/Z3Prover/z3/tree/df8f9d7dcb8b9f9b3de1072017b7c2b7f63f0af8)
Expand Down
24 changes: 24 additions & 0 deletions patches/cvc4-no-ld-gold.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e4d4aaeda..c604ba989 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -238,19 +238,6 @@ if (WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,100000000")
endif ()

-#-----------------------------------------------------------------------------#
-# Use ld.gold if available
-
-execute_process(COMMAND ${CMAKE_C_COMPILER}
- -fuse-ld=gold
- -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
-if ("${LD_VERSION}" MATCHES "GNU gold")
- string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold")
- string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold")
- string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold")
- message(STATUS "Using GNU gold linker.")
-endif ()
-
#-----------------------------------------------------------------------------#
# Option defaults (three-valued options (cvc4_option(...)))
#
82 changes: 82 additions & 0 deletions patches/cvc4-win64-native.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
diff --git a/configure.sh b/configure.sh
index 21a444082..8b30c8b14 100755
--- a/configure.sh
+++ b/configure.sh
@@ -23,6 +23,7 @@ General options;
--best turn on dependencies known to give best performance
--gpl permit GPL dependencies, if available
--win64 cross-compile for Windows 64 bit
+ --win64-native natively compile for Windows 64 bit
--ninja use Ninja build system


@@ -146,6 +147,7 @@ ubsan=default
unit_testing=default
valgrind=default
win64=default
+win64_native=default

language_bindings_java=default
language_bindings_python=default
@@ -238,6 +240,9 @@ do
--win64) win64=ON;;
--no-win64) win64=OFF;;

+ --win64-native) win64_native=ON;;
+ --no-win64-native) win64_native=OFF;;
+
--ninja) ninja=ON;;

--glpk) glpk=ON;;
@@ -387,6 +392,9 @@ cmake_opts=""
&& cmake_opts="$cmake_opts -DENABLE_GPL=$gpl"
[ $win64 != default ] \
&& cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake"
+# Because 'MSYS Makefiles' has a space in it, we set the variable vs. adding to 'cmake_opts'
+[ $win64_native != default ] \
+ && [ $ninja == default ] && export CMAKE_GENERATOR="MSYS Makefiles"
[ $ninja != default ] && cmake_opts="$cmake_opts -G Ninja"
[ $muzzle != default ] \
&& cmake_opts="$cmake_opts -DENABLE_MUZZLE=$muzzle"
diff --git a/src/expr/mkexpr b/src/expr/mkexpr
index c5f12f487..b47c66753 100755
--- a/src/expr/mkexpr
+++ b/src/expr/mkexpr
@@ -14,6 +14,9 @@
#
# Output is to standard out.
#
+# Required to disable this option for bash >=5.2 to avoid automatically
+# replacing & by the substituted text.
+shopt | grep -q '^patsub_replacement\b' && shopt -u patsub_replacement

copyright=2010-2014

diff --git a/src/expr/mkkind b/src/expr/mkkind
index fbf37eff4..aabc70afe 100755
--- a/src/expr/mkkind
+++ b/src/expr/mkkind
@@ -13,6 +13,9 @@
#
# Output is to standard out.
#
+# Required to disable this option for bash >=5.2 to avoid automatically
+# replacing & by the substituted text.
+shopt | grep -q '^patsub_replacement\b' && shopt -u patsub_replacement

copyright=2010-2014

diff --git a/src/expr/mkmetakind b/src/expr/mkmetakind
index e2a733ec8..e56d076d7 100755
--- a/src/expr/mkmetakind
+++ b/src/expr/mkmetakind
@@ -16,6 +16,9 @@
#
# Output is to standard out.
#
+# Required to disable this option for bash >=5.2 to avoid automatically
+# replacing & by the substituted text.
+shopt | grep -q '^patsub_replacement\b' && shopt -u patsub_replacement

copyright=2010-2014

24 changes: 24 additions & 0 deletions patches/cvc5-no-ld-gold.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bbd49612a..fb9b416f9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -229,19 +229,6 @@ if (WIN32)
add_check_c_cxx_flag("-Wno-error=unknown-pragmas")
endif ()

-#-----------------------------------------------------------------------------#
-# Use ld.gold if available
-
-execute_process(COMMAND ${CMAKE_C_COMPILER}
- -fuse-ld=gold
- -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
-if ("${LD_VERSION}" MATCHES "GNU gold")
- string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold")
- string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold")
- string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold")
- message(STATUS "Using GNU gold linker.")
-endif ()
-
#-----------------------------------------------------------------------------#
# Use interprocedural optimization if requested

20 changes: 20 additions & 0 deletions patches/cvc5-win64-native.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/parser/CMakeLists.txt b/src/parser/CMakeLists.txt
index 3ff605948..d9dd4b70d 100644
--- a/src/parser/CMakeLists.txt
+++ b/src/parser/CMakeLists.txt
@@ -107,15 +107,6 @@ flex_target(Lexer
${CMAKE_CURRENT_BINARY_DIR}/smt2/smt2_lexer.cpp)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/smt2/smt2_lexer.cpp PROPERTIES GENERATED TRUE)

-# The FlexLexer.h header is installed to /usr/include/, but is not found by the
-# cross-compilation environment. As a workaround we'll copy the header to the
-# current build directory and set the FLEX_INCLUDE_DIRS variable accordingly.
-if(WIN32)
- file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/flex)
- file(COPY /usr/include/FlexLexer.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/flex)
- set(FLEX_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/flex)
-endif()
-
# We don't want to enable -Wall for code generated by Flex.
set(gen_src_files ${CMAKE_CURRENT_BINARY_DIR}/smt2/smt2_lexer.cpp)
set(GEN_SRC_FLAGS "")
2 changes: 1 addition & 1 deletion repos/cvc5
Submodule cvc5 updated 1042 files

0 comments on commit 63c282a

Please sign in to comment.