The /OPT:REF
option causes the Visual C++ linker to
Exclude functions and/or data that are never referenced
(MSDN)
This seems like it would be a good way to identify obsolete code in a legacy codebase. Is there any way to get the linker to output what is eliminated?
The /OPT:REF option causes the Visual C++ linker to. Exclude functions and/or data that are never referenced.
The Incremental Linker files (*. ilk) are used by the linker to speed up the generation of your app (.exe) or library (. lib). When your project has 100 files and only one changes, you'll be happy of this quicken.
Incremental linking links your exe/dll in a way which makes it easier for the linker to update the existing exe/dll when you make a small change and re-compile. So, incremental linking just makes it faster to compile and link your project.
In /OPT (Optimizations), the Remarks section states:
You can use the /VERBOSE option to see the functions removed by /OPT:REF and the functions that are folded by /OPT:ICF.
I have not tried using it for your purpose yet.
Also, you may want to refer to SO Question 641826 to eliminate compiler-generated symbols if you take the route given by @JamesMcNellis answer.
This isn't ideal, but...
You can do two builds, one with /OPT:REF
and one without, then run dumpbin /symbols
on the resulting binaries, parse out the symbols, and diff the results. The trick will be weeding out the library symbols so you are only left with your symbols. Since you'll end up with a list of mangled names, it's not going to be pretty.
I don't know of a way to get the linker to just tell you what it's removing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With