aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2022-10-12 11:59:51 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2023-05-18 08:53:52 +0200
commit721fa5e563e8174d6c33e1e413cebb5442625932 (patch)
tree1f5891151063039da0e742be06dff14d075ca17f /meson.build
parent34f983d86fe40ffe5975369c1cf5e6a61688383a (diff)
build: move SafeStack tests to meson
This disables the old behavior of detecting SafeStack from environment CFLAGS. SafeStack is now enabled purely based on the configure arguments. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build26
1 files changed, 26 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index b50b0161ba..22eaca1951 100644
--- a/meson.build
+++ b/meson.build
@@ -211,6 +211,31 @@ if get_option('prefer_static')
qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
endif
+# Compiles if SafeStack *not* enabled
+safe_stack_probe = '''
+ int main(void)
+ {
+ #if defined(__has_feature)
+ #if __has_feature(safe_stack)
+ #error SafeStack Enabled
+ #endif
+ #endif
+ return 0;
+ }'''
+if get_option('safe_stack') != not cc.compiles(safe_stack_probe)
+ safe_stack_arg = get_option('safe_stack') ? '-fsanitize=safe-stack' : '-fno-sanitize=safe-stack'
+ if get_option('safe_stack') != not cc.compiles(safe_stack_probe, args: safe_stack_arg)
+ error(get_option('safe_stack') \
+ ? 'SafeStack not supported by your compiler' \
+ : 'Cannot disable SafeStack')
+ endif
+ qemu_cflags += safe_stack_arg
+ qemu_ldflags += safe_stack_arg
+endif
+if get_option('safe_stack') and config_host['CONFIG_COROUTINE_BACKEND'] != 'ucontext'
+ error('SafeStack is only supported with the ucontext coroutine backend')
+endif
+
if get_option('sanitizers')
if cc.has_argument('-fsanitize=address')
qemu_cflags = ['-fsanitize=address'] + qemu_cflags
@@ -1951,6 +1976,7 @@ config_host_data.set('CONFIG_OPENGL', opengl.found())
config_host_data.set('CONFIG_PROFILER', get_option('profiler'))
config_host_data.set('CONFIG_RBD', rbd.found())
config_host_data.set('CONFIG_RDMA', rdma.found())
+config_host_data.set('CONFIG_SAFESTACK', get_option('safe_stack'))
config_host_data.set('CONFIG_SDL', sdl.found())
config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
config_host_data.set('CONFIG_SECCOMP', seccomp.found())