Skip to content

Commit ad56f86

Browse files
Copilotjll63
authored andcommitted
Fix odr_check visibility: add BOOST_SYMBOL_VISIBLE to prevent false ODR 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.
1 parent 6afb1f0 commit ad56f86

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

include/boost/openmethod/preamble.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct odr_violation : openmethod_error {
108108
namespace detail {
109109

110110
template<class Registry>
111-
struct odr_check {
111+
struct BOOST_SYMBOL_VISIBLE odr_check {
112112
static std::size_t count;
113113
template<class R>
114114
static std::size_t inc;

0 commit comments

Comments
 (0)