From 883b7a1c8efeecf271426a8b81f0d6c7315e29fa Mon Sep 17 00:00:00 2001 From: Philipp Remy Date: Wed, 18 Mar 2026 18:04:50 +0100 Subject: [PATCH 1/3] [CI] Test legacy libraries with static and shared linkage Signed-off-by: Philipp Remy --- .github/workflows/ci.yml | 54 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0750f95e63..578fb5e527 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -603,7 +603,7 @@ jobs: cmake --build . ctest --output-on-failure --no-tests=error - posix-cmake-install-legacy: + posix-cmake-install-legacy-static: strategy: fail-fast: false matrix: @@ -655,6 +655,58 @@ jobs: cmake --build . ctest --output-on-failure --no-tests=error + posix-cmake-install-legacy-shared: + strategy: + fail-fast: false + matrix: + include: + - os: macos-15 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v4 + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + mkdir -p libs/$LIBRARY + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBOOST_MATH_BUILD_WITH_LEGACY_FUNCTIONS=ON -DCMAKE_INSTALL_PREFIX=~/.local -DBUILD_SHARED_LIBS=ON .. + + - name: Install + run: | + cd ../boost-root/__build__ + cmake --build . --target install + + - name: Use the installed library (legacy compiled) + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_install_test_legacy + mkdir __build__ && cd __build__ + cmake -DCMAKE_INSTALL_PREFIX=~/.local .. + cmake --build . + ctest --output-on-failure --no-tests=error + sycl-cmake-test: strategy: fail-fast: false From 4aaeeacdbbfeee26ad0c3bb31d80c46ee1c382f0 Mon Sep 17 00:00:00 2001 From: Philipp Remy Date: Wed, 18 Mar 2026 18:07:56 +0100 Subject: [PATCH 2/3] [legacy] Allow building the legacy libraries in standalone mode Signed-off-by: Philipp Remy --- CMakeLists.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2d6c055d3..2b9f1b949b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,11 +52,12 @@ option(BOOST_MATH_BUILD_WITH_LEGACY_FUNCTIONS "Build the C99 and TR1 compiled li if(BOOST_MATH_BUILD_WITH_LEGACY_FUNCTIONS) include(CheckCXXSourceCompiles) -get_target_property(_config_type Boost::config TYPE) -if(_config_type STREQUAL "INTERFACE_LIBRARY") - get_target_property(_config_inc Boost::config INTERFACE_INCLUDE_DIRECTORIES) -else() - set(_config_inc "") +set(_config_inc "") +if(NOT BOOST_MATH_STANDALONE) + get_target_property(_config_type Boost::config TYPE) + if(_config_type STREQUAL "INTERFACE_LIBRARY") + get_target_property(_config_inc Boost::config INTERFACE_INCLUDE_DIRECTORIES) + endif() endif() set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include" ${_config_inc}) check_cxx_source_compiles("#include <${CMAKE_CURRENT_SOURCE_DIR}/config/has_long_double_support.cpp> \n int main() { return 0;}" BOOST_MATH_HAS_LONG_DOUBLE) @@ -130,13 +131,17 @@ list(TRANSFORM TR1_SOURCES APPEND ".cpp") foreach(type IN LISTS types) add_library(boost_math_tr1${type} ${TR1_SOURCES${type}}) add_library(Boost::math_tr1${type} ALIAS boost_math_tr1${type}) - target_link_libraries(boost_math_tr1${type} PUBLIC Boost::config) + if(NOT BOOST_MATH_STANDALONE) + target_link_libraries(boost_math_tr1${type} PUBLIC Boost::config) + endif() target_include_directories(boost_math_tr1${type} PRIVATE src/tr1) target_include_directories(boost_math_tr1${type} PRIVATE include) add_library(boost_math_c99${type} ${C99_SOURCES${type}}) add_library(Boost::math_c99${type} ALIAS boost_math_c99${type}) - target_link_libraries(boost_math_c99${type} PUBLIC Boost::config) + if(NOT BOOST_MATH_STANDALONE) + target_link_libraries(boost_math_c99${type} PUBLIC Boost::config) + endif() target_include_directories(boost_math_c99${type} PRIVATE src/tr1) target_include_directories(boost_math_c99${type} PRIVATE include) From b1523d96b132f11a3dfd72683fe0fd9ac0e29c01 Mon Sep 17 00:00:00 2001 From: Philipp Remy Date: Wed, 18 Mar 2026 18:09:00 +0100 Subject: [PATCH 3/3] [legacy] Handle MinGW and fix build with shared linkage (1) Change MSVC to WIN32: The symbol export rules should also apply if a MinGW toolchain is used. (2) On targets other than MSVC, a build with BUILD_SHARED_LIBS=ON failed because the macro BOOST_SYMBOL_EXPORT was not properly defined. Define it to default visibility for proper symbol export in shared libraries. Signed-off-by: Philipp Remy --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b9f1b949b..7d5f6d270b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,9 +148,12 @@ foreach(type IN LISTS types) if(BUILD_SHARED_LIBS) target_compile_definitions(boost_math_tr1${type} PUBLIC BOOST_MATH_TR1_DYN_LINK=1) target_compile_definitions(boost_math_c99${type} PUBLIC BOOST_MATH_TR1_DYN_LINK=1) - if(MSVC) + if(WIN32) target_compile_definitions(boost_math_tr1${type} PRIVATE "BOOST_SYMBOL_EXPORT=__declspec(dllexport)" BOOST_ALL_NO_LIB) target_compile_definitions(boost_math_c99${type} PRIVATE "BOOST_SYMBOL_EXPORT=__declspec(dllexport)" BOOST_ALL_NO_LIB) + else() + target_compile_definitions(boost_math_tr1${type} PRIVATE "BOOST_SYMBOL_EXPORT=__attribute__((visibility(\"default\")))" BOOST_ALL_NO_LIB) + target_compile_definitions(boost_math_c99${type} PRIVATE "BOOST_SYMBOL_EXPORT=__attribute__((visibility(\"default\")))" BOOST_ALL_NO_LIB) endif() endif()