* [PATCH] win32: avoid discarding the exception handler
@ 2023-09-25 11:39 marcandre.lureau
2023-09-25 11:56 ` Thomas Huth
0 siblings, 1 reply; 2+ messages in thread
From: marcandre.lureau @ 2023-09-25 11:39 UTC (permalink / raw)
To: qemu-devel; +Cc: thuth, Marc-André Lureau, Stefan Weil
From: Marc-André Lureau <marcandre.lureau@redhat.com>
In all likelihood, the compiler with lto doesn't see the function being
used, from assembly macro __try1. Help it by marking the function has
being used.
Fixes:
https://gitlab.com/qemu-project/qemu/-/issues/1904
Fixes: commit d89f30b4df ("win32: wrap socket close() with an exception handler")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/qemu/compiler.h | 6 ++++++
util/oslib-win32.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index a309f90c76..5c7f63f351 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -197,4 +197,10 @@
#define BUILTIN_SUBCLL_BROKEN
#endif
+#if __has_attribute(used)
+# define QEMU_USED __attribute__((used))
+#else
+# define QEMU_USED
+#endif
+
#endif /* COMPILER_H */
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 19a0ea7fbe..55b0189dc3 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -479,7 +479,7 @@ int qemu_bind_wrap(int sockfd, const struct sockaddr *addr,
return ret;
}
-EXCEPTION_DISPOSITION
+QEMU_USED EXCEPTION_DISPOSITION
win32_close_exception_handler(struct _EXCEPTION_RECORD *exception_record,
void *registration, struct _CONTEXT *context,
void *dispatcher)
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] win32: avoid discarding the exception handler
2023-09-25 11:39 [PATCH] win32: avoid discarding the exception handler marcandre.lureau
@ 2023-09-25 11:56 ` Thomas Huth
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Huth @ 2023-09-25 11:56 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Stefan Weil
On 25/09/2023 13.39, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> In all likelihood, the compiler with lto doesn't see the function being
> used, from assembly macro __try1. Help it by marking the function has
> being used.
>
> Fixes:
I'd suggest to use "Resolves:" for bug tickets so that they get auto-closed
when the patch is merged.
> https://gitlab.com/qemu-project/qemu/-/issues/1904
>
> Fixes: commit d89f30b4df ("win32: wrap socket close() with an exception handler")
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/qemu/compiler.h | 6 ++++++
> util/oslib-win32.c | 2 +-
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index a309f90c76..5c7f63f351 100644
> --- a/include/qemu/compiler.h
> +++ b/include/qemu/compiler.h
> @@ -197,4 +197,10 @@
> #define BUILTIN_SUBCLL_BROKEN
> #endif
>
> +#if __has_attribute(used)
> +# define QEMU_USED __attribute__((used))
> +#else
> +# define QEMU_USED
> +#endif
I first thought we could maybe do it without the detour via the QEMU_USED
macro, but seems like Clang just learnt this attribute with version 13:
https://releases.llvm.org/12.0.0/tools/clang/docs/AttributeReference.html
https://releases.llvm.org/13.0.0/tools/clang/docs/AttributeReference.html
(while GCC already has it in version 7).
So yes, this seems the right way to do this.
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-25 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-25 11:39 [PATCH] win32: avoid discarding the exception handler marcandre.lureau
2023-09-25 11:56 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).