Skip to contentSkip to conversation

security_flags: eliminate FORTIFY_SOURCE for debug builds

PATCH New Joe Slater 1 participant 1 message Mar 6, 2015

lore
Share & tools
lore

Joe Slater

author
#0 lore raw

PATCH 1/1 security_flags: eliminate FORTIFY_SOURCE for debug builds

If -D_FORTIFY_SOURCE=2 is included in CFLAGS for debug builds, many warnings will be generated and some packages will fail to build. So, only conditionally include it.

---
 meta/conf/distro/include/security_flags.inc |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
meta/conf/distro/include/security_flags.inc +8 -3
index f3f0082..287f30f 100644
@@ -1,10 +1,15 @@
-SECURITY_CFLAGS ?= "-fstack-protector-all -pie -fpie -D_FORTIFY_SOURCE=2"
-SECURITY_NO_PIE_CFLAGS ?= "-fstack-protector-all -D_FORTIFY_SOURCE=2"
+# _FORTIFY_SOURCE does not play well with debug builds
+#
+lcl_maybe_fortify = "${@base_conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE=2',d)}"
+
+SECURITY_CFLAGS ?= "-fstack-protector-all -pie -fpie ${lcl_maybe_fortify}"
+SECURITY_NO_PIE_CFLAGS ?= "-fstack-protector-all ${lcl_maybe_fortify}"
+
 SECURITY_LDFLAGS ?= "-Wl,-z,relro,-z,now"
 SECURITY_X_LDFLAGS ?= "-Wl,-z,relro"
 
 # powerpc does not get on with pie for reasons not looked into as yet
-SECURITY_CFLAGS_powerpc = "-fstack-protector-all -D_FORTIFY_SOURCE=2"
+SECURITY_CFLAGS_powerpc = "-fstack-protector-all ${lcl_maybe_fortify}"
 # Deal with ppc specific linker failures when using the cflags
 SECURITY_CFLAGS_pn-dbus_powerpc = ""
 SECURITY_CFLAGS_pn-dbus-ptest_powerpc = ""
Signature · 1 line
1.7.9.5