[Bug ld/10881] New: Multithreading link. Thread-local storage (__thread) is not working?

View: New views
8 Messages — Rating Filter:   Alert me  

[Bug ld/10881] New: Multithreading link. Thread-local storage (__thread) is not working?

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yesterday I tried to build GNU MPFR Library (mpfr-2.4.1) using gcc-3.4.6 and
binutils-2.20.

During configure phase I got a message:
...
checking for TLS support... no
configure: error: please configure with --disable-thread-safe
...

I prepared a little test program (test_binutils.c) to check GNU ld and SUN ld

cat > test_binutils.c <<EOF
__thread int x = 17;
int main() {
  return x != 17;
}
EOF

I compiled this programm with gcc (gcc-3.4.6)
/usr/gnu/bin/gcc -c -o test_binutils.o test_binutils.c

And then linked this program using the same options and object files.

with GNU ld

/usr/gnu/bin/ld -o gnu_ld /usr/gnu/lib/gcc/i386-pc-solaris2.11/3.4.6/crt1.o /
usr/gnu/lib/gcc/i386-pc-solaris2.11/3.4.6/crti.o /usr/ccs/lib/values-Xa.o /usr/
gnu/lib/gcc/i386-pc-solaris2.11/3.4.6/crtbegin.o test_binutils.o -L/lib -lc /
usr/gnu/lib/gcc/i386-pc-solaris2.11/3.4.6/crtend.o /usr/gnu/lib/gcc/i386-pc-
solaris2.11/3.4.6/crtn.o

And with SUN ld

/usr/bin/ld -o sun_ld /usr/gnu/lib/gcc/i386-pc-solaris2.11/3.4.6/crt1.o /usr/
gnu/lib/gcc/i386-pc-solaris2.11/3.4.6/crti.o /usr/ccs/lib/values-Xa.o /usr/gnu/
lib/gcc/i386-pc-solaris2.11/3.4.6/crtbegin.o test_binutils.o -L/lib -lc /usr/
gnu/lib/gcc/i386-pc-solaris2.11/3.4.6/crtend.o /usr/gnu/lib/gcc/i386-pc-
solaris2.11/3.4.6/crtn.o

When I run these built programs (gnu_ld and sun_ld) I get following results:
$ ./gnu_ld ; echo $?
1
$ ./sun_ld ; echo $?
0

Is this a bug in GNU ld?
I built and checked binutils-2.19.1 with the same result.

SUN ld version:
$ /usr/bin/ld --version
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1683

--
           Summary: Multithreading link. Thread-local storage (__thread) is
                    not working?
           Product: binutils
           Version: 2.20
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: YLitvinenko at astana dot oilfield dot slb dot com
                CC: bug-binutils at gnu dot org
 GCC build triplet: i386-pc-solaris2.11
  GCC host triplet: i386-pc-solaris2.11
GCC target triplet: i386-pc-solaris2.11


http://sourceware.org/bugzilla/show_bug.cgi?id=10881

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/10881] Multithreading link. Thread-local storage (__thread) is not working?

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From nickc at redhat dot com  2009-11-10 15:41 -------
Hi Yevgeniy,

  It certainly does look like a binutils bug.

  Are you able to repeat the test using a more modern version of gcc ?  Say one
of the 4.x series ?  (This is just a guess, but maybe there is a problem in the
binutils linker which was worked around by a change in gcc.  This would explain
why this problem has not shown up before).

  Can you upload the test_binutils.o, sun_ld and gnu_ld binaries so that we can
have a look at them ?

Cheers
  Nick

--


http://sourceware.org/bugzilla/show_bug.cgi?id=10881

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/10881] Multithreading link. Thread-local storage (__thread) is not working?

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From YLitvinenko at astana dot oilfield dot slb dot com  2009-11-13 03:36 -------
Created an attachment (id=4382)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4382&action=view)
object file. output from gcc-3.4.6


--


http://sourceware.org/bugzilla/show_bug.cgi?id=10881

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/10881] Multithreading link. Thread-local storage (__thread) is not working?

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From YLitvinenko at astana dot oilfield dot slb dot com  2009-11-13 03:38 -------
Created an attachment (id=4383)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4383&action=view)
GNU ld output when linking test_binutils.o


--


http://sourceware.org/bugzilla/show_bug.cgi?id=10881

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/10881] Multithreading link. Thread-local storage (__thread) is not working?

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From YLitvinenko at astana dot oilfield dot slb dot com  2009-11-13 03:39 -------
Created an attachment (id=4384)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4384&action=view)
Sun ld output when linking test_binutils.o


--


http://sourceware.org/bugzilla/show_bug.cgi?id=10881

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/10881] Multithreading link. Thread-local storage (__thread) is not working?

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From YLitvinenko at astana dot oilfield dot slb dot com  2009-11-19 08:37 -------
I repeated the test (see test script between lines "---- cut here ----")
using gcc-4.4.2.

Result the same.
-------- cut here -----

SRC=test_binutils.c
OBJ=test_binutils.o

OPT="/usr/lib/crt1.o /usr/lib/crti.o /usr/ccs/lib/values-Xa.o /usr/gnu/lib/gcc/
i386-pc-solaris2.11/4.4.2/crtbegin.o test_binutils.o -L/lib -lc /usr/gnu/lib/
gcc/i386-pc-solaris2.11/4.4.2/crtend.o /usr/lib/crtn.o"

cat > $SRC <<EOF
__thread int x = 17;
int main() {
  return x != 17;
}
EOF

/usr/gnu/bin/gcc -c -o $OBJ $SRC

LD=/usr/gnu/bin/ld
OUT=gnu-4.4.2_ld
$LD -o $OUT $OPT

LD=/usr/bin/ld
OUT=sun_ld
$LD -o $OUT $OPT

-------- cut here -----

$ ./gnu-4.4.2_ld ; print $?
1
$ ./sun_ld ; print $?      
0

Versions:
$ /usr/gnu/bin/gcc --version
gcc (GCC) 4.4.2
$ /usr/gnu/bin/ld --version
GNU ld (GNU Binutils) 2.20

I asked one of my friends to compile, link and run test_binutils.c on Linux
with gcc-4.4.2 and ld version 2.20. On Linux the resulting program gives
correct result (echo $? gives 0).


--


http://sourceware.org/bugzilla/show_bug.cgi?id=10881

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/10881] Multithreading link. Thread-local storage (__thread) is not working?

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From YLitvinenko at astana dot oilfield dot slb dot com  2009-11-19 08:40 -------
Created an attachment (id=4394)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4394&action=view)
object file from gcc-4.4.2


--


http://sourceware.org/bugzilla/show_bug.cgi?id=10881

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug ld/10881] Multithreading link. Thread-local storage (__thread) is not working?

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From YLitvinenko at astana dot oilfield dot slb dot com  2009-11-19 08:41 -------
Created an attachment (id=4395)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4395&action=view)
output from gcc-4.4.2 and ld version 2.20


--


http://sourceware.org/bugzilla/show_bug.cgi?id=10881

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils