From 189098d0922d1280c3d060d18cadba26eb887b73 Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Tue, 23 Jul 2024 17:35:39 +0100 Subject: [PATCH] fix: Static linkage (#1551) Fixes #1507 --- .github/workflows/nightly.yml | 4 ++++ src/main/CMakeLists.txt | 14 ++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4328f9abf..1d46ac2ce 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -13,12 +13,15 @@ jobs: include: - os: macos14 build_type: Release + static: false - os: heavy build_type: Release + static: true container: image: rippleci/clio_ci:latest - os: heavy build_type: Debug + static: true container: image: rippleci/clio_ci:latest runs-on: [self-hosted, "${{ matrix.os }}"] @@ -50,6 +53,7 @@ jobs: conan_profile: ${{ steps.conan.outputs.conan_profile }} conan_cache_hit: ${{ steps.restore_cache.outputs.conan_cache_hit }} build_type: ${{ matrix.build_type }} + static: ${{ matrix.static }} - name: Build Clio uses: ./.github/actions/build_clio diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index f60fae5ff..e8a701acc 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -11,18 +11,16 @@ target_sources(clio_server PRIVATE Main.cpp) target_link_libraries(clio_server PRIVATE clio) if (static) - target_link_options(clio_server PRIVATE -static) - - if (is_gcc AND NOT san) + if (san) + message(FATAL_ERROR "Static linkage not allowed when using sanitizers") + elseif (is_appleclang) + message(FATAL_ERROR "Static linkage not supported on AppleClang") + else () target_link_options( - # For now let's assume that we only using libstdc++ under gcc. + # Note: -static-libstdc++ can statically link both libstdc++ and libc++ clio_server PRIVATE -static-libstdc++ -static-libgcc ) endif () - - if (is_appleclang) - message(FATAL_ERROR "Static linkage not supported on AppleClang") - endif () endif () set_target_properties(clio_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})