-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better default for MinGW setjmp/longjmp #1443
base: master
Are you sure you want to change the base?
Conversation
I guess that will work, but note that MinGW is not Cygwin. The MinGW compiler is used without and outside of the Cygwin framework and, for example, uses native filenames instead of I don't know what your configuration framework requires and how it makes the distinction between MinGW and Cygwin. |
It needs a way of detecting the compiler/platform from preprocessor defines (without #including files) and then whatever goes. |
@Corion Would |
Ok, so based on the link there's a potential crash issue in longjmp() while __builtin_longjmp() would work. |
According to Stackoverflow and a Sourceforge project collecting #defines , the following should work to identify MinGW: #ifdef MINGW32 On 64bit, the following also is enabled: #ifdef MINGW64 Unfortunately, I don't know much about the differences between longjmp, _longjmp, __longjmp and __builtin_longjmp - I just took a solution I found and applied it here ;) |
C and C++ (lang/compillers) exceptions handlers differs, i.e., https://msdn.microsoft.com/pt-br/library/yz2ez4as(v=vs.110).aspx Lua uses a tiny approach to handle it. NOTE: i know, duktape are written in ANSI C, but, can be compilled using c++ [same lua] |
@denisdemaisbr The easiest approach would be to rely on ANSI setjmp()/longjmp() and any platform missing it would need to supply it separately. That was pretty much the original approach but there are various reasons (performance, signal handling) to use different variants on each platform. So ultimately I can only rely on the input from people working on each platform as to what the appropriate default (that is, suitable for the majority of users on that platform) would be. Duktape does support C++ exceptions which allows proper C++ unwinding, -DDUK_USE_CPP_EXCEPTIONS. It's not the default because C++ environments don't always have exception support enabled. |
Ok, I've updated the pull so that MinGW with POSIX (Cygwin) and Windows targets should now use
If anyone can confirm whether this is correct, that'd be nice. |
2d489b1
to
78e1763
Compare
Also one thing to consider: should config/platforms/platform_cygwin.h.in define the OS string as "cygwin" rather than "windows"? If so, a POSIX/Cygwin build would identify as "mingw cygwin". |
I happened to have an unused Windows 10 VM around so I quickly checked that Cygwin GCC doesn't identify as MinGW (= doesn't trigger I've updated the diff to reflect this; config/platforms/platform_cygwin.h.in uses _setjmp()/_longjmp() as before, and now sets the OS string to "cygwin" and not "windows". |
Use __builtin_{setjmp,longjmp}() for MinGW for both POSIX and Windows build targets, to avoid issues described in: - http://www.agardner.me/golang/windows/cgo/64-bit/setjmp/longjmp/2016/02/29/go-windows-setjmp-x86.html
77b1c9d
to
d5b7a8f
Compare
@svaarala I've been checking this yesterday and I came to a conclusion that this may happened because of a bad design from my side, or maybe perl itself :P I've been compiling Duktape along side with perl headers, perl redefines setjmp This is already confusing to me so I think this exact case is a major header pollution, separate the build process and linking duktape fixed the problem, at least for me, I'll check with @Corion and I'll try to test duktape compiling under MingW, I'll be commenting here if I find anything. |
Proposal from IRC: mamod/JavaScript-Duktape@91f0ef2.
Changes: