if ($compile and not all_flags_used($line, \@missing, @cflags)
# Libraries linked with -fPIC don't have to (and can't) be linked
# with -fPIE as well. It's no error if only PIE flags are missing.
- and not pic_pie_conflict($line, $harden_pie, \@missing, @cflags_pie)) {
+ and not pic_pie_conflict($line, $harden_pie, \@missing, @cflags_pie)
+ # Assume dpkg-buildflags returns the correct flags.
+ and not $line =~ /`dpkg-buildflags --get (?:CFLAGS|CXXFLAGS)`/) {
error_flags('CFLAGS missing', \@missing, \%flag_renames, $line);
$exit |= 1 << 3;
}
- if ($preprocess and not all_flags_used($line, \@missing, @cppflags)) {
+ if ($preprocess and not all_flags_used($line, \@missing, @cppflags)
+ # Assume dpkg-buildflags returns the correct flags.
+ and not $line =~ /`dpkg-buildflags --get CPPFLAGS`/) {
error_flags('CPPFLAGS missing', \@missing, \%flag_renames, $line);
$exit |= 1 << 3;
}
if ($link and not all_flags_used($line, \@missing, @ldflags)
# Same here, -fPIC conflicts with -fPIE.
- and not pic_pie_conflict($line, $harden_pie, \@missing, @ldflags_pie)) {
+ and not pic_pie_conflict($line, $harden_pie, \@missing, @ldflags_pie)
+ # Assume dpkg-buildflags returns the correct flags.
+ and not $line =~ /`dpkg-buildflags --get LDFLAGS`/) {
error_flags('LDFLAGS missing', \@missing, \%flag_renames, $line);
$exit |= 1 << 3;
}
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
Depends: libc6 (>= 2.7), gcc
+
+# `...` isn't expanded by the Makefile, assume dpkg-buildflags returns the
+# correct flags.
+gcc -c `dpkg-buildflags --get CFLAGS` test.c
+g++ -c `dpkg-buildflags --get CXXFLAGS` test.cc
+gcc -c `dpkg-buildflags --get LDFLAGS` test.c
+gcc -c `dpkg-buildflags --get CFLAGS` `dpkg-buildflags --get CPPFLAGS` test.c
+g++ -c `dpkg-buildflags --get CXXFLAGS` `dpkg-buildflags --get CPPFLAGS` test.cc
+gcc -o test test.o `dpkg-buildflags --get LDFLAGS`
+gcc -o test test.o `dpkg-buildflags --get CFLAGS`
is_blhc 'debian', '', 8,
'CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -c test.c
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c `dpkg-buildflags --get CFLAGS` test.c
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -c `dpkg-buildflags --get CXXFLAGS` test.cc
+CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -c `dpkg-buildflags --get LDFLAGS` test.c
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c `dpkg-buildflags --get LDFLAGS` test.c
+LDFLAGS missing (-Wl,-z,relro): gcc -o test test.o `dpkg-buildflags --get CFLAGS`
';