Boost logo

Boost-Build :

From: David Abrahams (gclbb-jamboost_at_[hidden])
Date: 2003-05-08 12:45:46


Vladimir Prus <ghost_at_[hidden]> writes:

> Zbynek Winkler wrote:
>> This is the command line used for final linking stage of my debug build:
>>
>> LINK /DEBUG /OPT:REF,ICF /subsystem:console
>> /out:"test\bin\msvc\debug\main-target-test\test.exe "
>> @"test\bin\msvc\debug\main-target-test\test.rsp"
>>
>> I am getting a warning:
>> LINK : warning LNK4075: ignoring /EDITANDCONTINUE due to /OPT specification
>>
>> Why is there /OPT option even for debug build? Is that a bug or a feature?
>
> The msvc support was implemented by David Abrahams. Dave, can you comment on
> this issue?

Well, the docs say:

The following linker options disable Edit and Continue.

Setting /OPT:REF, /OPT:ICF, or /INCREMENTAL:NO disables Edit
and Continue with the following warning:

LINK : warning LNK4075: ignoring /EDITANDCONTINUE due to /OPT
specification

So the warning is going to be there for some combination of
optimizations whether we like it or not. As for REF,ICF:

I didn't consider whether to use them or not; I simply drew on the
successful command-lines we get from BBv1 for MSVC. On the other
hand, these options seem like something we'd want for a debug build.
If unused symbols aren't linked away, the executable is just bigger
and may even produce different behavior (due to initializations) that
wouldn't be diagnosable in the debug build.

I note that ICF is redundant once you specify REF, though:

REF | NOREF

/OPT:REF eliminates functions and/or data that are never
referenced while /OPT:NOREF keeps functions and/or data that are
never referenced.

LINK removes unreferenced packaged functions by default. An object
contains packaged functions (COMDATs) if it has been compiled with
the /Gy option. This optimization is called transitive COMDAT
elimination. To override this default and keep unreferenced
COMDATs in the program, specify /OPT:NOREF. You can use the
/INCLUDE option to override the removal of a specific symbol.

If /DEBUG is specified, the default for /OPT is NOREF (otherwise,
it is REF), and all functions are preserved in the image. To
override this default and optimize a debugging build, specify
/OPT:REF. The /OPT:REF option disables incremental linking.

You have to explicitly mark data as a COMDAT; use
__declspec(selectany).

If /OPT:REF is specified, /OPT:ICF is on by default. If you want
/OPT:REF but not /OPT:ICF, you must specify the following:

link /opt:ref /opt:noicf
Specifying /OPT:ICF does not activate the /OPT:REF option

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com
 

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