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(); } $ gcc -c test-builtin-thread-pointer.c test-builtin-thread-pointer.c: In function ‘f’: test-builtin-thread-pointer.c:3:13: warning: implicit declaration of function ‘__builtin_thread_pointer’; did you mean ‘__builtin_extend_pointer’? [-Wimplicit-function-declaration] 3 | void *p = __builtin_thread_pointer(); | ^~~~~~~~~~~~~~~~~~~~~~~~ | __builtin_extend_pointer test-builtin-thread-pointer.c:3:13: warning: initialization of ‘void *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] On Ubuntu 24.04 this program compiles without warnings. It looks like the gcc configure script checks for TLS here: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/configure.ac;h=8fab93c9365496062583c5bd8ace402c8a797817;hb=HEAD#l3846, by running some code through the assembler. I would guess that doesn't work on Cygwin. -Dimitry > On 11 Feb 2025, at 21:45, Brian Inglis via Cygwin <cygwin@cygwin.com> 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)? > > -- > 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 -- 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