Commit ad56f86
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
0 commit comments