D.gnu - building GDC-0.18 on an AMD64
- Thomas Kuehne (145/145) Jun 01 2006 -----BEGIN PGP SIGNED MESSAGE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Below is a mini HOWTO, that describes how to build GDC-0.18(GCC-3.4.4) on an AMD64. The steps required migth differ from system to system. I highly recomend that you use "--prefix=/some/where/", otherwise you might override your system's GCC with a broken one. ^-^ 1) unpack gcc tar -xjf /download/gcc-3.4.4.tar.bz2 2) unpack gdc cd /build/gcc-3.4.4/gcc tar -xzf /download/gdc-0.18.tar.gz 3) setup gdc cd /build/gcc-3.4.4 ./gcc/d/setup-gcc.sh 4) adapt d/d-lang.h - --- /build/gcc-3.4.4/gcc/d/d-lang.h +++ /build/gcc-3.4.4/gcc/d/d-lang.h -221,4 +221,10 static inline tree build2(enum tree_code c, tree t, tree a, tree b) { return build(c, t, a, b); } #endif +#define D_CPU_VERSYM "X86" +#define D_OS_VERSYM "linux" +#define D_OS_VERSYM2 "Unix" +#define POINTER_SIZE 32 +#define UNITS_PER_WORD 4 + #endif 5) build gcc (will fail to build Phobos) cd /build/gcc-3.4.4 ./configure --enable-languages=c,d make 6) configure Phobos cd /build/gcc-3.4.4/gcc/d/phobos PATH=/build/gcc-3.4.4/gcc/:$PATH CFLAGS="-m32" ./configure --target=i386-unknown-linux 7) fix Phobos' Makefile - --- /build/gcc-3.4.4/gcc/d/phobos/Makefile - --- /build/gcc-3.4.4/gcc/d/phobos/Makefile -16,7 +16,7 target_alias = i386-unknown-linux - -host_alias = +host_alias = i386-unknown-linux AR = ar RANLIB = ranlib -49,8 +49,8 LIBS=-lm -lpthread - -CC=gcc - -GDC=gdc +CC=gcc -m32 +GDC=gdc -m32 srcdir=. 8) build Phobos cd /build/gcc-3.4.4/gcc/d/phobos mkdir -p i386-unknown-linux/gcc PATH=/build/gcc-3.4.4/gcc/:$PATH make 9) install cd /build/gcc-3.4.4 make install 10) try to use gdc: /where/ever/bin/gdc -m32 -L/usr/lib32 test.d 11) adapt gdmd 1/2 (should enable you to compile with gdmd) - --- /where/ever/bin/gdmd - --- /where/ever/bin/gdmd -119,12 +119,12 } use subs qw(errorExit); - -my $gcc_version = `$gdc -dumpversion`; +my $gcc_version = `$gdc -m32 -dumpversion`; chomp $gcc_version; $gcc_version =~ m/^(\d+)\.(\d+)/; my ($gcc_maj, $gcc_min) = ( $1, $2 ); - -my $target_machine = `$gdc -dumpmachine`; +my $target_machine = `$gdc -m32 -dumpmachine`; chomp $target_machine; sub addSourceFile($) { -282,7 +282,7 } if (! scalar( sources) && ! ($link && scalar( objects))) { - - my cmd = ($gdc, '--version', out); + my cmd = ($gdc, '-m32', '--version', out); my $result = system( cmd); signal printUsage; -323,7 +323,7 } - - my cmd = ($gdc, out, '-c', all_sources_hack, $srcf, '-o', $outf ); + my cmd = ($gdc, out, '-m32', '-c', all_sources_hack, $srcf, '-o', $outf ); if ( $show_commands ) { print join(' ', cmd), "\n"; } 12) adapt gdmd 2/2 (should enable you to link with gdmd) Adapt /where/ever/bin/gdmd's | | my cmd = ($gdc, out, dobjects, objects, link_out); | A simple solution might be: | | my cmd = ($gdc, "-m32", "-L/usr/lib32", out, dobjects, objects, link_out); | If the simple way doesn't work, check what gcc is doing in step 10: /where/ever/bin/gdc -m32 -verbose -L/usr/lib32 test.d In my case it's a bit more compilcated: (undefined reference to `__gmon_start__' ...) | my cmd = ("/opt/gdc/gdc-0.18/libexec/gcc/x86_64-unknown-linux-gnu/3.4.4/collect2", | "--eh-frame-hdr", | "-m", "elf_i386", | "-dynamic-linker", "/lib/ld-linux.so.2", "/usr/lib/../lib/../lib32/crt1.o", | "/usr/lib/../lib/../lib32/crti.o", | "/opt/gdc/gdc-0.18/lib/gcc/x86_64-unknown-linux-gnu/3.4.4/32/crtbegin.o", | "-L/usr/lib32", | "-L/opt/gdc/gdc-0.18/lib/gcc/x86_64-unknown-linux-gnu/3.4.4/32", | "-L/opt/gdc/gdc-0.18/lib/gcc/x86_64-unknown-linux-gnu/3.4.4", | "-L/opt/gdc/gdc-0.18/lib/", | "-L/lib/", | "-L/usr/lib/", | out, dobjects, objects, link_out, | "-lgphobos", | "-lm", | "-lgcc_s_32", | "-lgcc", | "-lpthread", | "-lc", | "/opt/gdc/gdc-0.18/lib/gcc/x86_64-unknown-linux-gnu/3.4.4/32/crtend.o", | "/usr/lib/../lib/../lib32/crtn.o" | ); | Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEfvLD3w+/yD4P9tIRAq4gAKCDKtqbEvCJoQwn0Z0WGCP8ecs+2ACgwxoL 4pfdpqLS8mgVu/7fyLOoM8s= =oOem -----END PGP SIGNATURE-----
Jun 01 2006