and those merged by attribute @code{externally_visible} become static functions
and in effect are optimized more aggressively by interprocedural optimizers.
-This option should not be used in combination with @option{-flto}.
-Instead relying on a linker plugin should provide safer and more precise
-information.
+With @option{-flto} this option has a limited use. In most cases the
+precise list of symbols used or exported from the binary is known the
+resolution info passed to the link-time optimizer by the linker plugin. It is
+still useful if no linker plugin is used or during incremental link step when
+final code is produced (with @option{-flto}
+@option{-flinker-output=nolto-rel}).
@item -flto[=@var{n}]
@opindex flto
if (strcmp (lto_resolution_str[j], r_str) == 0)
{
r = (enum ld_plugin_symbol_resolution) j;
+ /* Incremental linking together with -fwhole-program may seem
+ somewhat contradictionary (as the point of incremental linking
+ is to allow re-linking with more symbols later) but it is
+ used to build LTO kernel. We want to hide all symbols that
+ are not explicitely marked as exported and thus turn
+ LDPR_PREVAILING_DEF_IRONLY_EXP
+ to LDPR_PREVAILING_DEF_IRONLY. */
+ if (flag_whole_program
+ && flag_incremental_link == INCREMENTAL_LINK_NOLTO
+ && r == LDPR_PREVAILING_DEF_IRONLY_EXP)
+ r = LDPR_PREVAILING_DEF_IRONLY;
break;
}
}
break;
case LTO_LINKER_OUTPUT_NOLTOREL: /* .o: incremental link producing asm */
- flag_whole_program = 0;
flag_incremental_link = INCREMENTAL_LINK_NOLTO;
break;