[igt-dev] [PATCH i-g-t 5/5] meson: Use -D_FORTIFY_SOURCE=2 on optimized builds

Arkadiusz Hiler arkadiusz.hiler at intel.com
Thu May 9 10:03:26 UTC 2019


Some distribution enable _FORTIFY_SOURCE implicitly if user sets of -O1
greater in the CFLAGS, which may cause surprise compile failures.

Let's fortify explicitly and for everyone with default build, since the
checks provided are good.

Cc: Eero Tamminen <eero.t.tamminen at intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
 meson.build | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/meson.build b/meson.build
index 2a5a8580..2d1f5c50 100644
--- a/meson.build
+++ b/meson.build
@@ -255,6 +255,13 @@ config.set10('HAVE_MEMFD_CREATE', have)
 add_project_arguments('-D_GNU_SOURCE', language : 'c')
 add_project_arguments('-include', 'config.h', language : 'c')
 
+# FEATURE_TEST_MACROS(7)
+# performs lightweight overflow checks on quite a few libc functions
+# requires -O optimizations
+if  ['debugoptimized', 'release', 'minsize'].contains(get_option('buildtype'))
+	add_project_arguments('-D_FORTIFY_SOURCE=2', language : 'c')
+endif
+
 config.set('PACKAGE_NAME', meson.project_name())
 config.set_quoted('PACKAGE_VERSION', meson.project_version())
 config.set_quoted('PACKAGE', meson.project_name())
-- 
2.20.1



More information about the igt-dev mailing list