Page 1 of 1

Cross compiler on AMD64 machine

Posted: Thu Sep 06, 2007 6:38 pm
by senaus
Hi guys,
I got a new laptop recently, with an Athlon 64 X2 chip. Dual core, 64 bit - killing two birds with one stone as far as osdev is concerned - I couldn't resist :)

Anyway, I installed the latest version of Kubuntu for AMD64, and began to get my dev environment set up. The trouble was, when I tried to compile my kernel, GAS spat out loads of errors about operand size etc, so I summised that it must be trying to compile my 32 bit kernel as 64 bit.

So I started to follow the instructions on the wiki on setting up a cross compiler, downloaded the source files, set up the environment, but when I got to configuring binutils, apparently "config.guess" couldn't determine my host machine type.

I tried adding the "--host" option, with operands containing many combinations of "x86_64", "amd64", "linux-gnu", "x86_64-pc", but none were recognised. Google returned no promising results, so I'm hoping one of you guys have either been through this yourself, or know more than me about this sort of thing. Any input will be appreciated!

Thanks,
Sean

Posted: Thu Sep 06, 2007 7:12 pm
by Brynet-Inc
That's pretty cool 8)..

What version of binutils are you attempting to use? I think a new version was released recently..

Try posting your errors btw... might be beneficial.. :wink:

Posted: Thu Sep 06, 2007 7:49 pm
by senaus
Ok, here's step one:

Code: Select all

~/dk2os/tools/build-binutils$ ../binutils-2.9.1/configure --target=i586-elf --prefix=/home/sen/dk2os/tools --disable-nls
Config.guess failed to determine the host type.  You need to specify one.
Then I try to specify a host, and the following happens for pretty much everything I try:

Code: Select all

~/dk2os/tools/build-binutils$ ../binutils-2.9.1/configure --target=i586-elf --prefix=/home/sen/dk2os/tools --host=x86_64-pc-linux-gnu --disable-nls
Invalid configuration `x86_64-pc-linux-gnu': machine `x86_64-pc' not recognized
Invalid configuration `x86_64-pc-linux-gnu': machine `x86_64-pc' not recognized
Unrecognized host system name x86_64-pc-linux-gnu.
Any thoughts?

Posted: Thu Sep 06, 2007 7:55 pm
by Brynet-Inc
Why are you trying to use such an obsolete version of binutils? :?

Version 2.9.1 was released on May 1st 1998.. Several years before the amd64/x86-64 architecture even existed!! :lol:

Use the latest release.. :roll:

http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2
or
http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.gz

It was released on the 28th of August.. 2007 8)

Posted: Thu Sep 06, 2007 8:11 pm
by senaus
Aaaah, thanks for that! It was the latest version on the random FTP mirror I picked, so I assumed it was new... oops. I'll try again now, and post if I have any problems. :)

Cheers,
Sean

Posted: Thu Sep 06, 2007 8:36 pm
by senaus
Argh, now it says my "C compiler cannot create executables..." What is it supposed to do then?

Here is the full output:

Code: Select all

~/dk2os/tools/build-binutils$ ../binutils-2.18/configure --target=i586-elf --prefix=/home/sen/dk2os/tools --disable-nls
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... i586-pc-elf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking for C compiler default output file name... configure: error: C compiler cannot create executables
See `config.log' for more details.
I'm off to bed now, too tired to tackle this problem tonight. Any input appreciated as always :)

Oh, and here is my GCC version info:

Code: Select all

~/dk2os/tools/build-binutils$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-checking=release x86_64-linux-gnu
Thread model: posix
gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)

Posted: Thu Sep 06, 2007 10:47 pm
by Brynet-Inc
This is a shot in the dark... but did you try reading config.log? :wink:

Posted: Fri Sep 07, 2007 5:58 am
by senaus
Hi,
I did some more Googling this morning, and it turns out G++ wasn't installed... That fixed the error above, but I then had to botch the makefile in bfd/doc to get rid of a 'missing makeinfo' error, even though the latest makeinfo was present.

Anyway, binutils is compiled and installed now, and GCC is in progress. Thanks for your help!