Thread overview
Running dmd on ubuntu with AMD64
Apr 22, 2007
Jason House
Apr 22, 2007
Frits van Bommel
Apr 22, 2007
Jason House
Apr 22, 2007
Jason House
Apr 22, 2007
Jason House
Apr 22, 2007
Frits van Bommel
Running gdc -cov on ubuntu with AMD64
May 31, 2007
Jason House
April 22, 2007
I've discovered that the ubuntu linux distribution refuses to run 32 bit applications out of the box.  Are there plans for releasing a 64 bit version of dmd?  Is there anyone more experienced than me that has created a .deb (debian package) file that I can use?

jhouse@server:~/dmd/bin$ ls -al dmd
-rwxr-xr-x 1 jhouse jhouse 1009284 2007-03-26 00:45 dmd

jhouse@server:~/dmd/bin$ ./dmd
-bash: ./dmd: No such file or directory

jhouse@server:~/dmd/bin$ ldd dmd
        not a dynamic executable

jhouse@server:~/dmd/bin$ file dmd
dmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
April 22, 2007
Jason House wrote:
> I've discovered that the ubuntu linux distribution refuses to run 32 bit applications out of the box.  Are there plans for releasing a 64 bit version of dmd?  Is there anyone more experienced than me that has created a .deb (debian package) file that I can use?
> 
> jhouse@server:~/dmd/bin$ ls -al dmd
> -rwxr-xr-x 1 jhouse jhouse 1009284 2007-03-26 00:45 dmd
> 
> jhouse@server:~/dmd/bin$ ./dmd
> -bash: ./dmd: No such file or directory
> 
> jhouse@server:~/dmd/bin$ ldd dmd
>         not a dynamic executable
> 
> jhouse@server:~/dmd/bin$ file dmd
> dmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped

Try installing the "ia32-libs" package.

Works just fine for me:
=====
urxae@urxae:~/opt/dmd/bin$ ls -l dmd
-rwx------ 1 urxae urxae 1014564 2007-04-19 12:04 dmd
urxae@urxae:~/opt/dmd/bin$ ./dmd | head -n 2     # to shorten the output
Digital Mars D Compiler v1.013
Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
urxae@urxae:~/opt/dmd/bin$ file dmd
dmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, stripped
urxae@urxae:~/opt/dmd/bin$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 6.10
Release:        6.10
Codename:       edgy
urxae@urxae:~/opt/dmd/bin$ uname -m
x86_64
=====
April 22, 2007
Worked like a charm!  I'm surprised that wasn't on the ubuntu x86 64-bit forum.  Time to go make another post...

Frits van Bommel wrote:
> Jason House wrote:
>> I've discovered that the ubuntu linux distribution refuses to run 32 bit applications out of the box.  Are there plans for releasing a 64 bit version of dmd?  Is there anyone more experienced than me that has created a .deb (debian package) file that I can use?
>>
>> jhouse@server:~/dmd/bin$ ls -al dmd
>> -rwxr-xr-x 1 jhouse jhouse 1009284 2007-03-26 00:45 dmd
>>
>> jhouse@server:~/dmd/bin$ ./dmd
>> -bash: ./dmd: No such file or directory
>>
>> jhouse@server:~/dmd/bin$ ldd dmd
>>         not a dynamic executable
>>
>> jhouse@server:~/dmd/bin$ file dmd
>> dmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
> 
> Try installing the "ia32-libs" package.
> 
> Works just fine for me:
> =====
> urxae@urxae:~/opt/dmd/bin$ ls -l dmd
> -rwx------ 1 urxae urxae 1014564 2007-04-19 12:04 dmd
> urxae@urxae:~/opt/dmd/bin$ ./dmd | head -n 2     # to shorten the output
> Digital Mars D Compiler v1.013
> Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
> urxae@urxae:~/opt/dmd/bin$ file dmd
> dmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, stripped
> urxae@urxae:~/opt/dmd/bin$ lsb_release -a
> No LSB modules are available.
> Distributor ID: Ubuntu
> Description:    Ubuntu 6.10
> Release:        6.10
> Codename:       edgy
> urxae@urxae:~/opt/dmd/bin$ uname -m
> x86_64
> =====
April 22, 2007
Any further tips on getting rebuild/dsss to work?  I'm getting linker errors.  I'm assuming dmd is generating a 32 bit executable and failing to link with 64 bit libraries.  Can dmd generate a 64 bit executable? I'm not sure how to configure it to do so.  I did try hacking at the rebuild config files to see if I could get it to work (resulting file below).

Can gdc do better?

> $ dsss build
> housebot.d => housebot-0.6
> + /bin/rebuild -Idsss_imports/ -I. -S./ -I/include/d -S/lib/   -oqdsss_objs -Dddoc -unittest -w -gc housebot.d -ofhousebot-0.6
> gcc dsss_objs/_housebot.o dsss_objs/nmd_gcstats.o dsss_objs/_ipc.o dsss_objs/_gtp.o -o housebot-0.6 -g -m32 -lphobos -lpthread -lm -Xlinker --start-group -Xlinker -lphobos -Xlinker -L./ -Xlinker -L/lib/ -Xlinker -L/home/jhouse/housebot/dmd/bin/../lib -Xlinker -L/home/jhouse/housebot/dmd/bin/../lib
> /usr/bin/ld: skipping incompatible /usr/bin/../lib/libpthread.so when searching for -lpthread
> /usr/bin/ld: skipping incompatible /usr/bin/../lib/libpthread.a when searching for -lpthread
> /usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
> /usr/bin/ld: skipping incompatible /usr/lib/libpthread.a when searching for -lpthread
> /usr/bin/ld: cannot find -lpthread
> collect2: ld returned 1 exit status
> --- errorlevel 1
> Command /bin/rebuild returned with code 65280, aborting.

$ cat /etc/rebuild/default
profile=dmd-posix

$ cat /etc/rebuild/dmd-posix
profile=phobos

compiler=dmd
inifile=dmd.conf

exeext=
objext=o


version=DigitalMars
noversion=GNU
version=linux
noversion=Unix
version=Posix
noversion=Windows
noversion=Win32
noversion=Win64
noversion=X86
noversion=PPC
version=X86_64
version=D_InlineAsm
noversion=D_InlineAsm_X86
noversion=D_InlineAsm_PPC
version=D_InlineAsm_X86_64
version=LittleEndian
noversion=BigEndian


[compile]
cmd=dmd -version=Posix -c $i

flag=$i
incdir=-I$i
libdir=-L-L$i
optimize=-O
version=-version=$i


[link]
cmd=dmd -L--start-group -L-lphobos $i -of$o

libdir=-L-L$i
lib=-L-l$i
flag=-L$i


[liblink]
safe=yes
cmd=ar rc $o $i

libdir=
lib=
flag=


[postliblink]
cmd=ranlib $i


[shliblink]
shlibs=no

[dyliblink]
dylibs=no



Frits van Bommel wrote:
> Jason House wrote:
>> I've discovered that the ubuntu linux distribution refuses to run 32 bit applications out of the box.  Are there plans for releasing a 64 bit version of dmd?  Is there anyone more experienced than me that has created a .deb (debian package) file that I can use?
>>
>> jhouse@server:~/dmd/bin$ ls -al dmd
>> -rwxr-xr-x 1 jhouse jhouse 1009284 2007-03-26 00:45 dmd
>>
>> jhouse@server:~/dmd/bin$ ./dmd
>> -bash: ./dmd: No such file or directory
>>
>> jhouse@server:~/dmd/bin$ ldd dmd
>>         not a dynamic executable
>>
>> jhouse@server:~/dmd/bin$ file dmd
>> dmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
> 
> Try installing the "ia32-libs" package.
> 
> Works just fine for me:
> =====
> urxae@urxae:~/opt/dmd/bin$ ls -l dmd
> -rwx------ 1 urxae urxae 1014564 2007-04-19 12:04 dmd
> urxae@urxae:~/opt/dmd/bin$ ./dmd | head -n 2     # to shorten the output
> Digital Mars D Compiler v1.013
> Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
> urxae@urxae:~/opt/dmd/bin$ file dmd
> dmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, stripped
> urxae@urxae:~/opt/dmd/bin$ lsb_release -a
> No LSB modules are available.
> Distributor ID: Ubuntu
> Description:    Ubuntu 6.10
> Release:        6.10
> Codename:       edgy
> urxae@urxae:~/opt/dmd/bin$ uname -m
> x86_64
> =====
April 22, 2007
Jason House wrote:
> Any further tips on getting rebuild/dsss to work?  I'm getting linker errors.  I'm assuming dmd is generating a 32 bit executable and failing to link with 64 bit libraries.  Can dmd generate a 64 bit executable? I'm not sure how to configure it to do so.  I did try hacking at the rebuild config files to see if I could get it to work (resulting file below).
> 
> Can gdc do better?

gdc has an amd 64 binary release that works great.  No rebuild config changes required (besides telling /etc/rebuild/default to use gdc-posix).  There's a related thread from earlier this month that says dmd does not support 64 bit yet.
April 22, 2007
Jason House wrote:
> Any further tips on getting rebuild/dsss to work?  I'm getting linker 
> errors.

This has nothing to do with rebuild/dsss. I had the same problem with "pure" dmd. (Sorry for forgetting to mention that in my previous post)

> I'm assuming dmd is generating a 32 bit executable and failing to link with 64 bit libraries. 

Yes, that's exactly what's happening AFAIK

I got it to work was by running dmd in a 32-bit chroot. See http://ubuntuforums.org/showthread.php?t=24575 for step-by-step instructions.
You'll want to install DMD and gcc+binutils into the chroot, and create a symlink named "dmd" (outside the chroot) to the do_chroot script they provide.

> Can dmd generate a 64 bit executable? 

No, DMD can only generate 32-bit executables.

[snip]
> Can gdc do better?

Although I haven't been able to compile it myself on amd64, the binary distribution[1] worked straight out of the box IIRC. It's a native 64-bit executable and produces 64-bit code. (It's supposed to also be able to generate 32-bit code, but I haven't tried that)

Note that there is at least one issue with it, but considering this is the first release to support 64-bit it works pretty well. Unfortunately, that issue means that Tango's formatted output functions don't compile and (G)Phobos' formatted output doesn't support structs...
Other than that I haven't had any problems with it, as far as I can remember.


[1]: gdc-0.23-x86_64-linux-gcc-4.1.1.tar.bz2 from http://sourceforge.net/project/showfiles.php?group_id=154306
May 31, 2007
Now that I've gotten gdc to work on ubuntu with AMD64, I've started experimenting with the coverage analysis.  gdc -cov will build object files, but doesn't link.  Any tips?

dsss build -cov -llgcov
housebot.d => housebot-0.6
+ /bin/rebuild -Idsss_imports/ -I. -S./ -I/include/d -S/lib/ -cov -llgcov   -oqdsss_objs -Dddoc -unittest -w -g housebot.d -ofhousebot-0.6
/usr/bin/ld: cannot find -lgcov

dsss build -cov -lgcov --libdir=/usr/lib/gcc/x86_64-linux-gnu/4.1.2
housebot.d => housebot-0.6
+ /bin/rebuild -Idsss_imports/ -I. -S./ -I/include/d -S/usr/lib/gcc/x86_64-linux-gnu/4.1.2/ -cov -lgcov   -oqdsss_objs -Dddoc -unittest -w -g housebot.d -ofhousebot-0.6
dsss_objs/_housebot.o: In function `global constructors keyed to 0__D8housebot21mainThreadControllers6__initZ':
/home/jhouse/housebot/0.6/housebot.d:1: undefined reference to `__gcov_init'
...