[Boost-bugs] [Boost C++ Libraries] #11671: explicit template instanciations in boost::serialization don't get exported with all compilers

Subject: [Boost-bugs] [Boost C++ Libraries] #11671: explicit template instanciations in boost::serialization don't get exported with all compilers
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-09-19 10:02:00


#11671: explicit template instanciations in boost::serialization don't get exported
with all compilers
-------------------------------------------------+-------------------------
 Reporter: Frederic Devernay | Owner: ramey
  <frederic.devernay@…> | Status: new
     Type: Bugs | Component:
Milestone: To Be Determined | serialization
  Version: Boost 1.59.0 | Severity: Problem
 Keywords: |
-------------------------------------------------+-------------------------
 * 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11671>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC