Cross compiler, building GCC.

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
AndyB
Posts: 15
Joined: Fri Dec 17, 2010 5:43 pm

Cross compiler, building GCC.

Post by AndyB »

I have been trying to build a cross compiler based on the instructions on the wiki and also from http://solarianprogrammer.com/2012/04/1 ... ntu-12-04/

Unfortunately I have been unsuccessful and getting the same error on linux mint 13, ubuntu and xubuntu 12.04.
The problem comes when I attempt to make gcc.
Firstly I have built binutils, gmp, mpfr and mpc.

GCC configures fine as follows:
sudo ../gcc-4.7.0/configure --target=i386-gravity-elf --disable-nls --without-headers --with-newlib --disable-threads --disable-shared --disable-libmudflap --disable-libssp --with-gmp=/opt/gravitygcc --with-mpfr=/opt/gravitygcc --with-mpc=/opt/gravitygcc
but when I attempt to make it I always end up with the following error:
checking for ISO C99 support in <stdio.h>... no
checking for ISO C99 support in <stdlib.h>... no
checking for fully enabled ISO C99 support... no
configure: Debug build flags set to -gdwarf-4 -g3 -O0
checking for additional debug build... no
configure: target-libgomp not built
checking for parallel mode support... no
checking for extra compiler flags for building...
checking for extern template support... yes
checking for custom python install directory... no
checking for -Werror... yes
checking for gets declaration... no
checking for EOWNERDEAD... no
checking for ENOTRECOVERABLE... no
checking for ENOLINK... no
checking for EPROTO... no
checking for ENODATA... no
checking for ENOSR... no
checking for ENOSTR... no
checking for ETIME... no
checking for EBADMSG... no
checking for ECANCELED... no
checking for EOVERFLOW... no
checking for ENOTSUP... no
checking for EIDRM... no
checking for ETXTBSY... no
checking for ECHILD... no
checking for ENOSPC... no
checking for EPERM... no
checking for ETIMEDOUT... no
checking for EWOULDBLOCK... no
checking for int64_t... checking for LFS support... no
checking sys/ioctl.h usability... no
checking sys/ioctl.h presence... no
checking for sys/ioctl.h... no
checking sys/filio.h usability... no
checking sys/filio.h presence... no
checking for sys/filio.h... no
checking for poll... no
checking for S_ISREG or S_IFREG... no
checking sys/uio.h usability... no
checking sys/uio.h presence... no
checking for sys/uio.h... no
checking for writev... no
checking for complex.h... (cached) no
no
checking for ISO C99 support to TR1 in <ctype.h>... no
checking fenv.h usability... no
checking fenv.h presence... no
checking for fenv.h... no
no
checking for ISO C99 support to TR1 in <stdint.h>... no
checking for ISO C99 support to TR1 in <math.h>... no
no
no
checking stdbool.h usability... no
checking stdbool.h presence... yes
configure: WARNING: stdbool.h: present but cannot be compiled
configure: WARNING: stdbool.h: check for missing prerequisite headers?
configure: WARNING: stdbool.h: see the Autoconf documentation
configure: WARNING: stdbool.h: section "Present But Cannot Be Compiled"
configure: WARNING: stdbool.h: proceeding with the compiler's result
checking for stdbool.h... no
checking stdalign.h usability... no
checking stdalign.h presence... yes
configure: WARNING: stdalign.h: present but cannot be compiled
configure: WARNING: stdalign.h: check for missing prerequisite headers?
configure: WARNING: stdalign.h: see the Autoconf documentation
configure: WARNING: stdalign.h: section "Present But Cannot Be Compiled"
configure: WARNING: stdalign.h: proceeding with the compiler's result
checking for stdalign.h... no
checking for the value of EOF... configure: error: computing EOF failed
make[1]: *** [configure-target-libstdc++-v3] Error 1
make[1]: Leaving directory `/home/andy/Downloads/build'
make: *** [all] Error 2
I have tried searching without any luck, Ive tried the GCC and Ubuntu IRC channels with no success either.
I am really hoping that someone here could shed some light please?

Thank you.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Cross compiler, building GCC.

Post by bluemoon »

AndyB wrote:I have been trying to build a cross compiler based on the instructions on the wiki and also from http://solarianprogrammer.com/2012/04/1 ... ntu-12-04/

Unfortunately I have been unsuccessful and getting the same error on linux mint 13, ubuntu and xubuntu 12.04.
The problem comes when I attempt to make gcc.
Firstly I have built binutils, gmp, mpfr and mpc.

GCC configures fine as follows:

Code: Select all

sudo ../gcc-4.7.0/configure --target=i386-gravity-elf --disable-nls --without-headers --with-newlib --disable-threads --disable-shared --disable-libmudflap --disable-libssp --with-gmp=/opt/gravitygcc --with-mpfr=/opt/gravitygcc --with-mpc=/opt/gravitygcc
but when I attempt to make it I always end up with the following error:
checking for ISO C99 support in <stdio.h>... no
checking for ISO C99 support in <stdlib.h>... no
<snip>
If you are not sure, follow the wiki exactly. some flags you provided do not appear in the wiki walkthrough and is causing trouble. Are you sure you have a working newlib? do you build binutils correctly to support your target?
AndyB wrote:I have tried searching without any luck
You can't search with luck, you need searching skill.

EDIT: Do you even have a working gcc on the linux host? try sudo apt-get install build-essential #-o
AndyB
Posts: 15
Joined: Fri Dec 17, 2010 5:43 pm

Re: Cross compiler, building GCC.

Post by AndyB »

The extra flags are there because I am following the MIT 6.828 course which on their tools page lists these flags as required. (http://pdos.csail.mit.edu/6.828/2011/tools.html).

Yes I have an existing gcc and build-esstentials binutils is built for my target.

berkus wrote:

Code: Select all

sudo ../gcc-4.7.0/configure
sudo to configure, seriously?
sudo or not sudo, what difference would it make. Could you elaborate on your post a bit? How about trying to contribute something helpful rather than condescending?
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Cross compiler, building GCC.

Post by thepowersgang »

If you do not know the difference, then you fail basic knowledge of your system.

To explain the difference, by running configure as root (via sudo) all files created will be owned by root, and will not be readable by you (iirc, root-created files tend to have funny permissions). This means that every other step in the compilation process would have to be run as root.

In linux (and almost all unix derivatives) there should be no reason past system administration for you to run a command as root. Running anything as root is a security risk (a minimal one, but one none the same) and hence you should avoid using it.
tl;dr - Running routing commands as root is a bad thing.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Cross compiler, building GCC.

Post by gravaera »

Yo:
AndyB wrote:
berkus wrote:

Code: Select all

sudo ../gcc-4.7.0/configure
sudo to configure, seriously?
sudo or not sudo, what difference would it make. Could you elaborate on your post a bit? How about trying to contribute something helpful rather than condescending?
Running configure as root isn't going to change the outcome for this particular package, but the other information it serves up to people reading the topic is more relevant than you think it is. It means you have no idea what you're doing, and I should dismiss this thread and move on :)
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
AndyB
Posts: 15
Joined: Fri Dec 17, 2010 5:43 pm

Re: Cross compiler, building GCC.

Post by AndyB »

thepowersgang wrote:If you do not know the difference, then you fail basic knowledge of your system.

To explain the difference, by running configure as root (via sudo) all files created will be owned by root, and will not be readable by you (iirc, root-created files tend to have funny permissions). This means that every other step in the compilation process would have to be run as root.

In linux (and almost all unix derivatives) there should be no reason past system administration for you to run a command as root. Running anything as root is a security risk (a minimal one, but one none the same) and hence you should avoid using it.
tl;dr - Running routing commands as root is a bad thing.
Thank you for the elaboration. I am well aware of the effects that root would have on the permissions but as you said its irrelevant as long as I run make as root aswel.

The reason I even attempted it was because it wouldnt work in the first place so I gave it a shot as root just to see if that would work.

Either way, root or no root, its not the cause of the above error message.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Cross compiler, building GCC.

Post by Solar »

AndyB wrote:The reason I even attempted it was because it wouldnt work in the first place so I gave it a shot as root just to see if that would work.
Called "trial & error", and generally the least effective and instructive of all error-solving techniques. All that "sudo" does is allowing you to fail in a more spectacular and potentially more damaging matter. With a bit of luck (since you didn't give a --prefix), you damaged your system compiler..

Our strongest recommendation, repeated frequently over the years, is to start by following the Wiki tutorial to the letter, and only then (once you got it right once) customizing paths, options, targets etc.

Code: Select all

make[1]: *** [configure-target-libstdc++-v3] Error 1
Did you, by any chance, attempt to build the C++ standard library? Like, by typing "make all" instead of "make all-gcc"? Note how virtually everything in that configure attempt fails...

Thanks to using "sudo", my recommendation at this point is to start over with a complete reinstall of your Linux...
Every good solution is obvious once you've found it.
AndyB
Posts: 15
Joined: Fri Dec 17, 2010 5:43 pm

Re: Cross compiler, building GCC.

Post by AndyB »

Solar wrote:Thanks to using "sudo", my recommendation at this point is to start over with a complete reinstall of your Linux...
Thats fine, Im working from a VM and I have the disk image backed up from before I made the changes. Thank you for the recommendation.

Back to the wiki it is.
Post Reply