SPRUIG8J January 2018 – March 2024
Link-time optimization is an optimization mode that allows the compiler to have visibility of the entire program. The optimization occurs at link-time instead of compile-time like other optimization levels.
Link-time optimization is invoked using the --opt_level=4 option. This option must be placed before the --run_linker (-z) option on the command line, because both the compiler and linker are involved in link-time optimization. At compile time, the compiler embeds an intermediate representation of the file being compiled into the resulting object file. At link-time this representation is extracted from every object file which contains it, and is used to optimize the entire program.
If you use --opt_level=4 (-O4), the --program_level_compile option cannot also be used, because link-time optimization provides the same optimization opportunities as program level optimization (Section 4.4). Link-time optimization provides the following benefits:
When using link-time optimization (--opt_level=4) for the C7000, link only source and object files that were compiled with the same --silicon_version and --mma_version options. Linking source and/or object files compiled with different --silicon_version or --mma_version options may cause the link to fail.