-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boost linker warnings on OSX #4497
Comments
Quite remarkable, I did that change and I now have zero warnings on OSX! Can't quite believe it! :-) However, I'm not sure this is suitable for submission - not quite sure what the impact of this change is really. For what it's worth, here's the patch to my local tree:
I'm only doing this on OSX at present but I may look into doing it for Linux in the future when I fully understand the implications :-) |
Actually, its probably worth mentioning that my project's CMakeLists.txt has the following:
And that's why it worked - basically, all I did was to make vcpkg's Boost match my project's visibility settings. Your setup may differ. |
One slight downside of the previous approach is that it required changes to vcpkg setup. I didn't want to have my own fork, so I ended up using a slightly different approach: if(APPLE)
set(other_flags "${other_flags} -fvisibility=default")
else()
set(other_flags "${other_flags} -fvisibility-inlines-hidden")
set(other_flags "${other_flags} -fvisibility=hidden")
endif() This resolved almost all of my OSX warnings, with the exception of one for my Debug build (manual indentation for clarity) [1]:
I am finding this extremely puzzling because:
The only possible conclusion here is that boost is being compiled with different visibility settings? The plot thickens. [1] https://my.cdash.org/viewBuildError.php?type=1&buildid=2221688 |
Since every single warning on my debug builds is related to
This appears sensible enough. We can see // class basic_text_oprimitive - output of prmitives to stream
template<class OStream>
class BOOST_SYMBOL_VISIBLE basic_text_oprimitive
{ In GCC this macro is defined as follows [3]: #define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) In Clang too [4]: #define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) The general conclusion is that by setting visibility to default we should match the symbols definition (as per previous comment [5]). We now turn our attention to the destructor [2]: BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_oprimitive(OStream & os, bool no_codecvt);
BOOST_ARCHIVE_OR_WARCHIVE_DECL
~basic_text_oprimitive(); The macro #if defined(BOOST_WARCHIVE_SOURCE) || defined(BOOST_ARCHIVE_SOURCE)
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL BOOST_SYMBOL_EXPORT
#else
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL BOOST_SYMBOL_IMPORT
#endif The macros # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
# define BOOST_SYMBOL_IMPORT And Clang says [4]: # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default")))
...
# define BOOST_SYMBOL_IMPORT This means when we are importing, visibility is not defined. We now need to find out if that is a good thing or bad. [1] https://www.boost.org/doc/libs/master/libs/config/doc/html/boost_config/boost_macro_reference.html |
Hi vcpkg developers,
Now that I have my setup working reliably for OSX, Linux and Windows, I have a small nit to pick :-) I am seeing a lot of warnings on OSX like these [1]:
Apparently these are caused by differing visibility settings [2] between my build and the build of Boost [3]. As per those comments, I have tried setting my build to
fvisibility=hidden
andfvisibility=default
, with neither helping. This ticket [4] suggests recompiling Boost with:I will try that next when I have some down time; meanwhile, has anyone experienced/solved this issue by any chance? To be honest, its nothing major but I thought I'd ask.
Many thanks for your time.
[1] https://my.cdash.org/viewBuildError.php?type=1&buildid=1545212
[2] https://gcc.gnu.org/wiki/Visibility
[3] https://stackoverflow.com/questions/36567072/why-do-i-get-ld-warning-direct-access-in-main-to-global-weak-symbol-in-this
[4] https://stackoverflow.com/questions/8685045/xcode-with-boost-linkerid-warning-about-visibility-settings/8685088#8685088
The text was updated successfully, but these errors were encountered: