Developer Guide and Reference

Contents

Exclude Unused Code and Data from the Executable

Programs often contain dead code or data that is not used during their execution. Even if no expensive whole-program inter-procedural analysis is made at compile time to identify dead code, there are compiler options you can specify to eliminate unused functions and data at link time.
This method is often referred to as function-level linking.
Options to specify:
Linux*
and
macOS*
:
-
fdata-sections
-
ffunction-sections
-
Wl
, --
gc-sections
Windows*:
/Gy
/Qoption
,
link
,
/OPT:REF
Some of the options in the above specifications are passed to the linker.
Advantages of this method:
Only the code that is referenced remains in an executable. Dead functions and data are stripped from the executable.
Disadvantages of this method:
  • The object codes may become slightly larger because each function or datum is put into a separate section. The overhead is eliminated at the linking stage.
  • This method requires linker support to strip unused sections.
  • This method can slightly increase linking time.

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804