summary refs log tree commit diff stats
path: root/util/coroutine-sigaltstack.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2023-10-03 10:15:49 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2023-10-04 09:52:06 -0400
commit9afa888ce0f816d0f2cfc95eebe4f49244c518af (patch)
treeb549bb1bc3c3c8dc693dd5c52be2280e94d49305 /util/coroutine-sigaltstack.c
parentda1034094d375afe9e3d8ec8980550ea0f06f7e0 (diff)
downloadfocaccia-qemu-9afa888ce0f816d0f2cfc95eebe4f49244c518af.tar.gz
focaccia-qemu-9afa888ce0f816d0f2cfc95eebe4f49244c518af.zip
osdep: set _FORTIFY_SOURCE=2 when optimization is enabled
Currently we set _FORTIFY_SOURCE=2 as a compiler argument when the
meson 'optimization' setting is non-zero, the compiler is GCC and
the target is Linux.

While the default QEMU optimization level is 2, user could override
this by setting CFLAGS="-O0" or --extra-cflags="-O0" when running
configure and this won't be reflected in the meson 'optimization'
setting. As a result we try to enable _FORTIFY_SOURCE=2 and then the
user gets compile errors as it only works with optimization.

Rather than trying to improve detection in meson, it is simpler to
just check the __OPTIMIZE__ define from osdep.h.

The comment about being incompatible with clang appears to be
outdated, as compilation works fine without excluding clang.

In the coroutine code we must set _FORTIFY_SOURCE=0 to stop the
logic in osdep.h then enabling it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20231003091549.223020-1-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'util/coroutine-sigaltstack.c')
-rw-r--r--util/coroutine-sigaltstack.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/coroutine-sigaltstack.c b/util/coroutine-sigaltstack.c
index e2690c5f41..037d6416c4 100644
--- a/util/coroutine-sigaltstack.c
+++ b/util/coroutine-sigaltstack.c
@@ -22,9 +22,9 @@
  */
 
 /* XXX Is there a nicer way to disable glibc's stack check for longjmp? */
-#ifdef _FORTIFY_SOURCE
 #undef _FORTIFY_SOURCE
-#endif
+#define _FORTIFY_SOURCE 0
+
 #include "qemu/osdep.h"
 #include <pthread.h>
 #include "qemu/coroutine_int.h"