Link Time Optimization (LTO) gives GCC the capability of dumping its internal representation (GIMPLE) to disk, so that all the different compilation units that make up a single executable can be optimized as a single module. This expands the scope of inter-procedural optimizations to encompass the whole program (or, rather, everything that is visible at link time). https://gcc.gnu.org/wiki/LinkTimeOptimization
All you need is add in ''make.conf'' append to your CFLAGS ''-flto''.
$ cat /etc/portage/env/no-lto.conf
CFLAGS="${CFLAGS} -fno-lto -fno-use-linker-plugin"
CXXFLAGS="${CXXFLAGS} -fno-lto -fno-use-linker-plugin"
LDFLAGS="${LDFLAGS} -fno-lto -fno-use-linker-plugin"
This is list of packages, which doesn't build with ''CFLAGS="-flto"'', please update if you encounter some broken.
$ cat /etc/portage/package.env/no-lto
sys-libs/glibc no-lto # glibc take care self about it
sys-devel/llvm no-lto
sys-apps/coreutils no-lto
dev-lang/ruby no-lto
dev-lang/perl no-lto
dev-lang/yasm no-lto
sys-devel/flex no-lto
net-misc/dhcp no-lto
app-shells/bash no-lto
sys-apps/findutils no-lto
media-libs/mesa no-lto
x11-apps/mesa-progs no-lto
app-benchmarks/glmark2 no-lto
app-emulation/wine no-lto
media-libs/alsa-lib no-lto
x11-base/xorg-server no-lto
sys-apps/grep no-lto
sys-fs/e2fsprogs no-lto
sys-devel/gdb no-lto
sys-devel/gettext no-lto
net-misc/wget no-lto
net-analyzer/traceroute no-lto
dev-libs/cyrus-sasl no-lto
mail-mta/postfix no-lto
sys-apps/util-linux no-lto
sys-fs/udisks no-lto
x11-libs/pango no-lto
gnome-base/libglade no-lto
media-libs/gstreamer no-lto
media-libs/gst-plugins-base no-lto
media-libs/gst-plugins-bad no-lto
app-misc/mc no-lto
media-libs/quvi no-lto
# OLD GST, remove later
media-plugins/gst-plugins-a52dec no-lto
media-plugins/gst-plugins-vorbis no-lto
media-plugins/gst-plugins-ogg no-lto
media-plugins/gst-plugins-xvideo no-lto
media-plugins/gst-plugins-theora no-lto
media-plugins/gst-plugins-x no-lto
media-plugins/gst-plugins-mad no-lto
media-plugins/gst-plugins-dvdread no-lto
media-plugins/gst-plugins-mpeg2dec no-lto
media-plugins/gst-plugins-x264 no-lto
media-plugins/gst-plugins-resindvd no-lto
media-plugins/gst-plugins-dts no-lto
media-plugins/gst-plugins-faad no-lto
media-plugins/gst-plugins-flac no-lto
media-plugins/gst-plugins-assrender no-lto
media-plugins/gst-plugins-pulse no-lto
media-plugins/gst-plugins-libav no-lto
sys-apps/systemd no-lto
sys-apps/kmod no-lto
sys-apps/dbus no-lto
media-sound/pulseaudio no-lto
dev-qt/qtcore no-lto
dev-qt/qtgui no-lto
dev-qt/qtquick1 no-lto
dev-qt/qtwidgets no-lto
dev-qt/qtdeclarative no-lto
dev-qt/qtprintsupport no-lto
dev-qt/qtscript no-lto
dev-qt/qtxmlpatterns no-lto
dev-qt/qtquickcontrols no-lto
dev-qt/qtwebkit no-lto
dev-qt/designer no-lto
media-video/libav no-lto
media-libs/libpostproc no-lto
dev-db/mariadb no-lto #maybe
net-misc/openssh no-lto
app-admin/sudo no-lto
sys-libs/pam no-lto
sys-apps/shadow no-lto
dev-libs/libtasn1 no-lto
net-libs/gnutls no-lto
net-libs/webkit-gtk no-lto
app-crypt/gnupg no-lto
net-libs/glib-networking no-lto
net-misc/modemmanager no-lto
dev-libs/gobject-introspection no-lto
dev-libs/gjs no-lto
www-servers/apache no-lto
net-dns/libidn no-lto
dev-lang/vala no-lto
x11-libs/gdk-pixbuf no-lto
dev-vcs/git no-lto
sys-power/upower no-lto
dev-libs/xapian no-lto
app-office/akonadi-server no-lto
net-voip/telepathy-gabble no-lto
net-irc/telepathy-idle no-lto
net-im/telepathy-mission-control no-lto
# KDE
kde-base/kdelibs no-lto
kde-base/ksmserver no-lto
kde-base/pykde4 no-lto
kde-base/drkonqi no-lto
kde-base/kdepim-runtime no-lto
app-office/calligra no-lto
net-im/ktp-call-ui no-lto
app-office/kmymoney no-lto
# KDE 5
dev-util/cmake no-lto
kde-base/baloo no-lto
kde-base/plasma-workspace no-lto
kde-base/kate no-lto
kde-base/marble no-lto
kde-frameworks/kauth no-lto
kde-frameworks/kdoctools no-lto
kde-frameworks/kio no-lto
dev-util/kdevelop no-lto
dev-util/kdevelop-clang no-lto
media-sound/mpg123 no-lto
media-libs/openal no-lto
kde-base/ksysguard no-lto
x11-themes/qtcurve no-lto
net-print/cups no-lto
media-gfx/imagemagick no-lto
media-gfx/inkscape no-lto
dev-lang/spidermonkey no-lto
sys-auth/polkit no-lto
dev-lang/lua no-lto
net-analyzer/wireshark no-lto
net-libs/gupnp-igd no-lto
net-libs/libnice no-lto
gnome-base/gconf no-lto
media-video/vlc no-lto
net-libs/libproxy no-lto
net-fs/nfs-utils no-lto
gnome-base/librsvg no-lto
sys-devel/libtool no-lto #phonon fails
net-irc/quassel no-lto
media-libs/libquvi no-lto
media-sound/mpd no-lto
app-misc/strigi no-lto
media-gfx/nvidia-texture-tools no-lto
games-emulation/dosbox no-lto
app-arch/tar no-lto
sys-apps/accountsservice no-lto
net-wireless/aircrack-ng no-lto
media-libs/libdvdnav no-lto
sys-apps/kbd no-lto
dev-libs/elfutils no-lto
media-libs/libdvdread no-lto
sys-apps/iproute2 no-lto
media-libs/flac no-lto
sys-block/parted no-lto
app-crypt/pinentry no-lto
sys-apps/net-tools no-lto
app-text/hunspell no-lto
app-i18n/ibus no-lto
# GNOME
app-misc/tracker no-lto
gnome-base/gvfs no-lto
gnome-base/gnome-desktop no-lto
gnome-base/gnome-control-center no-lto