From 3e98be42bca89a10119352d190af7584bab2f39f Mon Sep 17 00:00:00 2001 From: Gereon Kremer Date: Wed, 6 Oct 2021 09:27:33 -0700 Subject: [PATCH] Enable static builds in CI (#7281) This PR modifies our CI builds to have two static production builds. These binaries will be used as release artifacts later. --- .github/workflows/ci.yml | 8 +++++--- INSTALL.rst | 11 +++++++---- cmake/deps-helper.cmake | 5 ++--- src/main/CMakeLists.txt | 8 +++++--- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c7c4ed23..6cea1122f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: include: - name: ubuntu:production os: ubuntu-latest - config: production --auto-download --all-bindings --editline --docs + config: production --auto-download --all-bindings --editline --docs --static-binary cache-key: production python-bindings: true build-documentation: true @@ -18,7 +18,7 @@ jobs: - name: macos:production os: macos-11 - config: production --auto-download --all-bindings --editline + config: production --auto-download --all-bindings --editline --static-binary cache-key: production python-bindings: true check-examples: true @@ -64,10 +64,12 @@ jobs: sudo apt-get install -y \ build-essential \ ccache \ + libbsd-dev \ libcln-dev \ + libedit-dev \ libgmp-dev \ libgtest-dev \ - libedit-dev \ + libtinfo-dev \ flex \ libfl-dev \ flexc++ diff --git a/INSTALL.rst b/INSTALL.rst index 99626a554..7df21cb4c 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -31,8 +31,11 @@ Compilation on macOS On macOS, we recommend using `Homebrew `_ to install the dependencies. We also have a Homebrew Tap available at https://github.com/CVC4/homebrew-cvc4 . -To build a static binary for macOS, use: -``./configure.sh --static --no-static-binary``. +Note that linking system libraries statically is +`strongly discouraged `_ +on macOS. Using ``./configure.sh --static-binary`` will thus produce a binary +that uses static versions of all our dependencies, but is still a dynamically +linked binary. Cross-compiling for Windows @@ -42,7 +45,7 @@ Cross-compiling cvc5 with Mingw-w64 can be done as follows: .. code:: bash - ./configure.sh --win64 --static + ./configure.sh --win64 --static-binary cd # default is ./build make # use -jN for parallel build with N threads @@ -428,6 +431,6 @@ linked LGPL libraries perform the following steps: .. code:: - ./configure.sh --static + ./configure.sh --static-binary 7. Follow remaining steps from `build instructions <#building-cvc5>`_ diff --git a/cmake/deps-helper.cmake b/cmake/deps-helper.cmake index f2a43c028..9a92928b6 100644 --- a/cmake/deps-helper.cmake +++ b/cmake/deps-helper.cmake @@ -40,7 +40,6 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.14") endif() macro(force_static_library) - message(STATUS "before: ${CMAKE_FIND_LIBRARY_SUFFIXES}") if (WIN32) set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a) else() @@ -50,9 +49,9 @@ endmacro(force_static_library) macro(reset_force_static_library) if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .dll) + set(CMAKE_FIND_LIBRARY_SUFFIXES .dll .lib) else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .so .dylib) + set(CMAKE_FIND_LIBRARY_SUFFIXES .so .dylib .a) endif() endmacro(reset_force_static_library) diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 4d528312e..1aedcb265 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -78,9 +78,11 @@ endif() # https://cmake.org/cmake/help/v3.0/prop_tgt/LINK_SEARCH_START_STATIC.html # https://cmake.org/cmake/help/v3.0/prop_tgt/LINK_SEARCH_END_STATIC.html if(ENABLE_STATIC_BINARY) - set_target_properties(cvc5-bin PROPERTIES LINK_FLAGS -static) - set_target_properties(cvc5-bin PROPERTIES LINK_SEARCH_START_STATIC ON) - set_target_properties(cvc5-bin PROPERTIES LINK_SEARCH_END_STATIC ON) + if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set_target_properties(cvc5-bin PROPERTIES LINK_FLAGS -static) + set_target_properties(cvc5-bin PROPERTIES LINK_SEARCH_START_STATIC ON) + set_target_properties(cvc5-bin PROPERTIES LINK_SEARCH_END_STATIC ON) + endif() endif() if(USE_EDITLINE) -- 2.30.2