Description
Describe the bug
In our environment (based on Poky from the Yocto Project), we pass a lot of compiler options via CC
, CFLAGS
, and CXXFLAGS
, which are set in the environment or via meson.cross
. These include -O2
, -D_FORTIFY_SOURCE
, and -Werror
. When Meson needs to run the compiler during configuration, e.g., via check_header
, this may lead to an unrelated error:
In file included from /usr/include/bits/libc-header-start.h:33,
from /usr/include/stdio.h:27,
from .../build/meson-private/tmp3fr8c8af/testfile.c:2:
/usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
| ^~~~~~~
cc1: all warnings being treated as errors
This is due to Meson adding -O0
to the compiler options during configuration tests, which clashes with the use of -D_FORTIFY_SOURCE=2
.
To Reproduce
In Meson's top directory:
CFLAGS="-O2 -D_FORTIFY_SOURCE=2 -Werror" ./meson.py setup build test\ cases/common/189\ check\ header/
Expected behavior
Configuration should not fail because -O2
, -D_FORTIFY_SOURCE
, and -Werror
are in CFLAGS
or CXXFLAGS
.
system parameters
- Is this a cross build or just a plain native build (for the same computer)?
In our environment it is typically a cross build, but as the reproducer above shows, it is easy to reproduce in a plain build.
- what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
Linux Arch, Fedora, Gentoo, and OpenSUSE. However, Ubuntu is not affected as they have patched away the warning from glibc's features.h
file...
- what
meson --version
1.7.0