boostorg / boostorg/program_options

symbol visibility problem on macOS

Open
#98 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
136
Forks
117
PR merge metrics
No merged PRs in 30d

Description

When I compile with gcc-9, gcc-10, clang-9, clang-10 or the Xcode clang I have this problem. I do not see it under Linux (Ubuntu 18 LTS):
[BUG-REPORT.txt](https://github.com/boostorg/program_options/files/4944925/BUG-REPORT.txt)

I get linkage warnings that suggest possible runtime failure

ld: warning: direct access in function '__ZN5boost10wrapexceptINS_15program_options14unknown_optionEEC1ERKS3_' from file lib/libboost_program_options.a(options_description.o)' to global weak symbol '__ZTVN5boost15program_options5errorE' from file XXX means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

What's weird is that visibility should only apply to dynamic linkage, and I have built the libraries entirely statically.

I was able to get around this by building all of boost by supplying `cxxflags="-fvisibility=default"` to b2. Probably not the right fix but make the problem go away.

Probably incomplete list of symbols causing this problem. I do not have this issue with any other Boost library I use.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with BUG-REPORT.txt and reproduce the static build on macOS using the listed GCC, Clang, or Xcode Clang versions. Compare the build with and without b2's cxxflags="-fvisibility=default" and check the linker warnings involving program_options symbols. Done means the visibility warnings are resolved without relying on that workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.