Skip to content

Support R_X86_64_TLSGD relocation on FreeBSD (GHC 9.2)

vdukhovni requested to merge trac-vdukhovni/ghc:freebsd-tlsgd-9.2 into ghc-9.2

The FreeBSD C <ctype.h> header supports per-thread locales by exporting a static inline function that references the _ThreadRuneLocale thread-local variable. This means that object files that use e.g. isdigit(3) end up with TLSGD(19) relocations, and would not load into ghci or the language server.

Here we add support for this type of relocation, for now just on FreeBSD, and only for external references to thread-specifics defined in already loaded dynamic modules (primarily libc.so). This is sufficient to resolve the FreeBSD <ctype.h> issue.

Runtime linking of ".o" files which define new thread-specific variables would be noticeably more difficult, as this would likely require new rtld APIs.

Also block signals in RTS ticker thread on platforms that use a Posix thread for the itimer.

Merge request reports