diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2024-03-04 14:44:55 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2024-03-04 15:57:35 +0000 |
commit | 956331108e78cd8cee166a9735fac78c5f36ec55 (patch) | |
tree | a6f05d56848f031a26a995ad9c63e4efe1c4e022 /meson.build | |
parent | eb844330bd36ebdd4959053da08069d1e5d49119 (diff) |
meson: detect broken clang 17 with -fzero-call-used-regs
Clang 17 will segv if given -fzero-call-used-regs and optimization
is enabled. Since upstream hasn't triaged the bug, distros are
increasingly shipping with broken Clang.
https://github.com/llvm/llvm-project/issues/75168
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277474
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20240304144456.3825935-2-berrange@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/meson.build b/meson.build index 0ef1654e86..c59ca496f2 100644 --- a/meson.build +++ b/meson.build @@ -555,17 +555,24 @@ endif # Check further flags that make QEMU more robust against malicious parties hardening_flags = [ - # Zero out registers used during a function call - # upon its return. This makes it harder to assemble - # ROP gadgets into something usable - '-fzero-call-used-regs=used-gpr', - # Initialize all stack variables to zero. This makes # it harder to take advantage of uninitialized stack # data to drive exploits '-ftrivial-auto-var-init=zero', ] +# Zero out registers used during a function call +# upon its return. This makes it harder to assemble +# ROP gadgets into something usable +# +# NB: Clang 17 is broken and SEGVs +# https://github.com/llvm/llvm-project/issues/75168 +if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }', + name: '-fzero-call-used-regs=used-gpr', + args: ['-O2', '-fzero-call-used-regs=used-gpr']) + hardening_flags += '-fzero-call-used-regs=used-gpr' +endif + qemu_common_flags += cc.get_supported_arguments(hardening_flags) add_global_arguments(qemu_common_flags, native: false, language: all_languages) |