Skip to contentSkip to conversation

11.2 - Build fix windows-arm64

GIT PULL Applied Pierrick Bouvier 2 participants 8 messages Dec 2 – Dec 3 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

The following changes since commit 3c061218fcf37a98c944ecb88cff56f94f5c0a43:

Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging (2026-12-01 07:34:03 -0800)

are available in the Git repository at:

https://gitlab.com/p-b-o/qemu tags/pbouvier/pr/build_windows_arm64-20261201

for you to fetch changes up to 36dcd51bbd87168879a29620e8bbefe678d82c12:

meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp (2026-12-01 17:45:13 -0700)

----------------------------------------------------------------
Changes:
- [PATCH] meson.build: windows-arm64 build fix, (Pierrick Bouvier <[email protected]>)

----------------------------------------------------------------
Pierrick Bouvier (1):
meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp

 include/system/os-win32.h | 14 ++++++++------
 meson.build               |  6 +++---
 2 files changed, 11 insertions(+), 9 deletions(-)
#1 lore raw

[PULL 1/1] meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp

mingw-w64 removed __mingw_setjmp for aarch64, as its usage was replaced by _setjmpex, which has the same functionality:
https://github.com/mingw-w64/mingw-w64/commit/326b51ef75c4dde099edb063a573b7d114a93af1

This change reached MSYS2 with toolchain update a few days ago, mingw-w64-clang-aarch64-crt14.0.0.r757.g7dceb7d77, and configure now fails on windows-arm64:

ld.lld: error: undefined symbol: __mingw_setjmp ../meson.build:3226:4: ERROR: Problem encountered: mingw must provide setjmp/longjmp for windows-arm64

_setjmpex is provided by the Windows CRT, so this works with both older and newer mingw-w64 versions.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/5052

---
 include/system/os-win32.h | 14 ++++++++------
 meson.build               |  6 +++---
 2 files changed, 11 insertions(+), 9 deletions(-)
include/system/os-win32.h +8 -6
index 22d72babdf4..f3896763cdd 100644
@@ -56,19 +56,21 @@ extern "C" {
 /*
  * On windows-arm64, setjmp is available in only one variant, and longjmp always
  * does stack unwinding. This crash with generated code.
- * Thus, we use another implementation of setjmp (not windows one), coming from
+ * Thus, we use another implementation of longjmp (not windows one), coming from
  * mingw, which never performs stack unwinding.
+ *
+ * mingw used to provide __mingw_setjmp, but it was removed in favor of
+ * _setjmpex(env, NULL):
+ * https://github.com/mingw-w64/mingw-w64/commit/326b51ef75c4dde099edb063a573b7d114a93af1
  */
 #undef setjmp
 #undef longjmp
 /*
- * These functions are not declared in setjmp.h because __aarch64__ defines
- * setjmp to _setjmpex instead. However, they are still defined in libmingwex.a,
- * which gets linked automatically.
+ * __mingw_longjmp is not always declared in setjmp.h, but it is defined in
+ * libmingwex.a, which gets linked automatically.
  */
-int __mingw_setjmp(jmp_buf);
 void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);
-#define setjmp(env) __mingw_setjmp(env)
+#define setjmp(env) _setjmpex(env, NULL)
 #define longjmp(env, val) __mingw_longjmp(env, val)
 #elif defined(_WIN64)
 /*
meson.build +3 -3
index f8dd3926dd8..35e10d8cf10 100644
@@ -3209,15 +3209,15 @@ endif
 if host_os == 'windows'
   mingw_has_setjmp_longjmp = cc.links('''
     #include <setjmp.h>
+    #include <stddef.h>
     int main(void) {
       /*
-       * These functions are not available in setjmp header, but may be
+       * __mingw_longjmp is not always declared in setjmp header, but may be
        * available at link time, from libmingwex.a.
        */
-      extern int __mingw_setjmp(jmp_buf);
       extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);
       jmp_buf env;
-      __mingw_setjmp(env);
+      _setjmpex(env, NULL);
       __mingw_longjmp(env, 0);
     }
   ''', name: 'mingw setjmp and longjmp')
Signature · 1 line
2.47.3
#2 lore raw

Re: [PULL 1/1] meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp

Quoted 67 lines · Pierrick Bouvier

mingw-w64 removed __mingw_setjmp for aarch64, as its usage was replaced by _setjmpex, which has the same functionality:
https://github.com/mingw-w64/mingw-w64/commit/326b51ef75c4dde099edb063a573b7d114a93af1

This change reached MSYS2 with toolchain update a few days ago, mingw-w64-clang-aarch64-crt14.0.0.r757.g7dceb7d77, and configure now fails on windows-arm64:

ld.lld: error: undefined symbol: __mingw_setjmp ../meson.build:3226:4: ERROR: Problem encountered: mingw must provide setjmp/longjmp for windows-arm64

_setjmpex is provided by the Windows CRT, so this works with both older and newer mingw-w64 versions.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/5052

---
  include/system/os-win32.h | 14 ++++++++------
  meson.build               |  6 +++---
  2 files changed, 11 insertions(+), 9 deletions(-)
include/system/os-win32.h +8 -6
index 22d72babdf4..f3896763cdd 100644
@@ -56,19 +56,21 @@ extern "C" {
  /*
   * On windows-arm64, setjmp is available in only one variant, and longjmp always
   * does stack unwinding. This crash with generated code.
- * Thus, we use another implementation of setjmp (not windows one), coming from
+ * Thus, we use another implementation of longjmp (not windows one), coming from
   * mingw, which never performs stack unwinding.
+ *
+ * mingw used to provide __mingw_setjmp, but it was removed in favor of
+ * _setjmpex(env, NULL):
+ * https://github.com/mingw-w64/mingw-w64/commit/326b51ef75c4dde099edb063a573b7d114a93af1
   */
  #undef setjmp
  #undef longjmp
  /*
- * These functions are not declared in setjmp.h because __aarch64__ defines
- * setjmp to _setjmpex instead. However, they are still defined in libmingwex.a,
- * which gets linked automatically.
+ * __mingw_longjmp is not always declared in setjmp.h, but it is defined in
+ * libmingwex.a, which gets linked automatically.
   */
-int __mingw_setjmp(jmp_buf);
  void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);
-#define setjmp(env) __mingw_setjmp(env)
+#define setjmp(env) _setjmpex(env, NULL)
  #define longjmp(env, val) __mingw_longjmp(env, val)
  #elif defined(_WIN64)
  /*
meson.build +1 -0
index f8dd3926dd8..35e10d8cf10 100644
@@ -3209,15 +3209,15 @@ endif
  if host_os == 'windows'
    mingw_has_setjmp_longjmp = cc.links('''
      #include <setjmp.h>
+    #include <stddef.h>
      int main(void) {
        /*

meson.build endif · line 3221

Quoted 10 lines
meson.build +2 -3
-       * These functions are not available in setjmp header, but may be
+       * __mingw_longjmp is not always declared in setjmp header, but may be
         * available at link time, from libmingwex.a.
         */
-      extern int __mingw_setjmp(jmp_buf);
        extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);
        jmp_buf env;
-      __mingw_setjmp(env);
+      _setjmpex(env, NULL);
        __mingw_longjmp(env, 0);

Is it really a good idea to mix interfaces like this? Surely _setjmpex should be paired with _longjmpex.

r~

#3 lore raw

Re: [PULL 1/1] meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp

Quoted 85 lines · Richard Henderson
Quoted 84 lines · Pierrick Bouvier

mingw-w64 removed __mingw_setjmp for aarch64, as its usage was replaced by _setjmpex, which has the same functionality:
https://github.com/mingw-w64/mingw-w64/
commit/326b51ef75c4dde099edb063a573b7d114a93af1

This change reached MSYS2 with toolchain update a few days ago, mingw-w64-clang-aarch64-crt14.0.0.r757.g7dceb7d77, and configure now fails on windows-arm64:

   ld.lld: error: undefined symbol: __mingw_setjmp ../meson.build:3226:4: ERROR: Problem encountered: mingw must provide setjmp/longjmp for windows-arm64

_setjmpex is provided by the Windows CRT, so this works with both older and newer mingw-w64 versions.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/5052

[email protected]

---
  include/system/os-win32.h | 14 ++++++++------
  meson.build               |  6 +++---

  2 files changed, 11 insertions(+), 9 deletions(-)
include/system/os-win32.h +0 -0
index 22d72babdf4..f3896763cdd 100644
@@ -56,19 +56,21 @@ extern "C" {
   /*
    * On windows-arm64, setjmp is available in only one variant, and

longjmp always
   * does stack unwinding. This crash with generated code.
- * Thus, we use another implementation of setjmp (not windows one), coming from
+ * Thus, we use another implementation of longjmp (not windows one), coming from
   * mingw, which never performs stack unwinding.
+ *
+ * mingw used to provide __mingw_setjmp, but it was removed in favor of
+ * _setjmpex(env, NULL):
+ * https://github.com/mingw-w64/mingw-w64/
commit/326b51ef75c4dde099edb063a573b7d114a93af1
   */
  #undef setjmp
  #undef longjmp
  /*
- * These functions are not declared in setjmp.h because __aarch64__ defines
- * setjmp to _setjmpex instead. However, they are still defined in libmingwex.a,
- * which gets linked automatically.
+ * __mingw_longjmp is not always declared in setjmp.h, but it is defined in
+ * libmingwex.a, which gets linked automatically.
   */
-int __mingw_setjmp(jmp_buf);
  void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);

include/system/os-win32.h +1 -1
-#define setjmp(env) __mingw_setjmp(env)
+#define setjmp(env) _setjmpex(env, NULL)

  #define longjmp(env, val) __mingw_longjmp(env, val) #elif defined(_WIN64)
  /*

meson.build +0 -0
index f8dd3926dd8..35e10d8cf10 100644
@@ -3209,15 +3209,15 @@ endif

  if host_os == 'windows'
    mingw_has_setjmp_longjmp = cc.links('''
      #include <setjmp.h>
+    #include <stddef.h>
      int main(void) {
        /*
-       * These functions are not available in setjmp header, but may be +       * __mingw_longjmp is not always declared in setjmp header, but may be
         * available at link time, from libmingwex.a.
         */
-      extern int __mingw_setjmp(jmp_buf);
        extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);

Quoted 9 lines
Quoted 4 lines

        jmp_buf env;
-      __mingw_setjmp(env);
+      _setjmpex(env, NULL);
        __mingw_longjmp(env, 0);

Is it really a good idea to mix interfaces like this? Surely _setjmpex should be paired with _longjmpex.

_longjmpex triggers a stack unwinding (with SEH), which crashes with our generated code. That was the original reason to use mingw variants. the setjmpex does not have any side effect like this, which is why mingw commit says it can replace __mingw_setjmp, and why they left __mingw_longjmp.

IMHO, the right way in MinGW should have been to leave __mingw_setjmp defined (and defined as _setjmpex) instead of just removing it.

I tested this patch on windows-arm64 by the way.

Regards,
Pierrick

#4 lore raw

Re: [PULL 1/1] meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp

Quoted 96 lines · Pierrick Bouvier
Quoted 85 lines · Richard Henderson
Quoted 84 lines · Pierrick Bouvier

mingw-w64 removed __mingw_setjmp for aarch64, as its usage was replaced by _setjmpex, which has the same functionality:
https://github.com/mingw-w64/mingw-w64/
commit/326b51ef75c4dde099edb063a573b7d114a93af1

This change reached MSYS2 with toolchain update a few days ago, mingw-w64-clang-aarch64-crt14.0.0.r757.g7dceb7d77, and configure now fails on windows-arm64:

   ld.lld: error: undefined symbol: __mingw_setjmp ../meson.build:3226:4: ERROR: Problem encountered: mingw must provide setjmp/longjmp for windows-arm64

_setjmpex is provided by the Windows CRT, so this works with both older and newer mingw-w64 versions.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/5052

[email protected]

---
  include/system/os-win32.h | 14 ++++++++------
  meson.build               |  6 +++---

  2 files changed, 11 insertions(+), 9 deletions(-)
include/system/os-win32.h +0 -0
index 22d72babdf4..f3896763cdd 100644
@@ -56,19 +56,21 @@ extern "C" {
   /*
    * On windows-arm64, setjmp is available in only one variant, and

longjmp always
   * does stack unwinding. This crash with generated code.
- * Thus, we use another implementation of setjmp (not windows one), coming from
+ * Thus, we use another implementation of longjmp (not windows one), coming from
   * mingw, which never performs stack unwinding.
+ *
+ * mingw used to provide __mingw_setjmp, but it was removed in favor of
+ * _setjmpex(env, NULL):
+ * https://github.com/mingw-w64/mingw-w64/
commit/326b51ef75c4dde099edb063a573b7d114a93af1
   */
  #undef setjmp
  #undef longjmp
  /*
- * These functions are not declared in setjmp.h because __aarch64__ defines
- * setjmp to _setjmpex instead. However, they are still defined in libmingwex.a,
- * which gets linked automatically.
+ * __mingw_longjmp is not always declared in setjmp.h, but it is defined in
+ * libmingwex.a, which gets linked automatically.
   */
-int __mingw_setjmp(jmp_buf);
  void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);

include/system/os-win32.h +1 -1
-#define setjmp(env) __mingw_setjmp(env)
+#define setjmp(env) _setjmpex(env, NULL)

  #define longjmp(env, val) __mingw_longjmp(env, val) #elif defined(_WIN64)
  /*

meson.build +0 -0
index f8dd3926dd8..35e10d8cf10 100644
@@ -3209,15 +3209,15 @@ endif

  if host_os == 'windows'
    mingw_has_setjmp_longjmp = cc.links('''
      #include <setjmp.h>
+    #include <stddef.h>
      int main(void) {
        /*
-       * These functions are not available in setjmp header, but may be +       * __mingw_longjmp is not always declared in setjmp header, but may be
         * available at link time, from libmingwex.a.
         */
-      extern int __mingw_setjmp(jmp_buf);
        extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);

Quoted 9 lines
Quoted 4 lines

        jmp_buf env;
-      __mingw_setjmp(env);
+      _setjmpex(env, NULL);
        __mingw_longjmp(env, 0);

Is it really a good idea to mix interfaces like this? Surely _setjmpex should be paired with _longjmpex.

Quoted 9 lines

_longjmpex triggers a stack unwinding (with SEH), which crashes with our generated code. That was the original reason to use mingw variants. the setjmpex does not have any side effect like this, which is why mingw commit says it can replace __mingw_setjmp, and why they left __mingw_longjmp.

IMHO, the right way in MinGW should have been to leave __mingw_setjmp defined (and defined as _setjmpex) instead of just removing it.

By the way, if you dig on this topic, you'll hear about __USE_MINGW_SETJMP_NON_SEH define, which is supposed to do what we do here.

That said, it was introduced 3 years ago, and I didn't test if it still worked as expected. Also, I didn't hear about it before writing the current patch, and since it was already tested/published and that release is in a few days, I thought it was a better thing to send the current one.

Quoted 4 lines

I tested this patch on windows-arm64 by the way.

Regards,
Pierrick

#5 lore raw

Re: [PULL 1/1] meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp

In reply to Pierrick Bouvier
Quoted 6 lines · Pierrick Bouvier
Quoted 3 lines

Is it really a good idea to mix interfaces like this? Surely _setjmpex should be paired with _longjmpex.

_longjmpex triggers a stack unwinding (with SEH), which crashes with our generated code.

Of course. I should have remembered that.

A point for improvement if we ever have someone paid to care about windows in the future, registering unwind info for the JIT, if only for better debugging.

Quoted 2 lines

IMHO, the right way in MinGW should have been to leave __mingw_setjmp defined (and defined as _setjmpex) instead of just removing it.

Agreed.

Quoted 1 line

I tested this patch on windows-arm64 by the way.

Thanks.

r~

#6 lore raw
In reply to Pierrick Bouvier
Quoted 17 lines · Pierrick Bouvier

The following changes since commit 3c061218fcf37a98c944ecb88cff56f94f5c0a43:

   Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging (2026-12-01 07:34:03 -0800)

are available in the Git repository at:

   https://gitlab.com/p-b-o/qemu tags/pbouvier/pr/build_windows_arm64-20261201

for you to fetch changes up to 36dcd51bbd87168879a29620e8bbefe678d82c12:

   meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp (2026-12-01 17:45:13 -0700)

----------------------------------------------------------------
Changes:
- [PATCH] meson.build: windows-arm64 build fix, (Pierrick Bouvier <[email protected]>)

Quoted 7 lines

----------------------------------------------------------------
Pierrick Bouvier (1):
meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp

  include/system/os-win32.h | 14 ++++++++------
  meson.build               |  6 +++---
  2 files changed, 11 insertions(+), 9 deletions(-)

The timing for this regression is a bit unfortunate, just before our release, but would definitely be great if we could have this for 11.2.

Regards,
Pierrick

#7 lore raw
In reply to Pierrick Bouvier
Quoted 17 lines · Pierrick Bouvier

The following changes since commit 3c061218fcf37a98c944ecb88cff56f94f5c0a43:

   Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging (2026-12-01 07:34:03 -0800)

are available in the Git repository at:

   https://gitlab.com/p-b-o/qemu tags/pbouvier/pr/build_windows_arm64-20261201

for you to fetch changes up to 36dcd51bbd87168879a29620e8bbefe678d82c12:

   meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp (2026-12-01 17:45:13 -0700)

----------------------------------------------------------------
Changes:
- [PATCH] meson.build: windows-arm64 build fix, (Pierrick Bouvier <[email protected]>)

Quoted 7 lines

----------------------------------------------------------------
Pierrick Bouvier (1):
meson.build: windows-arm64 build fix, use _setjmpex instead of (removed) __mingw_setjmp

  include/system/os-win32.h | 14 ++++++++------
  meson.build               |  6 +++---
  2 files changed, 11 insertions(+), 9 deletions(-)

Applied, thanks.

r~