mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
build: move stack protector flag selection to meson
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
6739825aa6
commit
911d4caaa2
4 changed files with 34 additions and 43 deletions
28
meson.build
28
meson.build
|
@ -200,7 +200,7 @@ foreach arg : config_host['QEMU_CFLAGS'].split()
|
|||
endif
|
||||
endforeach
|
||||
qemu_objcflags = config_host['QEMU_OBJCFLAGS'].split()
|
||||
qemu_ldflags = config_host['QEMU_LDFLAGS'].split()
|
||||
qemu_ldflags = []
|
||||
|
||||
if get_option('gprof')
|
||||
qemu_common_flags += ['-p']
|
||||
|
@ -211,6 +211,32 @@ if get_option('prefer_static')
|
|||
qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
|
||||
endif
|
||||
|
||||
if not get_option('stack_protector').disabled()
|
||||
stack_protector_probe = '''
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char arr[64], *p = arr, *c = argv[argc - 1];
|
||||
while (*c) {
|
||||
*p++ = *c++;
|
||||
}
|
||||
return 0;
|
||||
}'''
|
||||
have_stack_protector = false
|
||||
foreach arg : ['-fstack-protector-strong', '-fstack-protector-all']
|
||||
# We need to check both a compile and a link, since some compiler
|
||||
# setups fail only on a .c->.o compile and some only at link time
|
||||
if cc.compiles(stack_protector_probe, args: ['-Werror', arg]) and \
|
||||
cc.links(stack_protector_probe, args: ['-Werror', arg])
|
||||
have_stack_protector = true
|
||||
qemu_cflags += arg
|
||||
qemu_ldflags += arg
|
||||
break
|
||||
endif
|
||||
endforeach
|
||||
get_option('stack_protector') \
|
||||
.require(have_stack_protector, error_message: 'Stack protector not supported')
|
||||
endif
|
||||
|
||||
coroutine_backend = get_option('coroutine_backend')
|
||||
ucontext_probe = '''
|
||||
#include <ucontext.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue