Thread overview
TLS definition in curses.o section .tbss mismatches non-TLS reference in /usr/lib/libncurses.a(lib_initscr.o)
Dec 10, 2009
Gareth Charnock
Dec 11, 2009
Bernard Helyer
Dec 11, 2009
Gareth Charnock
Re: TLS definition in curses.o section .tbss mismatches non-TLS reference
Dec 14, 2009
Ali Cehreli
December 10, 2009
I've been trying to link a d program to a c library (ncurses in this case) on ubuntu 9.10 with dmd v2.036. Converting curses.c to a .d header seemed to go okay when I try to link the files together I get this:

dmd -c main.d
dmd -c curses.d
dmd main.o curses.o -L/usr/lib/libncurses.a
/usr/bin/ld: stdscr: TLS definition in curses.o section .tbss mismatches non-TLS reference in /usr/lib/libncurses.a(lib_initscr.o)
/usr/lib/libncurses.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

I eventually figured out that TLS is thread local storage. The -vtls looked helpful so I gave it a try:

dmd -c -vtls curses.d
curses.d(12): acs_map is thread local
curses.d(412): curscr is thread local
curses.d(413): newscr is thread local
curses.d(414): stdscr is thread local
curses.d(415): ttytype is thread local
curses.d(416): COLORS is thread local
curses.d(417): COLOR_PAIRS is thread local
curses.d(418): COLS is thread local
curses.d(419): ESCDELAY is thread local
curses.d(420): LINES is thread local
curses.d(421): TABSIZE

Here are what those lines look like in the file:

 WINDOW * curscr;
 WINDOW * newscr;
 WINDOW * stdscr;
 char ttytype[];
 int COLORS;
 int COLOR_PAIRS;
 int COLS;
 int ESCDELAY;
 int LINES;
 int TABSIZE;

It appears the header contains a smattering of variables dmd is assuming  I want stored with thread local storage. Is there any way to tell dmd to just share them between threads? Everything is already wrapped with extern(C). Am I missing something?

Thanks,
Gareth
December 11, 2009
On 11/12/09 10:48, Gareth Charnock wrote:
>
> Is there any way to tell dmd
> to just share them between threads?

__gshared type whatever;

December 11, 2009
Bernard Helyer wrote:
> On 11/12/09 10:48, Gareth Charnock wrote:
>>
>> Is there any way to tell dmd
>> to just share them between threads?
> 
> __gshared type whatever;
> 
Thanks. And now I see there was an article about that on website all along. I guess my eyes must have just scanned over it. A good night's sleep and knowing what to google can certainly help!
December 14, 2009
Gareth Charnock Wrote:

> And now I see there was an article about that on website all along.

And that article is here:

  http://www.digitalmars.com/d/2.0/migrate-to-shared.html

Ali