Speaking of testing with MSVC... I think what we could try is to configure with --disable-shared and then run `make CFLAGS='-MD -GL'` and then `make check CFLAGS='-MD -GL'` (when cl.exe is used for linking -GL implies -LTCG, so we don't need it here).
- Kirill Makurin ________________________________ From: Pali Rohár <[email protected]> Sent: Tuesday, September 23, 2025 6:06 PM To: Antonin Décimo <[email protected]>; Kirill Makurin <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [Mingw-w64-public] [PATCH 1/6] winpthreads: Remove additional declaration of __xl_f variable Hello Antonin, thank you for input. I thought that linker comment /include is sufficient for msvc linker in all cases. So it is really truth that separate declaration of variable with extern keyword is really needed even when linker comment /include is specified? Unfortunately MS documentation does not mention this and when doing LTO it is sometimes hard to figure out the things as sometimes compiler does not have to to the destructive optimization... For gcc I'm marking the variable as static __attribute__((used)) which for gcc is enough and prevents exporting unnecessary symbol. But one variable cannot be both static and extern, so I removed the extern as for non-static case it is not needed. (Thanks Kirill for forwarding the email) On Monday 22 September 2025 21:56:59 Kirill Makurin wrote: > (CC'ing Pali, AFAIK he's not subscribed to the list) > > Using /GL with libtool seems impossible, I tried it with some other projects. > So, it would be a bit tricky to test. > > The problem is that configuration for libtool tries to figure out what > program NM is and parse its output. It will fail to do it if you use /GL > compiler flag, this in turn will result in libtool failing in its link step > when generating DLL. > > - Kirill Makurin > ________________________________ > From: Antonin Décimo <[email protected]> > Sent: Monday, September 22, 2025 10:13 PM > To: [email protected] > <[email protected]> > Subject: Re: [Mingw-w64-public] [PATCH 1/6] winpthreads: Remove additional > declaration of __xl_f variable > > IIRC declaring the variable extern was suggested somewhere online to > prevent the linker from removing it, especially when LTO gets > involved. If you're feeling brave, you could test winpthreads + MSVC > and its /GL [0] or /LTGC [1] flags. > > [0]: > https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 > [1]: > https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 > > -- Antonin > > > _______________________________________________ > Mingw-w64-public mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
