Boost logo

Boost-Build :

Subject: Re: [Boost-build] bjam - win - ordering of obj files
From: Phillip Seaver (phil_at_[hidden])
Date: 2009-12-21 11:37:51


Anant Rao wrote:
>
> Hi,
>
>
>
> My jamfile is like this on Windows to generate a dll.
>
>
>
> lib blah
>
> : aprwrapper.cpp
>
> file1.cpp
>
> file2.cpp
>
> ;
>
>
>
> The bjam-generated .rsp file is like this:
>
>
>
> file1.obj
>
> file2.obj
>
> aprwrapper.obj
>
>
>
> The generated DLL gives an ‘Invalid access to memory’ at run-time,
> whereas that generated with MSVC IDE works fine. (This is because of
> ordering of global statics).
>
> If I move aprwrapper.obj to the top in the .rsp file and just run the
> link command, then the bjam-generated DLL is fine.
>
>
>
> My questions:
>
> 1. Is there a way to force bjam to place the obj files in a
> particular order or at least in the same order as given by the
> src file list – for the link step?
> 2. Assuming Microsoft published how it orders the obj files in its
> IDE’s link step, can bjam follow the same? This is the most
> preferable way so that there’s no discrepancy in output between
> bjam and MSVC IDE.
>
>
>
> Thanks in advance,
>
> Anant Rao
>

As an aside, relying on the order of initialization of static objects is
a bad idea. I've run into cases where it worked fine for a while, then
suddenly stopped working (usually crashing), even when compiling with
msvc (IIRC - I've been using boost.build so long it's hard to remember
for sure). See What's the "static initialization order fiasco"?
<http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12>

Phillip


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