summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-09-19 16:39:43 +0300
committerJacopo Mondi <jacopo.mondi@ideasonboard.com>2023-09-21 15:24:37 +0200
commit1d616141420d1f51e5999d758e3e0cc721a46290 (patch)
tree14d7c74f831e2ccd3157da13cd60e0ccc86878ee
parentdbe4e0e9457c349ea6a797b62d5f55e15c67f642 (diff)
meson: Simplify check for _FORTIFY_SOURCE
Use the compiler.get_define() function to get the value of _FORTIFY_SOURCE instead of iterating over the cpp_args. This simplies the code, but also guarantees to return the actual value of _FORTIFY_SOURCE, even if defined through other means than through the meson cpp_args. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: George Burgess IV <gbiv@google.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
-rw-r--r--meson.build14
1 files changed, 3 insertions, 11 deletions
diff --git a/meson.build b/meson.build
index 2e834263..e9a1c7e3 100644
--- a/meson.build
+++ b/meson.build
@@ -104,17 +104,9 @@ if cc.get_id() == 'clang'
# result in macro redefinition errors if the user already has a setting for
# `-D_FORTIFY_SOURCE`. Do not enable FORTIFY in either of those cases.
if get_option('optimization') != '0'
- has_fortify_define = false
- # Assume that if the user requests a FORTIFY level in cpp_args, they
- # do the same for c_args.
- foreach flag : get_option('cpp_args')
- if flag == '-U_FORTIFY_SOURCE'
- has_fortify_define = false
- elif flag.startswith('-D_FORTIFY_SOURCE=')
- has_fortify_define = true
- endif
- endforeach
- if not has_fortify_define
+ fortify = cc.get_define('_FORTIFY_SOURCE')
+ if fortify == ''
+ message('Adding _FORTIFY_SOURCE')
common_arguments += [
'-D_FORTIFY_SOURCE=2',
]