With gcc (GCC) 3.3.3 20040217 (Gentoo Linux 3.3.3, propolice-3.3-7), and kernel 2.6.3-gentoo-r1 it is not possible to load a shared library with TLS data. Reproducible: Always Steps to Reproduce: 1. Compile test.c (gcc test.c -shared -o libtest.so int test() { static __thread char *p; ; return 0; } 2. Save test.h extern int test(); 3. Compile testmain.c (gcc test.c testmain.c -o test) #include "test.h" int main () { test (); } 4. Execute a.out (./a.out) Actual Results: ./a.out: error while loading shared libraries: libtest.so: cannot handle TLS data Expected Results: No output and no error Gentoo Base System version 1.4.3.13 Portage 2.0.50-r1 (default-x86-1.4, gcc-3.3.3, glibc-2.3.3_pre20040207-r0, 2.6.3-gentoo-r1) ================================================================= System uname: 2.6.3-gentoo-r1 i686 Intel(R) Pentium(R) 4 CPU 2.66GHz Autoconf: sys-devel/autoconf-2.59-r3 Automake: sys-devel/automake-1.8.2 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CFLAGS="-march=pentium4 -O3 -pipe" CHOST="i686-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.1/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" CXXFLAGS="-march=pentium4 -O3 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs ccache sandbox" GENTOO_MIRRORS="ftp://trumpetti.atm.tut.fi/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="X apm arts avi berkdb bonobo cdr crypt cups encode esd foomaticdb gdbm gif gnome gpm gtk gtk2 guile imlib java jpeg ldap libg++ libwww mad mikmod motif mozilla mpeg ncurses nls oggvorbis opengl oss pam pdflib perl png python quicktime readline sdl slang spell ssl svga tcpd tetex truetype video_cards_radeon x86 xml2 xmms xv zlib"
Hmm, tried to compile library with -fPIC? Else try to remove '--without-__thread' from these lines, and remerge glibc: -- 484-485 -- myconf="${myconf} --without-__thread \ --enable-add-ons=linuxthreads" --
Adding nptl to USE removes this problem after re-emerging glibc.