Issues with _FORTIFY_SOURCE=3
Description:
The recent change to -D_FORTIFY_SOURCE=3
led to a build failure in the kitty-git
AUR package. What happens is that kitty's build script prepends -D_FORTIFY_SOURCE=2
and -Werror
to the env CFLAGS, and this means we'll end up with two conflicting definitions of -D_FORTIFY_SOURCE=2
on the command line, which together with -Werror
is a failure:
<command-line>: error: "_FORTIFY_SOURCE" redefined [-Werror]
<command-line>: note: this is the location of the previous definition
Now, this is a bit unfortunate. kitty correctly prepends to give our flags precedence, and usually, later CFLAGS override earlier CFLAGS, but not in the case of -D.
It's not entirely clear to me who should be responsible for dealing with redefinitions. But I'd like to suggest changing our CFLAGS to -U_FORTIFY_SOURCE D_FORTIFY_SOURCE=3
to avoid such issues entirely in the future. This looks a bit invasive at first glance, but I think it's really no more invasive than what happens with every other flag in CFLAGS.
Additional info:
- package version(s): 6.1.0-3
- config and/or log files: (should happen with the default
makepkg.conf
) - link to upstream bug report, if any: https://github.com/kovidgoyal/kitty/issues/7310, https://aur.archlinux.org/packages/kitty-git#comment-961665, and if you search the web for
_FORTIFY_SOURCE redefined
, you'll find many projects that had to deal with this in the past