Boost logo

Boost Users :

Subject: Re: [Boost-users] libboost_date_time: undefined reference to __sync_fetch_and_add_4
From: Carsten Raas (carsten.raas_at_[hidden])
Date: 2009-04-06 07:55:27


Am 04.04.2009 16:22, Peter Dimov schrieb:
> Carsten Raas:
>>> Did you rebuild date_time itself with this change?
>>
>> Yes, I did.
>>
>> I followed the hint of Peter Dimov in
>> http://lists.boost.org/Archives/boost/2008/04/135521.php
>
> That's very odd. It's true that Datetime uses shared_ptr, and that
> shared_ptr uses __sync_fetch_and_add on some platforms, but it shouldn't
> on Intel x64 because:
>
> #elif defined(__GNUC__) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 ) &&
> !defined( __arm__ ) && !defined( __hppa ) && ( !defined(
> __INTEL_COMPILER ) || defined( __ia64__ ) )
> # include <boost/detail/sp_counted_base_sync.hpp>
>
> so I've no idea where the reference to __sync_fetch_and_add comes from.
> Can you try rebuilding Datetime with
>
> #define __sync_fetch_and_add ERROR
>
> and see what in Boost is trying to make use of it?
>
> (The other alternative is that libstdc++ itself is using
> __sync_fetch_and_add in a header.)

I tried this one
echo "#define __sync_fetch_and_add ERROR" >> boost/config/user.hpp
echo "#define __sync_fetch_and_add_4 ERROR" >> boost/config/user.hpp
ending up with a complete library (without errors while building) and
        /opt/boost/1.38/intel/lib/libboost_date_time.so:
        undefined reference to `__sync_fetch_and_add_4'
again when trying to link.
------------------------------------------------------------------------
Then I deleted sp_counted_base_sync.hpp before building the library and
in the installation include directory after rebuilding: this did not
change anything. The build works, but the shared library cannot be linked.
------------------------------------------------------------------------
Finally, I tried to compile my demo program with the "-H" flag. Then I
grep'ed all included header files for "sync_fetch". The only file with
"sync_fetch" in it is atomicity.h and it appears three times, cf. the
dependency tree:
/opt/boost/1.38/intel/include/boost/date_time/date_generators.hpp
 /usr/include/c++/4.2.1/stdexcept
  /usr/include/c++/4.2.1/string
   /usr/include/c++/4.2.1/bits/basic_string.h
    /usr/include/c++/4.2.1/ext/atomicity.h
 /usr/include/c++/4.2.1/sstream
  /usr/include/c++/4.2.1/istream
   /usr/include/c++/4.2.1/ios
    /usr/include/c++/4.2.1/bits/ios_base.h
     /usr/include/c++/4.2.1/ext/atomicity.h
     /usr/include/c++/4.2.1/bits/locale_classes.h
      /usr/include/c++/4.2.1/ext/atomicity.h

Again, the static boost library (from the same build) works (with the
same header files included).
------------------------------------------------------------------------
And note that all libboost_date_time libraries (static and shared) have
the string "__sync_fetch_and_add_4" in it:
grep __sync_fetch_and_add_4 /opt/boost/1.38/intel-11.0.081-shared/lib/*
------------------------------------------------------------------------

-Carsten


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net