On Sunday 15 February 2026 16:03:14 Kirill Makurin wrote:
> Pali Rohár <[email protected]>:
> >On Sunday 15 February 2026 15:39:40 Kirill Makurin wrote:
> > I feel like adding --start-group/--end-group around mingw-w64's -l flags in 
> > gcc spec should be a good solution.
> >
> > That would be hard because gcc has definitions of -l flags in different
> > sections and it combines sections together based on output target.
> 
> By running `gcc -dumpspecs` (gcc 15.2.0 from Msys2/UCRT64) I see:
> 
> ```
> *libgcc:
> %{mthreads:-lmingwthrd} -lmingw32      %{static|static-libgcc:-lgcc -lgcc_eh} 
>  %{!static:    %{!static-libgcc:      %{!shared:        
> %{!shared-libgcc:-lgcc -lgcc_eh}        %{shared-libgcc:-lgcc_s -lgcc}       
> }      %{shared:-lgcc_s -lgcc}     }   }     -lmingwex %{!mcrtdll=*:-lmsvcrt} 
> %{mcrtdll=*:-l%*}    -lkernel32
> ```
> 
> So, we have -lmingwex followed by the CRT import library. Would it suffice to 
> add --start-group/--end-group just around them?

Because there is also *lib: section and somewhere is also libstdc++
which calls CRT functions too. So to address all these issues for C++
it would be needed to put all libs from all those sections into one
continuous --start-group/--end-group.

Also if such change in gcc is applied then there is a problem with
support for gcc versions without that change. I'm not sure if it is
a good idea to drop support for all existing gcc versions, and require
gcc 16.x.x (or where can be this --start-group/--end-group accepted)
for mingw-w64.

> >> > And that it is better if the msvcrt/ucrt import library does not call
> >> > functions from libmingwex.a library.
> >>
> >> IMO, this will be somewhat annoying as we will have to keep track of where 
> >> a function comes from when we call it. This may get pretty bad over time.
> >
> > I agree, but I do not have a solution for it, except get rid of 
> > libmingwex.a.
> 
> Can we just add contents of libmingwwx.a into import libraries? This will 
> increase size of CRT import libraries almost twice, but should get rid of 
> possible link issues coming from libmingwex.a being separate library.
> 
> - Kirill Makurin

That exactly means get rid of libmingwex.a. It is possible via
MRI script, basically all CRT import libraries are already built
via MRI scripts, so adding there another .a archive is not hard.


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to