Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Fri, 3 Aug 2018, Liu Hao wrote: 在 2018-08-03 03:16, Martin Storsjö 写道: GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ symbols via a linker script, while lld doesn't. (... ...) -#else -// old method that iterates the list twice because old linker scripts do not have

Re: [Mingw-w64-public] Error Codes Patch

2018-08-02 Thread Liu Hao
在 2018/8/3 1:10, Tom Ritter 写道: > Hit an error compiling Firefox because 1471 wasn't defined. > > -tom > Thanks for the patch. Pushed to master. LRN: He was talking about the value of `ERROR_NOT_GUI_PROCESS` in the patch attached. -- Best regards, LH_Mouse --

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Liu Hao
在 2018-08-03 03:16, Martin Storsjö 写道: > GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ > symbols via a linker script, while lld doesn't. > (... ...) > -#else > -// old method that iterates the list twice because old linker scripts do not > have __CTOR_END__ This drops th

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread JonY via Mingw-w64-public
On 08/02/2018 08:25 PM, Martin Storsjö wrote: > On Thu, 2 Aug 2018, Liu Hao wrote: > >>> index 54cbf02..44ff653 100644 >>> --- a/mingw-w64-crt/crt/gccmain.c >>> +++ b/mingw-w64-crt/crt/gccmain.c >>> @@ -23,18 +23,24 @@ __do_global_dtors (void) >>>   while (*p) >>>   { >>> -  (*(p)) ();

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: index 54cbf02..44ff653 100644 --- a/mingw-w64-crt/crt/gccmain.c +++ b/mingw-w64-crt/crt/gccmain.c @@ -23,18 +23,24 @@ __do_global_dtors (void) while (*p) { - (*(p)) (); + // If the linker provided its own __DTOR_LIST__ in addition to the +

Re: [Mingw-w64-public] [PATCHv2 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/2 19:22, Martin Storsjö 写道: + +typedef void (__thiscall * dtor)(void*); +int __cxa_atexit(dtor dtor, void *obj, void *dso); +int __cxa_thread_atexit(dtor dtor, void *obj, void *dso); + +typedef struct dtor_obj dtor_obj; +struct dtor_obj { + dtor dtor

[Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ symbols via a linker script, while lld doesn't. Due to this, we previously provided our own copy of these symbols while building with clang (assuming that means we'd be linking with lld), see 1e81200e88f. In an attempt to unif

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Martin Storsjö wrote: On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/2 19:02, Martin Storsjö 写道: -#ifdef __clang__ extern func_ptr __CTOR_END__[]; extern func_ptr __DTOR_END__[]; void __do_global_ctors (void) { static func_ptr *p = __CTOR_END__ - 1; + // If the

Re: [Mingw-w64-public] Error Codes Patch

2018-08-02 Thread LRN
On 02.08.2018 20:10, Tom Ritter wrote: > Hit an error compiling Firefox because 1471 wasn't defined. Add more context here because 1471 doesn't ring a bell. signature.asc Description: OpenPGP digital signature -- Check

[Mingw-w64-public] Error Codes Patch

2018-08-02 Thread Tom Ritter
Hit an error compiling Firefox because 1471 wasn't defined. -tom From 71ee4edf14d76ddacb8154620024c7a8b60be18b Mon Sep 17 00:00:00 2001 From: Tom Ritter Date: Thu, 2 Aug 2018 09:50:56 -0500 Subject: [PATCH] Add Error Codes between 1460 and 1471 --- mingw-w64-headers/include/winerror.h| 9 ++

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/2 19:02, Martin Storsjö 写道: -#ifdef __clang__ extern func_ptr __CTOR_END__[]; extern func_ptr __DTOR_END__[]; void __do_global_ctors (void) { static func_ptr *p = __CTOR_END__ - 1; + // If the linker provided its own __CTOR_LIST__ in add

Re: [Mingw-w64-public] [PATCHv2 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-02 Thread Liu Hao
在 2018/8/2 19:22, Martin Storsjö 写道: > + > +typedef void (__thiscall * dtor)(void*); > +int __cxa_atexit(dtor dtor, void *obj, void *dso); > +int __cxa_thread_atexit(dtor dtor, void *obj, void *dso); > + > +typedef struct dtor_obj dtor_obj; > +struct dtor_obj { > + dtor dtor; It is a bit strange

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Liu Hao
在 2018/8/2 19:02, Martin Storsjö 写道: > -#ifdef __clang__ > extern func_ptr __CTOR_END__[]; > extern func_ptr __DTOR_END__[]; > > void __do_global_ctors (void) > { > static func_ptr *p = __CTOR_END__ - 1; > + // If the linker provided its own __CTOR_LIST__ in addition to the one > +

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018-08-02 19:02, Martin Storsjö 写道: Signed-off-by: Martin Storsjö --- mingw-w64-crt/crt/crtdll.c | 2 -- mingw-w64-crt/crt/crtexe.c | 2 -- mingw-w64-crt/crt/gccmain.c | 34 -- 3 files changed, 8 insertions(+), 30 d

[Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ symbols via a linker script, while lld doesn't. Due to this, we previously provided our own copy of these symbols while building with clang (assuming that means we'd be linking with lld), see 1e81200e88f. In an attempt to unif

[Mingw-w64-public] [PATCHv2 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-02 Thread Martin Storsjö
In order to properly call destructors of a DLL when that DLL is unloaded, we need to provide these as part of the static library libmingw32.a, which gets linked into the module itself. C++ libraries (both libstdc++ and libcxxabi) can also provide the function __cxa_thread_atexit, and defer the act

[Mingw-w64-public] [PATCHv2 4/4] crt: Use _register_thread_local_exe_atexit_callback for TLS dtors

2018-08-02 Thread Martin Storsjö
The standard says that destructors of thread local objects should be invoked before any other destructors. Since the destructors are called by the CRT via what has been registered via atexit (ordered so that the function registered last will be executed first), we need to use this API from UCRT to

[Mingw-w64-public] [PATCHv2 3/4] crt: Expose a private variable that indicates whether the module is an exe or dll

2018-08-02 Thread Martin Storsjö
Signed-off-by: Martin Storsjö --- mingw-w64-crt/crt/crtdll.c | 2 ++ mingw-w64-crt/crt/crtexe.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index 50a9eb4..5f53602 100644 --- a/mingw-w64-crt/crt/crtdll.c +++ b/mingw-w64-crt/crt/crt

[Mingw-w64-public] [PATCHv2 2/4] crt: Declare _register_thread_local_exe_atexit_callback in headers, provide fallback

2018-08-02 Thread Martin Storsjö
This function is available in the universal CRT. Add a best effort fallback version of it for other CRTs. Signed-off-by: Martin Storsjö --- mingw-w64-crt/Makefile.am| 1 + mingw-w64-crt/misc/register_tls_atexit.c | 29 + mingw-w64-headers/crt/process

Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-02 Thread Liu Hao
在 2018-08-02 14:58, Martin Storsjö 写道: > Sorry for the double post, I accidentally dropped Liu from the CC of the > previous reply, > It doesn't matter, as I have subscribed to this list, and my client (ThunderBird) filters out duplicate mails. BTW, I have my name spelled in the surname-first

Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-02 Thread Martin Storsjö
Sorry for the double post, I accidentally dropped Liu from the CC of the previous reply, On Thu, 2 Aug 2018, Martin Storsjö wrote: On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/2 13:56, Martin Storsjö 写道: Yes, a responsible user would join all his threads before calling exit() or returning fr