Skip to content

Fix false ODR violation when dynamic loading with -fvisibility-inlines-hidden#78

Draft
Copilot wants to merge 2 commits into
developfrom
copilot/fix-github-actions-job-failure-again
Draft

Fix false ODR violation when dynamic loading with -fvisibility-inlines-hidden#78
Copilot wants to merge 2 commits into
developfrom
copilot/fix-github-actions-job-failure-again

Conversation

Copilot AI commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

The dynamic_loading test fails on ELF targets (notably s390x/QEMU) because odr_check::inc<R> — a template static variable with an initializer — gets hidden symbol visibility from -fvisibility-inlines-hidden even when -fvisibility=default is active. RTLD_GLOBAL cannot deduplicate hidden symbols, so each loaded DSO increments the shared count, triggering a spurious ODR abort.

Changes

  • include/boost/openmethod/preamble.hpp
    • Add #include <boost/config.hpp> for BOOST_SYMBOL_VISIBLE
    • Annotate odr_check with BOOST_SYMBOL_VISIBLE to force default visibility on all its members, overriding -fvisibility-inlines-hidden
// before
template<class Registry>
struct odr_check {

// after
template<class Registry>
struct BOOST_SYMBOL_VISIBLE odr_check {

BOOST_SYMBOL_VISIBLE expands to __attribute__((__visibility__("default"))) on GCC/Clang and is a no-op on MSVC/Windows.

@cppalliance-bot

cppalliance-bot commented Jun 28, 2026

Copy link
Copy Markdown

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
Copilot finished work on behalf of jll63 June 28, 2026 14:55
Copilot AI requested a review from jll63 June 28, 2026 14:55
Copilot finished work on behalf of jll63 June 28, 2026 15:51
Copilot finished work on behalf of jll63 June 28, 2026 15:56
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.

3 participants