summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-05-07 14:54:35 +0300
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-05-10 10:58:54 +0300
commit5b51f9e11eda3aeb3a13f50dcbf73320d085f349 (patch)
treee834e7d22d812530b1d9b05a73958ac6749d211b /meson.build
parentefec5d21ee16d47cc4058a935ac37091293f7933 (diff)
meson: Use -D_FORTIFY_SOURCE=2 on optimized builds
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@intel.com> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build7
1 files changed, 7 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 503180edd..a05e912c0 100644
--- a/meson.build
+++ b/meson.build
@@ -256,6 +256,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())