I'm using Gentoo Linux.
Here is my toolchain:
sys-kernel/linux-headers-3.9
sys-devel/binutils-2.23.1 USE="cxx nls zlib -multislot -multitarget -static-libs {-test} -vanilla"
sys-devel/gcc-4.7.3-r1:4.7 USE="cxx fortran gtk lto mudflap (multilib) nls nptl openmp (-altivec) -doc (-fixed-point) -gcj -go -graphite (-hardened) (-libssp) -multislot -nopie -nossp -objc -objc++ -objc-gc -regression-test -vanilla"
sys-libs/glibc-2.17:2.2 USE="(multilib) -debug -gd (-hardened) -nscd -profile (-selinux) -suid -systemtap -vanilla"
Here are my CFLAGS:
$ cat /etc/portage/make.conf
CFLAGS="-march=core-avx-i -mtune=core-avx-i -O2 -pipe -flto"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
# etc...
The whole world is built with LTO, except for few packages:
$ cat /etc/portage/package.env
dev-lang/perl no-lto
dev-libs/elfutils no-lto
dev-lang/spidermonkey no-lto
dev-libs/glib no-lto
sys-devel/llvm no-lto
media-libs/mesa no-lto
media-libs/alsa-lib no-lto
sys-apps/preload no-lto
app-text/aspell no-lto
app-text/rarian no-lto
sys-power/upower no-lto
net-libs/farstream no-lto
dev-python/notify-python no-lto
x11-libs/wxGTK no-lto
media-video/avidemux no-lto
media-gfx/inkscape no-lto
x11-base/xorg-server no-lto
x11-drivers/xf86-video-intel no-lto
net-libs/webkit-gtk no-lto
mail-client/thunderbird no-lto
$ cat /etc/portage/env/no-lto
CFLAGS="${CFLAGS} -fno-lto"
CXXFLAGS="${CXXFLAGS} -fno-lto"
LDFLAGS="${LDFLAGS} -fno-lto"
On some blogs I noticed authors setting LDFLAGS in their make.conf file also, I didn't do that.
The operating system sets these LDFLAGS according to selected profile:
$ emerge --info | grep LDFLAGS
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
Gentoo developers and maintainers do not recommend changing them
I would like to set these lines in my make.conf
file, then rebuild toolchain and world:
CFLAGS="-march=core-avx-i -mtune=core-avx-i -O2 -pipe -flto -Wl,-flto"
LDFLAGS="-Wl,-flto -Wl,-O2"
Will there be any difference in performance/stability?
Are these differences worth the time needed to recompile entire world?
I'd like to hear suggestions, explanations, better practices from experienced Gentoo users/maintainers/programmers/administrators...
Thank you very much in advance!
emerge --info
is what is already set, so setting it the same value explicitly does not change anything. This question might be more on topic on unix.stackexchange.com so don't be confused when it gets moved there (the accounts from both sites are merged if you register with the same authentification),--as-needed
is automatically replaced by-Wl,-flto -Wl,-O2
?-march
is a superset of-mtune
. Having both is pointless.