Opened 7 years ago

Closed 7 years ago

#11671 closed Bugs (fixed)

explicit template instanciations in boost::serialization don't get exported with all compilers

Reported by: Frederic Devernay <frederic.devernay@…> Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc: frederic.devernay@…

Description

  • Symptoms:

my program (compiled with g++-4.2.1 on OS X 10.6) crashed at run-time with:

dyld: lazy symbol binding failed: Symbol not found: __ZN5boost7archive21basic_text_oprimitiveISoED2Ev

also reported (by someone else) at: h__ps://trac.macports.org/ticket/48717

  • Diagnostic:

not all compiler export the template instanciations when the template class is exported but not the template argument (in this case, std::ostream).

g++-4.0 and g++-4.8 do, g++-4.2 and clang++-3.4 don't.

$ g++-4.0 -dynamic -fPIC -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -I"." -c -o "basic_text_oprimitive.o" "libs/serialization/src/basic_text_oprimitive.cpp" && nm -m basic_text_oprimitive.o|fgrep __ZN5boost7archive21basic_text_oprimitiveISoED2Ev
000003c2 (__TEXT,__text) external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev
00002d40 (__TEXT,__eh_frame) external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev.eh
$ g++-4.2 -dynamic -fPIC -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -I"." -c -o "basic_text_oprimitive.o" "libs/serialization/src/basic_text_oprimitive.cpp" && nm -m basic_text_oprimitive.o|fgrep __ZN5boost7archive21basic_text_oprimitiveISoED2Ev
000006d8 (__TEXT,__text) private external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev
00003bf8 (__TEXT,__eh_frame) private external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev.eh
$ g++-mp-4.8 -dynamic -fPIC -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -I"." -c -o "basic_text_oprimitive.o" "libs/serialization/src/basic_text_oprimitive.cpp" && nm -m basic_text_oprimitive.o|fgrep __ZN5boost7archive21basic_text_oprimitiveISoED2Ev000004dc (__TEXT,__text) external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev
$ clang++-mp-3.4 -dynamic -fPIC -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -I"." -c -o "basic_text_oprimitive.o" "libs/serialization/src/basic_text_oprimitive.cpp" && nm -m basic_text_oprimitive.o|fgrep __ZN5boost7archive21basic_text_oprimitiveISoED2Ev00000c70 (__TEXT,__textcoal_nt) weak private external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev
00003944 (__TEXT,__eh_frame) weak private external __ZN5boost7archive21basic_text_oprimitiveISoED2Ev.eh
  • Related GCC bugs :

h__ps://gcc.gnu.org/bugzilla/show_bug.cgi?id=17470 h__ps://gcc.gnu.org/bugzilla/show_bug.cgi?id=51930

  • Solutions :
    • adding BOOST_SYMBOL_VISIBLE (or the equivalent #pragma GCC visibility) to the template instantiation only solved the problem for clang-3.4.
    • adding #pragma GCC visibility push(default)/#pragma GCC visibility pop around #include <ostream> solved the problem for all compilers.

I do not know the side-effects of that second solution, but it seems like it is the only consistent one. All classes that are template arguments should be visible.

Maybe other compilers have the same issue.

Change History (2)

comment:1 by frederic.devernay@…, 7 years ago

patch at h__ps://raw.githubusercontent.com/MrKepzie/Natron/workshop/tools/MacOSX/ports/devel/boost/files/patch-serialization-visibility.diff

comment:2 by Robert Ramey, 7 years ago

Resolution: fixed
Status: newclosed

I believe that all problems related to visibility have been addressed. I've checked the changes into develop branch. Please feel free to double check

Note: See TracTickets for help on using tickets.