On Feb 11 20:41, Dimitry Andric via Cygwin wrote: > 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. > > -Dimitry
Nice answer! It's also not entirely clear what __builtin_thread_pointer is supposed to return. On some architectures, there's a register dedicated to point to thread local storage (Risc-V, SH), on some architectures it's a specific assembler call (Alpha). There's no such predefined set of registers or assembler instructions on x86_64. The Windows ABI defines the GS register as the register pointing to the TEB (Thread Environment Block), but that's not exactly the same thing as TLS. The TLS is another datastructure inside the TEB. And Cygwin has it's own internal TLS area called cygtls, which resides on the stack. All in all, the fact that __builtin_thread_pointer is only defined on *some* architectures supports what Dimitry already pointed out: It is probably better to not use this function. Ken, check the source or configury of your package. It looks weird that this function should be called architecture-independently. Corinna > > > On 11 Feb 2025, at 20:26, Ken Brown via Cygwin <cygwin@cygwin.com> 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. > > > > Ken > > > > [242/242] Linking C executable luametatex.exe > > FAILED: luametatex.exe > > : && /usr/bin/gcc.exe -ggdb -O2 -pipe -Wall -Werror=format-security > > -Wp,-D_FORTIFY_SOURCE=3 -fstack-protector-strong --param=ssp-buffer-size=4 > > -ffile-prefix-map=/home/kbrown/src/cygluametatex/luametatex-2.11.05-1.x86_64/build=/usr/src/debug/luametatex-2.11.05-1 > > > > -ffile-prefix-map=/home/kbrown/src/cygluametatex/luametatex-2.11.05-1.x86_64/src/luametatex=/usr/src/debug/luametatex-2.11.05-1 > > -O2 -g -DNDEBUG -s CMakeFiles/luametatex.dir/source/luametatex.c.o -o > > luametatex.exe -Wl,--out-implib,libluametatex.dll.a > > -Wl,--major-image-version,0,--minor-image-version,0 libtex.a liblua.a > > libmp.a libluarest.a libluasocket.a libluaoptional.a libpplib.a > > libminiz.a libsoftposit.a libpotrace.a -ldl libmimalloc.a -lpthread > > -lm && /bin/sh CMakeFiles/luametatex.dir/post-build.sh 7847d1a259c666c4 > > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: > > libmimalloc.a(alloc.c.o): in function `_mi_prim_thread_id': > > /usr/src/debug/luametatex-2.11.05-1/source/libraries/mimalloc/include/mimalloc/prim.h:251:(.text+0x187): > > undefined reference to `__builtin_thread_pointer' > > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: > > /usr/src/debug/luametatex-2.11.05-1/source/libraries/mimalloc/include/mimalloc/prim.h:251:(.text+0x437): > > undefined reference to `__builtin_thread_pointer' > > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: > > /usr/src/debug/luametatex-2.11.05-1/source/libraries/mimalloc/include/mimalloc/prim.h:251:(.text+0x4e7): > > undefined reference to `__builtin_thread_pointer' > > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: > > libmimalloc.a(alloc.c.o):/usr/src/debug/luametatex-2.11.05-1/source/libraries/mimalloc/src/free.c:340:(.text+0x597): > > undefined reference to `__builtin_thread_pointer' > > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: > > libmimalloc.a(init.c.o): in function `_mi_prim_thread_id': > > /usr/src/debug/luametatex-2.11.05-1/source/libraries/mimalloc/include/mimalloc/prim.h:251:(.text+0xd1): > > undefined reference to `__builtin_thread_pointer' > > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: > > libmimalloc.a(init.c.o):/usr/src/debug/luametatex-2.11.05-1/source/libraries/mimalloc/include/mimalloc/prim.h:251: > > more undefined references to `__builtin_thread_pointer' follow > > collect2: error: ld returned 1 exit status > > > > -- > > 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 -- 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