Mesa (master): spirv: workaround setjmp/longjmp crash on MinGW
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Nov 18 14:10:46 UTC 2020
Module: Mesa
Branch: master
Commit: f493fc5fa2b1acb620f7d2fb052273502edf8e92
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f493fc5fa2b1acb620f7d2fb052273502edf8e92
Author: Michel Zou <xantares09 at hotmail.com>
Date: Wed Nov 11 19:16:50 2020 +0100
spirv: workaround setjmp/longjmp crash on MinGW
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7555>
---
src/compiler/spirv/gl_spirv.c | 2 +-
src/compiler/spirv/spirv_to_nir.c | 4 ++--
src/compiler/spirv/vtn_private.h | 9 +++++++++
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/compiler/spirv/gl_spirv.c b/src/compiler/spirv/gl_spirv.c
index 55b4437cb13..5ef38928edd 100644
--- a/src/compiler/spirv/gl_spirv.c
+++ b/src/compiler/spirv/gl_spirv.c
@@ -238,7 +238,7 @@ gl_spirv_validation(const uint32_t *words, size_t word_count,
return false;
/* See also _vtn_fail() */
- if (setjmp(b->fail_jump)) {
+ if (vtn_setjmp(b->fail_jump)) {
ralloc_free(b);
return false;
}
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index de3d12dc757..73f3a7b62b1 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -160,7 +160,7 @@ _vtn_fail(struct vtn_builder *b, const char *file, unsigned line,
if (dump_path)
vtn_dump_shader(b, dump_path, "fail");
- longjmp(b->fail_jump, 1);
+ vtn_longjmp(b->fail_jump, 1);
}
static struct vtn_ssa_value *
@@ -5744,7 +5744,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
return NULL;
/* See also _vtn_fail() */
- if (setjmp(b->fail_jump)) {
+ if (vtn_setjmp(b->fail_jump)) {
ralloc_free(b);
return NULL;
}
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 45187a092c7..97fc67f8493 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -40,6 +40,15 @@
struct vtn_builder;
struct vtn_decoration;
+/* setjmp/longjmp is broken on MinGW: https://sourceforge.net/p/mingw-w64/bugs/406/ */
+#ifdef __MINGW32__
+ #define vtn_setjmp __builtin_setjmp
+ #define vtn_longjmp __builtin_longjmp
+#else
+ #define vtn_setjmp setjmp
+ #define vtn_longjmp longjmp
+#endif
+
void vtn_log(struct vtn_builder *b, enum nir_spirv_debug_level level,
size_t spirv_offset, const char *message);
More information about the mesa-commit
mailing list