Tk Source Code

View Ticket
Login
Ticket UUID: 7d6590d964a6f5c29edcaaac9d66dffdc261e40c
Title: Mingw-64 has SEH
Type: Patch Version:
Submitter: oscarfv Created on: 2025-10-26 14:01:28
Subsystem: 85. Win Build Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2025-10-27 10:40:12
Resolution: Invalid Closed By: oscarfv
    Closed on: 2025-10-27 10:40:12
Description:
Although gcc does not support the __try...__except syntax extension, Mingw-w64 runtime has the necessary support for SEH to not need the code within the #ifdef HAVE_NO_SEH in win/tkWin32Dll.c and for many years we are using this patch in MSYS2/Mingw-packages:


diff -Naur tk8.6.5-orig/win/tkWin32Dll.c tk8.6.5/win/tkWin32Dll.c
--- tk8.6.5-orig/win/tkWin32Dll.c	2014-02-10 23:03:05.000000000 +0400
+++ tk8.6.5/win/tkWin32Dll.c	2016-03-03 09:21:53.742037200 +0300
@@ -12,7 +12,7 @@
 #include "tkWinInt.h"
 #ifndef STATIC_BUILD
 
-#ifdef HAVE_NO_SEH
+#if defined(HAVE_NO_SEH) && __MINGW64_VERSION_MAJOR < 3
 
 /*
  * Unlike Borland and Microsoft, we don't register exception handlers by

It would be nice if the configure script detect Mingw-w64 and then not define HAVE_NO_SEH, but otherwise the above patch does the job.
User Comments: oscarfv added on 2025-10-27 10:40:12:
Yeah, the patch makes no sense. Digging on the git history, it looks like a half-baked early experiment.

Please accept my apologies.

jan.nijtmans added on 2025-10-27 09:07:43:

As I suspected, the build fails with your suggestion:

See: https://github.com/tcltk/tk/actions/runs/18832518106/job/53726499263


oscarfv added on 2025-10-26 22:28:22:
After your comment I looked at how this patch is used on our builds.

It turns out that this patch was dropped shortly after the creation of the mingw-w64-tk package but none of us maintainers noticed the fact and hence it was never deleted.

In msys2/mingw-packages there is the bad practice of not documenting why patches are added or dropped. Then, many years after, this happens :-(

I'm very sorry for wasting your time.

Hopefully the other tickets will prove useful. My intent is to have a patch-free msys2/mingw-w64 tcl/tk 9 build.

jan.nijtmans added on 2025-10-26 21:30:46:

Does [ad32c99356f987d4|this] work for you?

I'm puzzled how it's possible that Mingw-w64 has SEH, but doesn't have __try__. Tk doesn't have a code-path for this combination, as far as I can see.