http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49541
Summary: [4.6/4.7 regression] TLS support partially broken in 64-bit mode Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: ebotca...@gcc.gnu.org Target: sparc-sun-solaris2.8 The new TLS support on SPARC/Solaris 8 is partially broken in 64-bit mode. This is visible with gcc.dg/tls/opt-12.c: (botcazou@nile) /nile.build/botcazou/gcc-4.6/sparc-sun-solaris2.8 $ gcc/xgcc -Bgcc -o opt-12 opt-12.c -fpic -O2 -pthread (botcazou@nile) /nile.build/botcazou/gcc-4.6/sparc-sun-solaris2.8 $ gcc/xgcc -Bgcc -o opt-12 opt-12.c -fpic -O2 -pthread -m64 Undefined first referenced symbol in file __tls_get_addr /var/tmp//cc0nZy21.o ld: fatal: Symbol referencing errors. No output written to opt-12 collect2: ld returned 1 exit status This is with the Sun linker. The difference between 32-bit and 64-bit mode is that the driver inserts -L entries on the link line: gcc/collect2 -V -Y P,/usr/ccs/lib:/usr/lib -Qy -o opt-12 gcc/crt1.o gcc/crti.o /usr/ccs/lib/values-Xa.o gcc/crtbegin.o -Lgcc -L/usr/ccs/lib /var/tmp//ccLfjSjm.o -lgcc -lgcc_eh -L/usr/lib/lwp -R/usr/lib/lwp -lpthread -lthread -lc -lgcc -lgcc_eh -L/usr/lib/lwp -R/usr/lib/lwp -lpthread -lthread -lc gcc/crtend.o gcc/crtn.o gcc/collect2 -V -Y P,/usr/lib/sparcv9 -Qy -o opt-12 gcc/sparcv9/crt1.o gcc/sparcv9/crti.o /usr/ccs/lib/sparcv9/values-Xa.o gcc/sparcv9/crtbegin.o -Lgcc/sparcv9 -L/usr/ccs/lib/sparcv9 -L/lib/sparcv9 -L/usr/lib/sparcv9 -Lgcc -L/usr/ccs/lib /var/tmp//ccMywo2Z.o -lgcc -lgcc_eh -L/usr/lib/lwp/64 -R/usr/lib/lwp/64 -lpthread -lthread -lc -lgcc -lgcc_eh -L/usr/lib/lwp/64 -R/usr/lib/lwp/64 -lpthread -lthread -lc gcc/sparcv9/crtend.o gcc/sparcv9/crtn.o The problematic one is /lib/sparcv9. It causes /lib/sparcv9/libthread.so to be seen before /usr/lib/lwp/sparcv9/libthread.so. Now the latter provides the missing symbol __tls_get_addr while the former doesn't (we have the same setup with /lib/libthread.so and /usr/lib/lwp/libthread.so in 32-bit mode). This is a regression in the sense that the testcase links with GCC 4.5.x.