Problems building gcc cross-compiler

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
TeoZec
Posts: 4
Joined: Sat Oct 05, 2013 3:49 am
Location: Melegnano (MI), Italia

Problems building gcc cross-compiler

Post by TeoZec »

Hello.
I'm at the very beginning of my os development.
I tried to build gcc cross-compiler following the GCC Cross-Compiler tutorial on the wiki, but it didn't work.
I used gcc 4.8.1 and binutils 2.23.2 on Linux Mint Olivia 32 bit.
I wrote this shell script:

Code: Select all

#!/bin/sh

export PREFIX=$HOME/opt/cross
export TARGET=i586-elf
export PATH="$PREFIX/bin:$PATH"

cd $HOME/src
mkdir build-binutils
cd build-binutils
../binutils-2.23.2/configure --target=$TARGET --prefix="$PREFIX" --disable-nls
make
make install
cd $HOME/src

# If you wish to build these packages as part of gcc:
mv gmp-5.1.3 gcc-4.8.1/gmp
mv mpfr-3.1.2 gcc-4.8.1/mpfr
mv mpc-1.0.1 gcc-4.8.1/mpc

mkdir build-gcc
cd build-gcc
../gcc-4.8.1/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
and I executed it.
Before make all-gcc everything went well, but then I got this errors:

../gcc-4.8.1/gcc/objc/config-lang.in doesn't set $language.
make: *** Nessuna regola per generare l'obiettivo "all-gcc". Arresto.
make: *** Nessuna regola per generare l'obiettivo "all-target-libgcc". Arresto.
make: *** Nessuna regola per generare l'obiettivo "install-gcc". Arresto.
make: *** Nessuna regola per generare l'obiettivo "install-target-libgcc". Arresto.

In English (I'm Italian) it should be something like:

../gcc-4.8.1/gcc/objc/config-lang.in doesn't set $language.
make: *** No rule to generate target "all-gcc". Stop.
make: *** No rule to generate target "all-target-libgcc". Stop.
make: *** No rule to generate target "install-gcc". Stop.
make: *** No rule to generate target "install-target-libgcc". Stop.


I don't understand what went wrong. Can you help me, please?

Thanks,
TeoZec
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Problems building gcc cross-compiler

Post by sortie »

Hi.

Don't use a shell-script, but rather enter the commands one by one. This way you get to fully understand what's going on. (Of course, more advanced users should use a shell-script, but the commands from the cross-compiler tutorials are not meant to be a shell-script - for instance, the mv commands should only be done once).

A guess is that your gcc ./configure is failing, but you proceed to run make anyways. I recommend the 'set -e' command in your shell scripts, as it makes the shell exit after the first error. But examine whether the gcc ./configure command works.
TeoZec
Posts: 4
Joined: Sat Oct 05, 2013 3:49 am
Location: Melegnano (MI), Italia

Re: Problems building gcc cross-compiler

Post by TeoZec »

Hi.
Thank you very much. I tried it typing the commands one by one.
When I typed "make all-target-libgcc" I got this error:

checking for suffix of object files... configure: error: in `/home/matteo/src/build-gcc/i586-elf/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make: *** [configure-target-libgcc] Errore
(it stands for Error) 1

I attached the config.log file.

Then, when I types "make install-target-libgcc" I got:

/bin/bash ../gcc-4.8.1/mkinstalldirs /home/matteo/opt/cross /home/matteo/opt/cross
make[1]: ingresso nella directory "/home/matteo/src/build-gcc/i586-elf/libgcc"
make[1]: *** Nessuna regola per generare l'obiettivo "install". Arresto.
make[1]: uscita dalla directory "/home/matteo/src/build-gcc/i586-elf/libgcc"
make: *** [install-target-libgcc] Errore 2


In English it's something like:

/bin/bash ../gcc-4.8.1/mkinstalldirs /home/matteo/opt/cross /home/matteo/opt/cross
make[1]: entrance in the directory "/home/matteo/src/build-gcc/i586-elf/libgcc"
make[1]: *** No rule to generate target "install". Stop.
make[1]: exit from directory "/home/matteo/src/build-gcc/i586-elf/libgcc"
make: *** [install-target-libgcc] Error 2


I tried anyhow to follow the Bare Bones tutorials to see if it had worked. gcc and NASM worked, but when I tried to link all, I got this error:

collect2: fatal error: cannot find 'ld'
compilation terminated.


I don't understand why ld wasn't installed, while gcc was.
Thanks,
TeoZec
Attachments
config.log.txt
gcc build log file
(26.65 KiB) Downloaded 30 times
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Problems building gcc cross-compiler

Post by jnc100 »

Is this the config.log from the main build directory, or from the libgcc subdirectory?

We need to see the one from the libgcc directory.

Regards,
John.

edit: Also, when typing the commands in yourself, did you add $PREFIX/bin to your path?
TeoZec
Posts: 4
Joined: Sat Oct 05, 2013 3:49 am
Location: Melegnano (MI), Italia

Re: Problems building gcc cross-compiler

Post by TeoZec »

jnc100 wrote:Is this the config.log from the main build directory, or from the libgcc subdirectory?

We need to see the one from the libgcc directory.

Regards,
John.

edit: Also, when typing the commands in yourself, did you add $PREFIX/bin to your path?
It's from the main build directory. I don't have the libgcc subdirectory, but I have a libcpp subdirectory. I'll attach the config.log in this one.
Yes, I did: I added $PREFIX/bin to my path.

Regards,
Matteo
Attachments
config.log.txt
config.log from libcpp subdirectory
(62.45 KiB) Downloaded 55 times
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Problems building gcc cross-compiler

Post by sortie »

Okay, I'm a bit puzzled here. I'm not sure what's going wrong. Now, first of all, use the English language when running the tools. You can type this magic command:

Code: Select all

export LC_ALL=en_US.UTF-8
to force your locale to be English. (Perhaps LC_ALL=C is more appropriate).

Next, your i586-elf-gcc doesn't link with 'ld', but uses i586-elf-ld. In fact, any tool (as, objcopy, ...) should use the i586-elf- prefix because that uses your cross-binutils. The fact that it is complaining about 'ld' may be troublesome, or perhaps its just leaving out the cross-prefix.

Finally, please attach a log of your entire cross-compilation from the start to the point where you get the error. Be sure to have set LC_ALL as above. You need to either set your terminal scroll-back to infinite or perhaps use a shell command (such as 'script') to save the log to a file.
TeoZec
Posts: 4
Joined: Sat Oct 05, 2013 3:49 am
Location: Melegnano (MI), Italia

Re: Problems building gcc cross-compiler

Post by TeoZec »

Hi.
I found the problem. It was very stupid, actually: I didn't have g++ on my system. I just installed it and all worked, and now I have my very nice kernel saying hello to the world. :D
Thank you very much for your help.
Regards,
Matteo
Post Reply