ascent
ascent copied to clipboard
Linker warning about weak symbols
Hi There!
We're getting the following linker warning when linking our application, which uses all static libraries for Ascent and its dependencies:
ld: warning: direct access in function 'std::__1::__shared_ptr_pointer<std::__1::__empty_state<char>*, std::__1::shared_ptr<std::__1::__empty_state<char> >::__shared_ptr_default_delete<std::__1::__empty_state<char>, std::__1::__empty_state<char> >, std::__1::allocator<std::__1::__empty_state<char> > >::__get_deleter(std::type_info const&) const' from file '/Users/daibane/capp-alegra-ng/flavor/skylake/install/ascent/lib/libascent_mpi.a(ascent_actions_utils.cpp.o)' to global weak symbol 'typeinfo name for std::__1::shared_ptr<std::__1::__empty_state<char> >::__shared_ptr_default_delete<std::__1::__empty_state<char>, std::__1::__empty_state<char> >' from file '/Users/daibane/capp-alegra-ng/flavor/skylake/install/mu/lib/libmu.a(mu_datafile.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
Is there some visibility setting we could change in Ascent to silence this?
I think those style of symbols come from C++ std namespaces.
There is nothing special going on in ascent_actions_utils.cpp.o so this might be hard to track down.
We do default to hidden symbol visibility:
set_target_properties(ascent_mpi PROPERTIES CXX_VISIBILITY_PRESET hidden)
https://github.com/Alpine-DAV/ascent/blob/d7f41651f8251ffffb2b74845489e7fb4eb3fcae/src/ascent/CMakeLists.txt#L526
Any ideas of how we could narrow down the culprit?
Do we also need CMAKE_VISIBILITY_INLINES_HIDDEN?
Would an option to not do hidden visibility make any sense? Or would that break Ascent in some major way?
We could try -- but we prefer hidden symbol visibility for VTK-m, else we get a ton of symbols exposed.
Is it possible to leave this up to the user so that your builds would specify
-DCMAKE_CXX_VISIBILITY_PRESET=ON
and each user can choose what visibility their whole build uses?
My bad, I meant:
-DCMAKE_CXX_VISIBILITY_PRESET=hidden
https://cmake.org/cmake/help/latest/prop_tgt/LANG_VISIBILITY_PRESET.html
How about we default to hidden, but allow you to override?
That works great for me, thank you!
Hang on... I've tried removing the visibility preset commands from all of Ascen't CMakeLists.txt files and I'm still getting warnings like this... let me explore setting our app's visibility to hidden, see if I can get any combination at all that has no warnings
Ah nevermind, I was bitten by CMake caches that were still making things hidden. If I remove all the visibility lines from the Ascent CMake and set -DVTKm_HIDE_PRIVATE_SYMBOLS=OFF for VTK-m, then all my link warnings go away! Perhaps Ascent could be set up the same way as VTK-m with a HIDE_PRIVATE_SYMBOLS option ON by default?
I would be willing to do the PR to implement this if you're willing to accept it. It sounds like VTK-m implements that option for applications with static builds, which our application is.
@ibaned absolutely -- that would be great
I just opened #1033 which resolves this
resolved in #1033