meson.build: Disable -fzero-call-used-regs on OpenBSD
PATCH 1/1 meson.build: Disable -fzero-call-used-regs on OpenBSD
QEMU currently does not work on OpenBSD since the -fzero-call-used-regs option that we added to meson.build recently does not work with the "retguard" extension from OpenBSD's Clang. Thus let's disable the -fzero-call-used-regs here until there's a better solution available.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2278
---
Note: Given that we're close to the release, I think the host_os check is the best we can do ... the problem does not seem to trigger in all functions, only if certain registers are used by the compiler, so a more sophisticated check here seems to be too fragile to me right now.
meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
meson.build +5 -1
@@ -562,7 +562,11 @@ hardening_flags = [ # # 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(); }', +# +# NB2: This clashes with the "retguard" extension of OpenBSD's Clang +# https://gitlab.com/qemu-project/qemu/-/issues/2278 +if host_os != 'openbsd' and \ + 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'
Signature · 1 line
2.44.0
Quoted 1 line · Thomas Huth
QEMU currently does not work on OpenBSD since the -fzero-call-used-regs
That should be "OpenBSD 7.5" ... older versions are fine since they are using an older version of Clang that does not have -fzero-call-used-regs yet, I think.
Thomas
Quoted 32 lines
option that we added to meson.build recently does not work with the "retguard" extension from OpenBSD's Clang. Thus let's disable the -fzero-call-used-regs here until there's a better solution available.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2278
Signed-off-by Thomas Huth <[email protected]>---
Note: Given that we're close to the release, I think thehost_oscheck is the best we can do ... the problem does not seem to trigger in all functions, only if certain registers are used by the compiler, so a more sophisticated check here seems to be too fragile to me right now.meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)meson.build +5
-1@@ -562,7 +562,11 @@ hardening_flags = [ # # 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(); }', +# +# NB2: This clashes with the "retguard" extension of OpenBSD's Clang +# https://gitlab.com/qemu-project/qemu/-/issues/2278 +if host_os != 'openbsd' and \ + 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'
Quoted 5 lines · Thomas Huth
Quoted 1 line · Thomas Huth
QEMU currently does not work on OpenBSD since the -fzero-call-used-regs
That should be "OpenBSD 7.5" ... older versions are fine since they are using an older version of Clang that does not have -fzero-call-used-regs yet, I think.
About the compiler version that is correct. Between 7.4 and 7.5 we upgraded from Clang 13 to 16.
-fzero-call-used-regs was added with the 15 release.
https://github.com/llvm/llvm-project/commit/deaf22bc0e306bc44c70d2503e9364b5ed312c49
Retguard is also used to mitigate ROP exploits and is enabled by default.
Quoted 23 lines · Thomas Huth
QEMU currently does not work on OpenBSD since the -fzero-call-used-regs option that we added to meson.build recently does not work with the "retguard" extension from OpenBSD's Clang. Thus let's disable the -fzero-call-used-regs here until there's a better solution available.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2278
Signed-off-by Thomas Huth <[email protected]>---
Note: Given that we're close to the release, I think thehost_oscheck is the best we can do ... the problem does not seem to trigger in all functions, only if certain registers are used by the compiler, so a more sophisticated check here seems to be too fragile to me right now.meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)meson.build +0
-0@@ -562,7 +562,11 @@ hardening_flags = [ # # NB: Clang 17 is broken and SEGVs
meson.build hardening_flags = [ · line 572
Quoted 10 lines
meson.build +5
-1# https://github.com/llvm/llvm-project/issues/75168 -if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }', +# +# NB2: This clashes with the "retguard" extension of OpenBSD's Clang +# https://gitlab.com/qemu-project/qemu/-/issues/2278 +if host_os != 'openbsd' and \ + 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'
Paolo Bonzini
AppliedQueued, thanks.
Paolo