On Jun 16 22:12, Jeremy Drake via Cygwin-patches wrote:
> On Mon, 16 Jun 2025, Jeremy Drake via Cygwin-patches wrote:
> 
> > In order to avoid a restriction on any reinterpret_cast-like behavior in
> > constinit expressions, use assembly and the linker to define symbols
> > with the not-valid-address addresses.
> >
> > Signed-off-by: Jeremy Drake <[email protected]>
> > ---
> > This is gross, but I couldn't come up with a way to make this both source
> > and ABI (including C++ name mangling) compatible.  I'd be happy to be
> > shown a cleaner way.  I built libc++ without a patch to remove constinit,
> > and I'm working on building gcc/libstdc++ to confirm it didn't break
> > anything there.
> 
> gcc 13.4.0 rebuilt successfully too.  The thing to watch out for with this
> is "relocation truncated to fit" link errors.

I don't see those when building Cygwin. What are you doing differently?
Compiler or binutils version?

> Oddly enough, I saw this
> when using the absolute symbols from the C++ inside the Cygwin DLL build,
> but have not seen it building either DLLs or EXEs using clang or gcc, even
> when trying to recreate the scenario (comparing a pthread_mutex_t to
> PTHREAD_MUTEX_INITIALIZER).

This may be fallout from using -mcmodel=small, see winsup/cygwin/Makefile.am.
Default is -mcmodel=medium, IIRC.

When we ported Cygwin to x86_64, we got "relocation truncated to fit"
when we decided to move the address space used by Cygwin on 64 bit
beyond the 2 Gigs border.  Gcc and binutils got tweaked specificially to
allow Cygwin to use the full address space as desired.  But the PTHREAD
macros never triggered this problem before, which is puzzeling.


Corinna

Reply via email to