Gentoo Archives: gentoo-user

From: Devon Miller <devon.c.miller@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Gcc complains about TLS and errno; I baffled
Date: Thu, 16 Nov 2006 23:30:33
Message-Id: c52221f0611161526j62fff9d6tcb8e2f269a473f5@mail.gmail.com
In Reply to: Re: [gentoo-user] Gcc complains about TLS and errno; I baffled by Alan McKinnon
1 In this case, TLS stands for Thread Local Storage. Not to be confused with
2 Transport Layer Security
3
4 Welcome to the joy of overloaded acronyms :-P
5
6 Using "int errno;" will not work in any multithreaded executable.
7
8 You need to use errno via errno.h because errno isn't a simple int, but a
9 dereferenced pointer to a per-thread instance (in thread local storage) of
10 an int. That's there so that each thread gets its own private errno variable
11 for error reporting. Otherwise, errno would be the value of the last system
12 call on any thread, not necessarily the one that's trying to check errno.
13
14 The error is indicating (albeit badly) that the program's definition of
15 errno clashes with the TLS definition of errno.
16
17 dcm
18
19 On 11/16/06, Alan McKinnon <alan@××××××××××××××××.za> wrote:
20 >
21 > On Thursday 16 November 2006 22:03, Kevin O'Gorman wrote:
22 > > I'm trying to compile a program that works on Solaris with gcc, but
23 > > won't complile
24 > > under Linux (either FC5 or Gentoo). It seems to be because writing
25 > > int errno;
26 > > works under Solaris gcc-3.4.3 (well, it passes the compiler anyway),
27 > > but under Linux
28 > > gcc-3.4.6 or -4.1.0 one has to
29 > > #include <errno.h>
30 > > which makes more sense. I would just make the change, but I'm
31 > > baffled by the error message Linux gcc gives to the first
32 > > declaration. It reads:
33 > >
34 > > /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/../../../../i686-pc-linux-gnu/bi
35 > >n/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches
36 > > non-TLS reference in /tmp/cc6urgct.o
37 > > /lib/libc.so.6: could not read symbols: Bad value
38 > >
39 > > But when I try to look up TLS, all I get is a bunch of stuff about a
40 > > server-to-server
41 > > email security protocol. What is it talking about here, and where
42 > > can I find out about it?
43 >
44 > It would appear to be a an issue between linuxthreads and nptl. How are
45 > your nptl and nptlonly USE flasg set?
46 >
47 > This post that I find on google may start to give you more answers. It's
48 > for a completely different package but the problem and solution seesmto
49 > be the same as yours:
50 >
51 > http://www.rockbox.org/mail/archive/rockbox-dev-archive-2006-01/0020.shtml
52 >
53 > alan
54 > --
55 > gentoo-user@g.o mailing list
56 >
57 >