Skip to content

Commit 9aaf1a2

Browse files
committed
throw.h: use setjmp/longjmp with clang on MinGW
The MinGW branch picks __builtin_setjmp/__builtin_longjmp for any compiler that defines __GNUC__ >= 4, and clang does. Clang declares __builtin_setjmp as taking a void **, while jmp_buf on mingw-w64 is an array of struct _SETJMP_FLOAT128, so llvm-mingw (clang 23) stops at the first MRB_TRY/MRC_TRY with -Wincompatible-pointer-types, which is an error there: codegen.c:221:3: error: incompatible pointer types passing 'jmp_buf' (aka 'struct _SETJMP_FLOAT128[16]') to parameter of type 'void **' Casting the buffer to void ** gets the build through, but then the first exception crashes: `begin; raise "x"; rescue; end` segfaults and mrbtest dies before its first test, as #5950 reported. Leave clang out of the builtin branch, as was done for ARM64 in #6637, so it uses the setjmp()/longjmp() from <setjmp.h>. GCC keeps the builtins. The same condition is in mrc_throw.h.
1 parent d474475 commit 9aaf1a2

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎include/mruby/throw.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef void *mrb_jmpbuf_impl;
5757
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
5858
#define MRB_SETJMP _setjmp
5959
#define MRB_LONGJMP _longjmp
60-
#elif defined(__MINGW64__) && !defined(_M_ARM64) && defined(__GNUC__) && __GNUC__ >= 4
60+
#elif defined(__MINGW64__) && !defined(_M_ARM64) && !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4
6161
#define MRB_SETJMP __builtin_setjmp
6262
#define MRB_LONGJMP __builtin_longjmp
6363
#else

‎mrbgems/mruby-compiler/include/mrc_throw.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef void *mrc_jmpbuf_impl;
3333
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
3434
#define MRC_SETJMP _setjmp
3535
#define MRC_LONGJMP _longjmp
36-
#elif defined(__MINGW64__) && !defined(_M_ARM64) && defined(__GNUC__) && __GNUC__ >= 4
36+
#elif defined(__MINGW64__) && !defined(_M_ARM64) && !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4
3737
#define MRC_SETJMP __builtin_setjmp
3838
#define MRC_LONGJMP __builtin_longjmp
3939
#else

0 commit comments

Comments
 (0)