[llvm-dev] (Thin)LTO llvm build

Carsten Mattner via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 27 16:36:26 PST 2016


On Tue, Dec 27, 2016 at 10:42 PM, Kostya Serebryany <kcc at google.com> wrote:

> mixing -D_FORTIFY_SOURCE=2 with the sanitizers may be confusing as
> mentioned above. building the sanitizers themselves with
> -D_FORTIFY_SOURCE=2 is not expected to work at all.

Only to be clear, I didn't enable any -fsanitize for building llvm,
which I don't think you're saying, but allow me to be explicit for
clarity.

Arch Linux builds LLVM as follows and doesn't make an effort to
suppress the distro-default of using -fstack-protector=strong which
itself needs D_FORTIFY_SOURCE=2 macro:

https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/llvm

And flags are inherited from /etc/makepkg.conf which has this:

CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong"
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"

Which is exactly what I use in addition to the flags for LTO.

Given this and that 3.9.0 built with the above flags, I'm going to
suggest there's a different cause here. I'm not denying that
FORTIFY_SOURCE=2 is incompatible, but archlinux has already packaged
3.9.1 and the difference to my build is that I use clang and lld to
enable -flto=thin when building llvm as a whole.


More information about the llvm-dev mailing list