Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Problem with installing Tango with GDC

Moderators: larsivi kris

Posted: 10/27/10 14:18:46

Hi,

I'm currently preparing a lecture about D language and want to add some simple benchmarks to it which would include LDC and GDC compilers and Tango library. Unfortunately, I have problems with running Tango with GDC on Linux x86_64. Here's what I've done:

1. Compiling GDC - OK. 2. Installing GDC - OK, located in /opt/gdc 3. Downloading Tango trunk - OK 4. Compiling Tango with [i]bob/i for Linux64 - surprisingly OK

The problem is with point 5, installing Tango in GDC. After the compilation, I found libtango.a file in the Tango directory, so I copied it to /opt/gdc/lib64/libtango.a. I've also copied object.di to /opt/gdc/include/.../object.di, removing object.d from Phobos at the same time. I don't know what I can do next, because the build and install instructions are a nightmare - they either describe old Tango versions or show some strange steps which involve files that I do not have.

Anyway, I try to compile a simple Hello World program:

import tango.io.Console;

void main(char[][] args)
{
  Cout("Hi, universe!").newline;
} // end main();

with the following command:

/opt/gdc/bin/gdc -ltango hello.d

and this is what I get:

WARNING: no atomic operations on this architecture
WARNING: this is *slow* you probably want to change this!
/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/../../../../lib64/libtango.a(tango-core-rt-compiler-
gdc-rt-memory-frelease.o): In function `rt_stackBottom':
memory.d:(.text+0x1f): undefined reference to `dlopen'
memory.d:(.text+0x34): undefined reference to `dlsym'
memory.d:(.text+0x47): undefined reference to `dlclose'
/tmp/cc1Y5LM8.o: In function `_Dmain':
hello.d:(.text+0x29): undefined reference to `_D5tango2io7Console4CoutC5tango2io7Console7Console6Output'
hello.d:(.text+0x3c): undefined reference to `_D5tango2io7Console7Console6Output6appendMFAaZC5tango2io7Console7Console6Output'
hello.d:(.text+0x44): undefined reference to `_D5tango2io7Console7Console6Output7newlineMFZC5tango2io7Console7Console6Output'
/tmp/cc1Y5LM8.o:(.data+0x70): undefined reference to `_D5tango2io7Console12__ModuleInfoZ'
collect2: ld returned 1 exit status

GDC with Phobos worked perfectly. How can I make Tango run with the newest GDC? What am I missing?

Author Message

Posted: 10/27/10 16:25:07

I should start with saying that GDC support in Tango is not really considered complete yet (it has just recently been readded now that the new GDC has started to function again).

As for your error messages, the first ones are due to a missing '-ldl' linker argument. The bottom most errors could be due to the missing -ldl too. As for _why_ libdl is needed there, I'm not fully sure - possibly due to some dynlib support.

Posted: 10/27/10 16:37:10 -- Modified: 10/27/10 17:32:34 by
Zyx -- Modified 2 Times

Well, then this is an opportunity to help improving it by making some tests :). It would be nice to show some working examples during the lecture :).

But going back to the topic: -ldl eliminated the first three missing references, but still the output looks like this:

WARNING: no atomic operations on this architecture
WARNING: this is *slow* you probably want to change this!
/tmp/ccNDTWGC.o: In function `_Dmain':
hello.d:(.text+0x29): undefined reference to `_D5tango2io7Console4CoutC5tango2io7Console7Console6Output'
hello.d:(.text+0x3c): undefined reference to `_D5tango2io7Console7Console6Output6appendMFAaZC5tango2io7Console7Console6Output'
hello.d:(.text+0x44): undefined reference to `_D5tango2io7Console7Console6Output7newlineMFZC5tango2io7Console7Console6Output'
/tmp/ccNDTWGC.o:(.data+0x70): undefined reference to `_D5tango2io7Console12__ModuleInfoZ'
collect2: ld returned 1 exit status

Edit: OK, I added some verbose and this is the more complete output:

Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-languages=d --disable-multilib --disable-shared --prefix=/opt/gdc
Thread model: posix
gcc version 4.4.5 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-pthread' '-mtune=generic'
 /opt/gdc/libexec/gcc/x86_64-unknown-linux-gnu/4.4.5/cc1d hello.d -quiet -dumpbase hello.d -mtune=generic -auxbase hello -version -o /tmp/ccwCPANM.s
GNU D (GCC) version 4.4.5 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.5, GMP version 5.0.1, MPFR version 3.0.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
WARNING: no atomic operations on this architecture
WARNING: this is *slow* you probably want to change this!
COLLECT_GCC_OPTIONS='-v' '-pthread' '-mtune=generic'
 as -V -Qy -o /tmp/cceQ0iZo.o /tmp/ccwCPANM.s
GNU assembler version 2.20.1 (x86_64-unknown-linux-gnu) using BFD version (GNU Binutils) 2.20.1.20100521
COMPILER_PATH=/opt/gdc/libexec/gcc/x86_64-unknown-linux-gnu/4.4.5/:/opt/gdc/libexec/gcc/x86_64-unknown-linux-gnu/4.4.5/:
/opt/gdc/libexec/gcc/x86_64-unknown-linux-gnu/:/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/:/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/:
/usr/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/:/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/../../../../lib64/:
/lib/../lib64/:/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-pthread' '-mtune=generic'
 /opt/gdc/libexec/gcc/x86_64-unknown-linux-gnu/4.4.5/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib/crt1.o /usr/lib/crti.o /opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/crtbegin.o -L/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5
-L/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/../../../../lib64 -L/lib/../lib64 -L/opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/../../..
-ldl -ltango /tmp/cceQ0iZo.o -lgphobos -lm -lgcc -lpthread -lc -lgcc /opt/gdc/lib/gcc/x86_64-unknown-linux-gnu/4.4.5/crtend.o /usr/lib/crtn.o
/tmp/cceQ0iZo.o: In function `_Dmain':
hello.d:(.text+0x29): undefined reference to `_D5tango2io7Console4CoutC5tango2io7Console7Console6Output'
hello.d:(.text+0x3c): undefined reference to `_D5tango2io7Console7Console6Output6appendMFAaZC5tango2io7Console7Console6Output'
hello.d:(.text+0x44): undefined reference to `_D5tango2io7Console7Console6Output7newlineMFZC5tango2io7Console7Console6Output'
/tmp/cceQ0iZo.o:(.data+0x70): undefined reference to `_D5tango2io7Console12__ModuleInfoZ'
collect2: ld returned 1 exit statu

As far as I understand it correctly, GDC tries to link this both with Phobos and Tango.

Posted: 10/27/10 17:10:25

Hi, the example works for me. I used "./build/script/bob.sh --verbose --user --runtime gdc" to build libtango.a and put it to /opt/usr/local/lib64. Btw.: what Tango revision did you use?

Posted: 10/27/10 17:15:10

Hi Zyx,

The fact that both Phobos and Tango appear to be linked in together shouldn't be a cause for concern as -ltango is passed first, it takes precedence over phobos library. If it did cause a problem, then you'd be getting lots of "multiple definition" errors. :-)

I can only assume then that tango.io.Console.d didn't build correctly for you, or it wasn't included in the library. How are you building tango? I'm using:

/build/bin/linux32/bob -o="-g" -u -rgdc -cgdc -plinux -v .

Regards

Posted: 10/27/10 17:31:28 -- Modified: 10/27/10 17:41:10 by
Zyx

I'm using this command in Tango directory:

PATH=$PATH:/opt/gdc/bin ./build/bin/linux64/bob -vu -r=gdc -c=gdc ./

Of course, there is also a question, what files to copy from the Tango build dir and where to put them. I know about libtango.a, object.di and std/intrinsic.d.

Edit: I checked the command by mwarning, but it does not work:

PATH=$PATH:/opt/gdc/bin ./build/script/bob.sh --verbose --user --runtime gdc
~/Temp/GDC/tango/build/script ~/Temp/GDC/tango
Building libtango.a
D compiler call: gdmd   -c -inline  -release -O -version=Posix -I. .Itango/core -Itango/core/vendor -version=Tango -of<object> <filename>
[gdc] tango/net/device/Socket.d
WARNING: no atomic operations on this architecture
WARNING: this is *slow* you probably want to change this!
[gdc] tango/net/device/Berkeley.d
tango/net/device/Berkeley.d:2223: Error: function std.intrinsic.bts (ulong*,ulong) does not match parameter types (uint*,uint)
tango/net/device/Berkeley.d:2223: Error: cannot implicitly convert expression (&this.first()[cast(ulong)this.fdelt(s)]) of type uint* to ulong*
tango/net/device/Berkeley.d:2261: Error: function std.intrinsic.btr (ulong*,ulong) does not match parameter types (uint*,uint)
tango/net/device/Berkeley.d:2261: Error: cannot implicitly convert expression (&this.first()[cast(ulong)this.fdelt(s)]) of type uint* to ulong*
Compilation of tango/net/device/Berkeley.d failed

Tango comes from the freshest trunk, GDC too.

Posted: 10/27/10 20:31:15 -- Modified: 10/27/10 20:32:27 by
ibuclaw

Zyx wrote:

Edit: I checked the command by mwarning, but it does not work:

PATH=$PATH:/opt/gdc/bin ./build/script/bob.sh --verbose --user --runtime gdc
~/Temp/GDC/tango/build/script ~/Temp/GDC/tango
Building libtango.a
D compiler call: gdmd   -c -inline  -release -O -version=Posix -I. .Itango/core -Itango/core/vendor -version=Tango -of<object> <filename>
[gdc] tango/net/device/Socket.d
WARNING: no atomic operations on this architecture
WARNING: this is *slow* you probably want to change this!
[gdc] tango/net/device/Berkeley.d
tango/net/device/Berkeley.d:2223: Error: function std.intrinsic.bts (ulong*,ulong) does not match parameter types (uint*,uint)
tango/net/device/Berkeley.d:2223: Error: cannot implicitly convert expression (&this.first()[cast(ulong)this.fdelt(s)]) of type uint* to ulong*
tango/net/device/Berkeley.d:2261: Error: function std.intrinsic.btr (ulong*,ulong) does not match parameter types (uint*,uint)
tango/net/device/Berkeley.d:2261: Error: cannot implicitly convert expression (&this.first()[cast(ulong)this.fdelt(s)]) of type uint* to ulong*
Compilation of tango/net/device/Berkeley.d failed

Tango comes from the freshest trunk, GDC too.

Ah, I was told of this the other day!

The problem here is, I updated the std.intrinsic function signatures as part of the merge with the DMD 1.064 frontend. See: http://dsource.org/projects/phobos/browser/branches/phobos-1.x/phobos/std/intrinsic.d Although tango has their own copy of std/intrinsic.d inside the gdc runtime directory, when building the system's std/intrinsic.d gets imported instead. So the compiler expects (size_t*, size_t) to be the parameters passed to bts rather than (uint*, uint).

This could be arguably a problem with Tango, and not GDC. But I'm willing to deliberate a revert on my part (possibly only to reapply it again later though).

Regards

Posted: 10/27/10 22:44:23

Hi Zyx,

I had the same error with intrinsic.d. It worked after I replaced it with the one from Tango. But this is only a hack and there need to be done smth. about it.

Posted: 10/28/10 08:50:24 -- Modified: 10/28/10 08:51:32 by
Zyx

Thanks, mwarning - it helped for the building problem. Anyway, the linking issue is still partially open. I used nm tool to check the exported symbols and everything looks correct in the library file itself. So, the conclusion is that GDC has problem with finding Tango when it is put in /opt/gdc/lib. I made a workaround by linking Tango directly from the program directory:

/opt/gdc/bin/gdc -o hello.o -c hello.d
/opt/gdc/bin/gdc -ldl hello.o libtango.a
./a.out

So, the conclusion from this topic is: building Tango for GDC is possible, but still needs some work, and for linking problems I must check GDC options and, if it does not help, contact the GDC developer. Thanks for help!

Posted: 10/28/10 12:55:46 -- Modified: 10/28/10 12:57:04 by
ibuclaw

Zyx wrote:

Thanks, mwarning - it helped for the building problem. Anyway, the linking issue is still partially open. I used nm tool to check the exported symbols and everything looks correct in the library file itself. So, the conclusion is that GDC has problem with finding Tango when it is put in /opt/gdc/lib. I made a workaround by linking Tango directly from the program directory:

/opt/gdc/bin/gdc -o hello.o -c hello.d
/opt/gdc/bin/gdc -ldl hello.o libtango.a
./a.out

So, the conclusion from this topic is: building Tango for GDC is possible, but still needs some work, and for linking problems I must check GDC options and, if it does not help, contact the GDC developer. Thanks for help!

You mean the 'linker' has a problem finding Tango when it is put in /opt/gdc/lib ;-)

Try:

/opt/gdc/bin/gdc hello.o -L/opt/gdc/lib -ltango -ldl

Regards

Posted: 10/28/10 13:31:58 -- Modified: 10/28/10 13:32:35 by
Zyx

I tried that - it didn't work when GDC has to both compile and link the program.

Posted: 11/02/10 13:21:12

The problem with intrinsic.d should be gone now. :)

Posted: 11/15/10 08:39:42 -- Modified: 11/15/10 08:40:36 by
Zyx

OK, I think the problem must be solved on the GDC side. The linking way that works for simple programs, fails i.e. for tango.util.container.HashMap? where the compiler complains that some symbols have already been defined in Phobos. It seems that currently the only way to disable Phobos is to add -nostdlib to the linking command and link all the possible standard libraries, except Phobos, which is a bit problematic, too. I started a ticket on the GDC issue tracker concerning the ability to disable Phobos in GDC in more friendly way (or, if it is already implemented - to document it).