Skip to content

[FIX] Legacy libraries with shared linkage#1382

Merged
mborland merged 3 commits intoboostorg:developfrom
philippremy:develop
Mar 18, 2026
Merged

[FIX] Legacy libraries with shared linkage#1382
mborland merged 3 commits intoboostorg:developfrom
philippremy:develop

Conversation

@philippremy
Copy link
Contributor

Hi!

Thank you again for adding the legacy modules to CMake. I noticed a small issue when trying it out: Compiling the legacy modules as shared libraries failed on my macOS machine, because the BOOST_SYMBOL_EXPORT macro was not defined properly. The fix is as simple as (just like with MSVC) explicitly setting the export visibility to "default". It seems that Boost and CMake default to hidden visibility, so in order for the shared library to expose the symbols correctly this must be adapted accordingly. I also changed the if(MSVC) to if(WIN32), which makes it compatible with MinGW based toolchains as well.

I also added a CI workflow for the shared libraries (it just mirrors the one for the static linkage).

And theoretically it should also be possible to compile the legacy libraries in standalone mode, so I guarded any Boost::config logic behind the appropriate flag.

If any of these changes (or all of them) are not wanted / not fitting the project, feel free to cherry-pick or close the PR altogether.

Signed-off-by: Philipp Remy <philipp@philippremy.net>
Signed-off-by: Philipp Remy <philipp@philippremy.net>
(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 <philipp@philippremy.net>
Copy link
Member

@mborland mborland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all seem like reasonable changes to me. Thanks for giving it a go and working out the bugs!

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.35%. Comparing base (61fa6bb) to head (b1523d9).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1382   +/-   ##
========================================
  Coverage    95.35%   95.35%           
========================================
  Files          825      825           
  Lines        68203    68203           
========================================
+ Hits         65033    65034    +1     
+ Misses        3170     3169    -1     

see 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61fa6bb...b1523d9. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mborland mborland merged commit cfe946f into boostorg:develop Mar 18, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants