Fix false ODR violation when dynamic loading with -fvisibility-inlines-hidden#78
Draft
Copilot wants to merge 2 commits into
Draft
Fix false ODR violation when dynamic loading with -fvisibility-inlines-hidden#78Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
|
An automated preview of the documentation is available at https://78.openmethod.prtest3.cppalliance.org/libs/openmethod/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-06-28 15:00:53 UTC |
…DR violation with dynamic loading
When a project uses <visibility>hidden (which adds -fvisibility-inlines-hidden),
template static variable initializers like odr_check::inc<R> get hidden symbol
visibility. When multiple shared libraries are loaded via RTLD_GLOBAL on ELF
systems (e.g. s390x), hidden symbols are not deduplicated by the dynamic linker.
Each DSO initializes its own copy of inc<R>, each time incrementing the shared
count variable. When count > 1, initialize() falsely fires the ODR violation check.
Fix: add BOOST_SYMBOL_VISIBLE to odr_check struct, which expands to
__attribute__((__visibility__("default"))) on GCC/Clang (no-op on MSVC/Windows).
This overrides -fvisibility-inlines-hidden for all struct members including the
inc<R> template static, ensuring proper RTLD_GLOBAL symbol deduplication.
Also add the required #include <boost/config.hpp> for BOOST_SYMBOL_VISIBLE.
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions job for Boost.CI
Fix false ODR violation when dynamic loading with -fvisibility-inlines-hidden
Jun 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
dynamic_loadingtest fails on ELF targets (notably s390x/QEMU) becauseodr_check::inc<R>— a template static variable with an initializer — gets hidden symbol visibility from-fvisibility-inlines-hiddeneven when-fvisibility=defaultis active. RTLD_GLOBAL cannot deduplicate hidden symbols, so each loaded DSO increments the sharedcount, triggering a spurious ODR abort.Changes
include/boost/openmethod/preamble.hpp#include <boost/config.hpp>forBOOST_SYMBOL_VISIBLEodr_checkwithBOOST_SYMBOL_VISIBLEto force default visibility on all its members, overriding-fvisibility-inlines-hiddenBOOST_SYMBOL_VISIBLEexpands to__attribute__((__visibility__("default")))on GCC/Clang and is a no-op on MSVC/Windows.