On 2025-02-11 13:58, Dimitry Andric wrote:
On 11 Feb 2025, at 21:45, Brian Inglis via Cygwin wrote:
On 2025-02-11 12:41, Dimitry Andric via Cygwin wrote:
On 11 Feb 2025, at 20:26, Ken Brown via Cygwin wrote:
Does Cygwin support __builtin_thread_pointer?  I'm guessing not, because
I'm getting a link error (undefined reference to
`__builtin_thread_pointer') when I try to build some software that uses
it.  Or is there something that would have to be added to the link command
line?  The full command line and error message are quoted below, in case
anyone spots something obvious.

It's a gcc builtin function, not something implemented in an external library. 
Therefore, there is no linker option that can fix this.
Also, as far as I can see from gcc's documentation,
__builtin_thread_pointer() is only supported for the RISCV and SH
architectures. Then again, gcc's implementation seems to hinge this on
whether the platform supports TLS or not.
In any case, it is probably better to not use this function if your gcc does
not support it.
Does `info gcc tls` help and do we know if that is supported by our gcc(s)?

> It does not look like it's supported by Cygwin's gcc:
>
> $ gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/12/lto-wrapper.exe
> Target: x86_64-pc-cygwin
> Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-12.4.0/configure --srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-12.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --with-gcc-major-version-only --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --enable-clocale=newlib --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++,jit --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --disable-multilib --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
> Thread model: posix
> Supported LTO compression algorithms: zlib zstd
> gcc version 12.4.0 (GCC)
>
> $ cat test-builtin-thread-pointer.c
> void f(void)
> {
>    void *p = __builtin_thread_pointer();
> }

If you read the docs at `info gcc tls` it uses the __thread storage class to allow you to declare auto, extern, or static thread variables like any other.

Whether that would run as expected is more than I can deduce.

--
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                -- Antoine de Saint-Exupéry

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to