Boost logo

Boost Users :

Subject: Re: [Boost-users] undefined reference to '__sync_add_and_fetch_4'when cross-compiling boost::asio fors mips
From: Andreas Wehrmann (a.wehrmann_at_[hidden])
Date: 2012-02-17 07:37:19


On 02/17/2012 12:39 PM, Jayne wrote:
> Hello Andreas,
>
> Thank you for the reply. I have made some progress since my initial
> post, I have found that part of the problem is that I am using gcc 4.2
> and the various #defines for atomics assume that 4.2 will have the
> appropriate support. The compiler expects that `__sync_add_and_fetch_4'
> will be provided. I've found there is some assembler provided with the
> compiler which gives a 'atomic_exchange_and_add' macro which I've had
> working correctly in a demo programme, but I haven't yet got it
> integrated with boost, though that would be a nice long-term solution.
>
> Back to the problem though. I've tried a clean build with
> BOOST_ASIO_DISABLE_FENCED_BLOCK but I'm still getting the same problem.
> I've attached the build output below. Here are the steps I took to make
> the clean build:
>
> 1. unzip boost_1_48_0.zip
> 2. mkdir boost-binary
> 3. set and export
> BOOST_BUILD_ROOT=/home/jayne/boost-stb/boost_1_48_0
> export BOOST_BUILD_ROOT
> BOOST_BIN_ROOT=$BOOST_BUILD_ROOT/boost-binary
> export BOOST_BIN_ROOT
> 4. ./bootstrap.sh
> 5. Edit the resulting project-config.jam file (which has been generated
> for the host x86 system)
> using gcc : mipsel : mipsel-linux-g++ ;
> and
> option.set prefix : /opt/brcm/stblinux-2.6.31 ;
> option.set exec-prefix : /opt/brcm/stblinux-2.6.31 ;
> option.set libdir : /opt/brcm/stblinux-2.6.31/lib ;
> option.set includedir : /opt/brcm/stblinux-2.6.31/include/linux ;
>
> 6. Edit tools/build/v2/tools/gcc.jam to remove ‘-pendantic’ option
> (otherwise the string library assembler will not compile)
> 7. Run ./b2 cxxflags=-DBOOST_ASIO_DISABLE_FENCED_BLOCK --without-python
> --without-mpi
> 8. Run ./b2 threading=multi variant=release link=shared toolset=gcc
> --build-dir=$BOOST_BIN_ROOT --prefix=/tmp/boost --without-python
> --without-mpi install
>
> While compiling in step 7, a typical compiler line is:
>
> "mipsel-linux-g++"-ftemplate-depth-128 -O3 -finline-functions
> -Wno-inline -Wall -pthread -fPIC -DBOOST_ASIO_DISABLE_FENCED_BLOCK
> -Wextra -Wno-long-long -pedantic -DBOOST_ALL_DYN_LINK=1
> -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1
> -DBOOST_SYSTEM_NO_DEPRECATED -DNDEBUG-I"." -c -o
> "bin.v2/libs/chrono/build/gcc-mipsel/release/threading-multi/process_cpu_clocks.o"
> "libs/chrono/src/process_cpu_clocks.cpp"
>
>
>

Alright, I looked into how I did when I faced the problem
(my previous reply was a fast shot).

I put the following #defines in the user config header
(boost/config/user.hpp):

#define BOOST_ASIO_DISABLE_FENCED_BLOCK
#define BOOST_SP_USE_SPINLOCK

This did the trick for me.
 From what I recall, the problem lies with shared_ptr since
the implementation tries to use gcc builtins for the locking mechanism
it needs for refcounting but which are not implemented on every platform
(in my case it was Coldfire/m68k).

Regards

-- 
Dipl.-Ing. (FH) Andreas Wehrmann
Software Development
--------------------------------------------------------------
Center Communication Systems GmbH
A-1210 Wien, Ignaz-Köck-Straße 19
Sitz in Wien
FN 796 88p, Firmenbuchgericht Wien
www.centersystems.com
Tel.: +43 (0) 190 199 - 3616
Mobile: +43 (0) 664 884 75916
Fax: +43 (0) 190 199 - 2110
E-Mail: a.wehrmann_at_[hidden]

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