spirv: workaround setjmp/longjmp crash on MinGW

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7555>
This commit is contained in:
Michel Zou 2020-11-11 19:16:50 +01:00 committed by Marge Bot
parent 9e4f588318
commit f493fc5fa2
3 changed files with 12 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);