/INCREMENTAL[:NO]
The /INCREMENTAL option controls how the linker handles incremental linking.
By default, the linker runs in incremental mode. To override a default incremental link, specify /INCREMENTAL:NO.
An incrementally linked program is functionally equivalent to a program that is nonincrementally linked. However, because it is prepared for subsequent incremental links, an incrementally linked executable (.exe) file or dynamic-link library (DLL):
-
Is larger than a nonincrementally linked program because of padding of code and data. (Padding allows the linker to increase the size of functions and data without recreating the .exe file.)
-
May contain jump thunks to handle relocation of functions to new addresses.
Note:
To ensure that your final release build does not contain padding or thunks, link your program nonincrementally.
To link incrementally regardless of the default, specify /INCREMENTAL. When this option is selected, the linker issues a warning if it cannot link incrementally, and then links the program nonincrementally. Certain options and situations override /INCREMENTAL.
Most programs can be linked incrementally. However, some changes are too great, and some options are incompatible with incremental linking. LINK performs a full link if any of the following options are specified:
-
Link Incrementally is not selected (/INCREMENTAL:NO)
-
/OPT:REF is selected
-
/OPT:ICF is selected
-
/ORDER is selected
/INCREMENTAL is implied when /DEBUG is specified.
Additionally, LINK performs a full link if any of the following situations occur:
-
The incremental status (.ilk) file is missing. (LINK creates a new .ilk file in preparation for subsequent incremental linking.)
-
There is no write permission for the .ilk file. (LINK ignores the .ilk file and links nonincrementally.)
-
The .exe or .dll output file is missing.
-
The timestamp of the .ilk, .exe, or .dll is changed.
-
A LINK option is changed. Most LINK options, when changed between builds, cause a full link.
-
An object (.obj) file is added or omitted.
-
An object that was compiled with the /Yu /Z7 option is changed.
To set this linker option in the Visual Studio development environment
-
Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
-
Click the Linker folder.
-
Click the General property page.
-
Modify the Enable Incremental Linking property.
To set this linker option programmatically
-
See LinkIncremental.
Reference
//main.cpp
class base {
int a;
public:
/*virtual*/ void foo()
{
a++;
a--;
}
};
void main()
{
base b;
b.foo();
}
Just switching base::foo() between virtual and non-virtual causes incremental linking to fail. With /VERBOSE turned on, I can see that if I change the contents of base::foo(), the linker goes straight to pass2, but turning "virtual" on or off makes it start at pass 1 and do a full link.
The .ilk is about 300KB and every successful incremental link increases by about 1KB.
I don't see any errors/warnings in the output other than it just doesn't work.
Help please!