> I think I may have found a bug with MSVC: if you use LTO and
> optimization (-O1 or -O2), then the symbol is always discarded. I'll
> open a bug report and see what happens.

I've opened a bug report with a couple of questions. The latest
iteration of the code is there too.
https://developercommunity.visualstudio.com/t/Whole-program-optimization-and-opmitized/10531811

> > We can use `#pragma section` and `__declspec(allocate("xxx"))`
> > instead.
>
> Umm, this doesn't seem to work for me. With your example code below, with
> foo_init renamed into main(), I don't get any working TLS callbacks, on
> neither x86 nor x64, and linking produces the following warning:
>
> LIBCMT.lib(tlssup.obj) : warning LNK4078: multiple '.CRT' sections found
> with different attributes (40400040)
> LIBCMT.lib(initializers.obj) : warning LNK4254: section '.CRT' (50000040)
> merged into '.rdata' (40000040) with different attributes

My bad, the warning disappears if the "shared" attribute is not used.
If I remove it, all the test cases behave correctly.

It seems that if we use `const_seg`, we don't need the
`__declspec(allocate(".CRT$XLF"))`
expanded by `WINPTHREADS_ATTRIBUTE(WINPTHREADS_SECTION(".CRT$XLF"))`
Should I keep the macros only if __GNUC__ is defined?

To me, using `const_seg` feels a little bit less like magic than using
`section`.

-- Antonin


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

Reply via email to