Boost logo

Boost-Build :

Subject: Re: [Boost-build] Cross compiling to 64 bit on 32 bit host
From: Bo Jensen (jensen.bo_at_[hidden])
Date: 2011-03-19 06:33:00


On Sat, Mar 19, 2011 at 10:12 AM, Vladimir Prus <ghost_at_[hidden]> wrote:
> On Saturday, March 19, 2011 12:43:24 Bo Jensen wrote:
>> On Fri, Mar 18, 2011 at 5:26 PM, Vladimir Prus <ghost_at_[hidden]> wrote:
>> > On Friday, March 18, 2011 18:38:40 Bo Jensen wrote:
>> >> On Fri, Mar 18, 2011 at 2:54 PM, Vladimir Prus <ghost_at_[hidden]> wrote:
>> >> > On Friday, March 18, 2011 17:35:32 Bo Jensen wrote:
>> >> >> I am trying to build my 64 bit libraries on a 32 bit host and almost
>> >> >> got it right. I can build correctly with gcc when adding -m64 on the
>> >> >> commandline, so the libraries are all there. But when I build using
>> >> >> boost build, the I get the following error :
>> >> >>
>> >> >> /usr/bin/ld:
>> >> >> /home/bj/sulum/external/boost/bin.v2/libs/thread/build/gcc-4.4.1/rele
>> >> >> ase /a
>> >> >> ddress-model-64/link-static/threading-multi/libboost_thread.a(thread.
>> >> >> o)
>> >> >>
>> >> >> : relocation R_X86_64_32 against `tls_destructor' can not be used
>> >> >> : when
>> >> >>
>> >> >> making a shared object; recompile with -fPIC
>> >> >> /home/bj/sulum/external/boost/bin.v2/libs/thread/build/gcc-4.4.1/rele
>> >> >> ase /ad dress-model-64/link-static/threading-multi/libboost_thread.a:
>> >> >> could not read symbols: Bad value
>> >> >> collect2: ld returned 1 exit status
>> >> >>
>> >> >> I don't think it has any thing to do with thread library, I am
>> >> >> missing something.
>> >> >>
>> >> >> But all files are being compiled with -fPIC, so I am a bit stuck, any
>> >> >> pointers appreciated ?
>> >> >
>> >> > That's a well known issue -- dynamic executable for 64 bit x86 cannot
>> >> > use non-fPIC code at all, and therefore using static libraries in
>> >> > such build results in the error you see.
>> >>
>> >> Vladimir, thanks for the reply, much appreciated.
>> >>
>> >> Hmm maybe a dumb question, but how do I then build my library
>> >> including boost libs into one shared library ? Right now I build a
>> >> bunch of static libs and included them into a shared library, from
>> >> what you say this is not possible on 64 bit.
>> >
>> > Bo,
>> >
>> > you have two options, basically:
>> >
>> > - You shared libraries, which is really the best approach
>> > - Clean your entire Boost tree (e.g. remove bin.v2), and then do:
>> >
>> >        bjam link=static cxxflags=-fPIC
>> >
>> > HTH,
>>
>> Thanks.
>>
>> Ok, I got it working, though I was confused by why some libraries
>> linked fine without -fPIC flag, turned out they were redundant and not
>> used any more or linked into a executable.
>>
>> I still have one thing which annoys me, I think the following should work :
>>
>> <library>../../../external/boost/libs/thread/build//<link>static
>> <cxxflags>-fPIC
>
> You mean, with a slash between <link>static and <cxxflags>-fPIC?
>
>> but it does not add the flags when compiling in thread library. Is
>> this intended ?
>
> Probably note. However, could you please try the attached. Building with -n,
> I see both -DFOO and -bar options passed to the compiler.

Ok, I must have messed up, you project works correctly i.e adds -fPIC
on compile. I also can make it work for some libraries such as thread,
but for iostream I get :

/home/bj/sulum/external/boost/tools/build/v2/build/virtual-target.jam:1079:
in virtual-target.register-actual-name from module virtual-target
error: Duplicate name of actual target:
<p/home/bj/sulum/external/boost/bin.v2/libs/iostreams/build/zlib/gcc-4.4.1/release/address-model-64/link-static/threading-multi>libboost_zlib.a
error: previous virtual target {
gcc%gcc.archive-libboost_zlib.a.STATIC_LIB {
gcc%gcc.compile.c-adler32.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/adler32.c.C } } {
gcc%gcc.compile.c-compress.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/compress.c.C } } {
gcc%gcc.compile.c-crc32.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/crc32.c.C } } {
gcc%gcc.compile.c-deflate.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/deflate.c.C } } {
gcc%gcc.compile.c-gzclose.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/gzclose.c.C } } {
gcc%gcc.compile.c-gzlib.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/gzlib.c.C } } {
gcc%gcc.compile.c-gzread.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/gzread.c.C } } {
gcc%gcc.compile.c-gzwrite.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/gzwrite.c.C } } {
gcc%gcc.compile.c-infback.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/infback.c.C } } {
gcc%gcc.compile.c-inffast.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/inffast.c.C } } {
gcc%gcc.compile.c-inflate.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/inflate.c.C } } {
gcc%gcc.compile.c-inftrees.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/inftrees.c.C } } {
gcc%gcc.compile.c-trees.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/trees.c.C } } {
gcc%gcc.compile.c-uncompr.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/uncompr.c.C } } {
gcc%gcc.compile.c-zutil.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/zutil.c.C } } }
error: created from
/home/bj/sulum/external/boost/libs/iostreams/build/boost_zlib
error: another virtual target {
gcc%gcc.archive-libboost_zlib.a.STATIC_LIB {
gcc%gcc.compile.c-adler32.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/adler32.c.C } } {
gcc%gcc.compile.c-compress.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/compress.c.C } } {
gcc%gcc.compile.c-crc32.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/crc32.c.C } } {
gcc%gcc.compile.c-deflate.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/deflate.c.C } } {
gcc%gcc.compile.c-gzclose.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/gzclose.c.C } } {
gcc%gcc.compile.c-gzlib.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/gzlib.c.C } } {
gcc%gcc.compile.c-gzread.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/gzread.c.C } } {
gcc%gcc.compile.c-gzwrite.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/gzwrite.c.C } } {
gcc%gcc.compile.c-infback.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/infback.c.C } } {
gcc%gcc.compile.c-inffast.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/inffast.c.C } } {
gcc%gcc.compile.c-inflate.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/inflate.c.C } } {
gcc%gcc.compile.c-inftrees.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/inftrees.c.C } } {
gcc%gcc.compile.c-trees.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/trees.c.C } } {
gcc%gcc.compile.c-uncompr.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/uncompr.c.C } } {
gcc%gcc.compile.c-zutil.o.OBJ {
/home/bj/sulum/external/zlib/zlib-1.2.4/zutil.c.C } } }
error: created from
/home/bj/sulum/external/boost/libs/iostreams/build/boost_zlib
error: added properties: <cxxflags>-fPIC
error: removed properties: none

>
>> For some reason it takes forever to add flags on the
>> commandline,
>
> You mean, it reduces performance? Are you using current Boost.Build? There
> was a patch that fixed nasty behaviour in that department.

The following command :

bjam myproject release cxxflags=-fPIC -j2 -d2

seem to stall before gettting started, am I doing something wrong here ?

My bjam is a new build from trunk (checked out a couple of weeks ago).

>
> - Volodya
>
> --
> Vladimir Prus
> http://vladimir_prus.blogspot.com
> Boost.Build: http://boost.org/boost-build2
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
>
>


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk