Page 1 of 1

Cross-compiler, libgcc, newlib

Posted: Fri Jun 29, 2012 2:05 pm
by kr651129
Ok, this is driving me nuts. I'm able to make a flat cross compiler per the tutorial on FreeBSD 9.0 but every time I run

Code: Select all

gmake all-target-libgcc
gmake install-target-libgcc
I get errors (will post them later, I'm at work now)

I also can't port newlib with FreeBSD 9.0 as the host. I'm using all of the GNU tools for the build and I'm coming up with zilch.

I can however follow all of the tutorials step by step with no errors on cygwin.

Can someone tell me what I'm missing or point me in the right direction?

edit:
I meant to say I was using gmake not make

Re: Cross-compiler, libgcc, newlib

Posted: Fri Jun 29, 2012 3:46 pm
by Brynet-Inc
If you don't have the error output handy, what's the point of posting an incomplete message?

Because we're left guessing.. FreeBSD doesn't use GNU make, it's possible that the libgcc target of that particular version of gcc is broken.

Re: Cross-compiler, libgcc, newlib

Posted: Fri Jun 29, 2012 9:39 pm
by bluemoon
I get solutions (will post them later, I'm at holiday now) :mrgreen:

Anyway, newlib build with provided compiler as-is, so it probably drag in FreeBSD stuff if you configure to use the hosted compiler directly. You may either use a clean cross-compiler toolchain or provide enough flag to the configure script to specify a freestanding environment.

Re: Cross-compiler, libgcc, newlib

Posted: Sun Jul 01, 2012 12:15 am
by kr651129
bluemoon -- thanks for the info! I'm looking forward to your solution when you get back.

Here is the error I'm getting

Code: Select all

$ gmake all-target-libgcc
...................
checking for suffix of object files... configure: error: in '/usr/home/kclark/build-gcc/i586-elf/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See 'config.log' for more details.
config.log
http://pastebin.com/i8jMbQde

Re: Cross-compiler, libgcc, newlib

Posted: Sun Jul 01, 2012 7:47 am
by kr651129
I compiled them all by themselves and put them In /use/local/cross then I pointed binutils.and gcc to them.

Re: Cross-compiler, libgcc, newlib

Posted: Sun Jul 01, 2012 7:59 am
by Griwes
kr651129 wrote:bluemoon -- thanks for the info! I'm looking forward to your solution when you get back.
bluemoon was trolling you, wasn't he?

Re: Cross-compiler, libgcc, newlib

Posted: Mon Jul 02, 2012 12:32 am
by Solar

Code: Select all

See 'config.log' for more details.
The log of what configure actually tried to do, and what the real error was, is the section after "## Core tests. ##", up to the section "## Running config.status. ##".

I always wonder how people miss this "hint". It cannot be any more obvious, really.

Re: Cross-compiler, libgcc, newlib

Posted: Mon Jul 02, 2012 1:45 am
by JamesM
config.log is a hairy mess not really obviously easy to parse.
It really is all kinds of nasty. My technique is to reverse seach for "error" from the end. That usually gets the "right" erroring command.

Re: Cross-compiler, libgcc, newlib

Posted: Mon Jul 02, 2012 2:14 am
by Solar
Seconded, it's not exactly easy. That's why I memorized "Running config.status". That's where the configure log ends and the environment dump begins.

Re: Cross-compiler, libgcc, newlib

Posted: Mon Jul 09, 2012 11:43 am
by JessyV
Personnally, I'm on Windows (by obligation, not by choice ;) using TDM MinGW/MSYS and I've never used FreeBSD, but I already had problems making a cross-compiler.

Before anything else : http://wiki.osdev.org/GCC_Cross_Compiler

What actually matters ? The configure script or the make execution ?
If it is the configure script, the primary reason of configure failing could be that FreeBSD's shell is not compatible. You should use GNU Bash, which is known to be compatible. I don't know, however, how this is done, but it should be as simple as downloading the package from the GNU mirror FTP site,, unpacking it somewhere, doing a configure in a separate directory, doing make all and make install, and then prefixing ./configure of the name of the GNU Bash executable to ensure FreeBSD shell doesn' try to execute it by itself. If this works, skip the rest of this post.
Also, the make program is not in fault as the O.P. is using GNU make (I see it in the 'gmake' command) which is the preferred make program of all GNU programs, including GCC.

If it still doesn't work, I would recommend to use Binutils v2.22/GCC 4.6.3 (GCC can be higher, but it worked for me with 4.6.3). Just look at this table : http://wiki.osdev.org/Cross-Compiler_Successful_Builds .

Unpack the binutils to, say, /usr/src/binutils-2.22 and build them passing to the configure prefix your --prefix=* plus the --disable-nls (NLS support just gave me problems, while not being so useful to me, though my native language is French (fr-fr), I'm nearly 16 and actually speak English quite well, I think this is a bare minimum when thinking of lerning programming, as much of the documentation is written in Shakespeare's language).

Then, unpack gcc to, say, /usr/src/gcc-4.6.3. Then, unpack GMP MPFR and MPC to, respectively, usr/src/gcc-4.6.3/gmp, usr/src/gcc-4.6.3/mpfr and /usr/src/gcc-4.6.3/mpc. This will ensure that they are built with all the correct settings for GCC, and will avoid confusion with the options.
Also, think of getting the source code for libiconv and unpacking it to usr/src/gcc-4.6.3/iconv. I didn't have to do this as Windows doesn't use libiconv and lets MinGW use it's own which is the same for all programs. However, I heard that on FreeBSD, the system's version could not work, be found, or something in ths kind. This similarly ensures that it is built accordingly for GCC to use.

For GCC, you should configure it with the usual --prefix, plus --disable-nls to match the binutils configuration, --enable-languages=c (or =c,c++ if you want C++, that's up to you to decide), and eventually --without-headers if neded.
You don't need to add anything as the GMP/MPFR/MPC/iconv libraries will be found automatically.

If that still doesn't work, please send us the precise error messages that you get.

Re: Cross-compiler, libgcc, newlib

Posted: Tue Jul 10, 2012 2:56 am
by Solar
Hmm... wouldn't the simplest thing be to have mpc / mpfr / gmp installed by the system package manager? You don't need them on the target (or cross) side, only on the host side, and the package manager is usually better-tested at providing packages than any tutorial-driven manual compile...