Page 1 of 2
Cross-Compiler Problem - GMP and MPFR
Posted: Mon Jun 02, 2008 9:18 am
by AJ
Hi,
I know there's a topic along very similar lines here at the moment, but this is kind of a new question.
I'm having a go at building the
GCC Cross-Compiler at the moment with Binutils 2.18 and GCC 4.3.0, but have stumbled upon the GMP and MPFR error which is becoming infamous!
I re-ran Cygwin's setup with GMP, LibGMP, MPFR and LibMPFR, but still no good. So, I have cross-compiled GMP and MPFR, which seems to be OK (they are installed, no build errors in /usr/cross/lib with headers in /usr/cross/include. By default, I still got the common error message:
Code: Select all
checking for correct version of gmp.h... yes
checking for correct version of mpfr.h... no
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.0+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.
So, I tried again with the following:
Code: Select all
Adam J@ADAMJ /usr/src/build-gcc
$ ../gcc-4.3.0/configure --target=$TARGET --prefix=$PREFIX \
--disable-nls --enable-languages=c,c++ --with-newlib \
--without-headers --with-gmp=$PREFIX --with-mpfr=$PREFIX
But still get the same error message. As per the GNU web page, I have also tried using --with-gmp-lib=... and --with-gmp-include=... and the same parameters for mpfr.
Any ideas what I should be doing differently? I seem to have working library paths which I am pointing GCC to in exactly the way stated on the GNU site.
Cheers,
Adam
Posted: Mon Jun 02, 2008 10:06 am
by JamesM
Hi,
Have you ensured that you compiled GMP before you compiled MPFR? MPFR relies on GMP, so if you compiled that first then it will be based off the cygwin standard GMP, which could be why configure is failing.
Cheers,
James
Posted: Mon Jun 02, 2008 10:16 am
by jnc100
Generally as part of its tests, configure will try and compile something with said libraries. If you examine the config.log file you might be able to track down the command line it tried to execute which failed and see the output from the compiler at the failure. Search it for gmp or something.
edit:
alternatively...
Regards,
John.
Posted: Mon Jun 02, 2008 10:25 am
by Brynet-Inc
I can confirm that binutils-2.18 and gcc-4.3.0 work on OpenBSD 4.3 without problems, using the instructions on the Wiki(
Minus --with-newlib on GCC):
Code: Select all
[os-cross]~: $ i686-elf-gcc -v
Using built-in specs.
Target: i686-elf
Configured with: ../gcc-4.3.0/configure --target=i686-elf --prefix=/home/os-cross --disable-nls --enable-languages=c --without-headers --with-gmp=/usr/local --with-mpfr=/usr/local
Thread model: single
gcc version 4.3.0 (GCC)
[os-cross]~: $ i686-elf-as -v
GNU assembler version 2.18 (i686-elf) using BFD version (GNU Binutils) 2.18
[os-cross]~: $
@AJ, You need to ensure --with-gmp/mpfr point the locations of the "installed" libraries, in my case, gmp-4.2.2 and 2.3.1 are in /usr/local (
Adhering the proper hier, libraries in /usr/local/lib, headers in /usr/local/include..)
I'll never understand why people have problems following instructions... every time I try to repeat them.. it's successful.
Posted: Mon Jun 02, 2008 10:31 am
by Combuster
I decided to put a [no] in the tested table for now as it does not work obviously. For the moment that should deter beginners from using it.
That said, from what I figured about GMP and MPFR is that they optimize out transcendent functions - a feature not present in prior versions, and one which we probably won't use for average compile work either. jnc100's link suggested that GCC could be compiled
without them, so figuring that out would provide us with a 4.3.0 GCC with all the upgrades but without that bulky feature we're not going to use anyway.
That said, the GCC devs could IMO have done that a bit better.
edit: @Brynet-Inc: we're talking cygwin here.
Posted: Mon Jun 02, 2008 10:31 am
by AJ
Thanks for the tips guys - I don't have my development machine again until tomorrow but will give it a go with the suggestions then.
Also, although I build GMP first as JamesM suggested, I didn't point MPFR to my new GMP installation - d'oh!
Cheers,
Adam
Edit (@Combuster): I have placed a scratchpad wiki page under my user name so that I can track my progress with this one. Once I have got it compiling nicely a few times, I'll format and word it all properly and add it to the main wiki (unless someone else gets there first).
Posted: Mon Jun 02, 2008 10:35 am
by Brynet-Inc
Why should it be marked as "No" when it does actually work? The problem is Cygwin/user related..
Anyway,
Binary constants look like a neat new feature in GCC 4.3.0.
Posted: Mon Jun 02, 2008 10:56 am
by Combuster
Brynet-Inc wrote:Why should it be marked as "No" when it does actually work? The problem is Cygwin/user related..
Hence, like you said, it is known to *not* work. It takes only one counterexample to disprove a statement - in this case "This works for the combination 2.18 and 4.3.0" is wrong, because it does not hold under all circumstances (i.e. cygwin).
Posted: Mon Jun 02, 2008 3:54 pm
by Brynet-Inc
@AJ,
http://www.osdev.org/wiki/User:AJ/Building_GMP is wrong... --build should be omitted, and --prefix should be where your host OS keeps 3rd party packages, It's GCC that needs to be linked with those libraries not your freestanding environment.
Now, If you were porting GCC to your OS, then yes, they would be required.
In my setup, I installed both gmp/mpfr via OpenBSD ports system...
Posted: Tue Jun 03, 2008 2:04 am
by AJ
Thanks Brynet,
Obviously one of the first rules of OS Devving is 'know your toolchain' and I'm now pretty confident with GCC, having built cross-compilers and a custom toolchain, but GMP and MPFR are two tools I have never used, so I panicked and applied the same rules as for building Binutils and GCC.
I have sat back and had a look at what I am doing and am going to try again today. One thing that I find odd is that with Cygwin's default LibGMP and LibMPFR installed, it still doesn't seem to work despite the fact they seem to be the version numbers required by GCC (Cygwin's GMP is 4.2.2 and MPFR is 2.3.1).
It does look like others have had success, so I'm going to assume a broken Cygwin installation in addition to error ID10-T, and will reinstall from scratch.
Cheers,
Adam
Posted: Tue Jun 03, 2008 5:05 am
by AJ
Ok, thanks again for the help everyone. I now have a working 4.3.0 cross compiler and binutils for i586.
I have written down exactly what I did at [wiki]User:AJ/Building GMP[/wiki] and would be grateful if some others could follow this on Cygwin to let me know if it goes OK for you too. If so, I will format the article properly and add a link to it somewhere in the
GCC Cross-Compiler article. If I get enough positive responses, I can update that grid to 'yes' as well
Apologies to Brynet if you felt I did not RTFM enough initially - I started out yesterday afternoon but after a good night's sleep, it all became much clearer
Cheers,
Adam
Posted: Tue Jun 03, 2008 5:45 am
by Solar
Combuster wrote:Brynet-Inc wrote:Why should it be marked as "No" when it does actually work? The problem is Cygwin/user related..
Hence, like you said, it is known to *not* work. It takes only one counterexample to disprove a statement - in this case "This works for the combination 2.18 and 4.3.0" is wrong, because it does not hold under all circumstances (i.e. cygwin).
The fine point being that, at least initially, the how-to in the Wiki was primarily written
for Cygwin...
Posted: Tue Jun 03, 2008 11:36 am
by jnc100
I think AJs article should include some reason behind the new dependencies on gmp and mpfr (I don't like to edit an article in someone else's namespace). Someone please correct me if I'm wrong:
As far as I understand, gmp and mpfr are used to help gcc perform optimisations. The general idea is that if the compiler can determine that a value is loaded to a variable, and then an operation (e.g. add, sub, mul, div etc) is performed on that variable then in fact you could just load the result to that variable and save yourself the extra instructions. The problem is that (especially with cross compilers) there is no easy way to work out on the build machine what value the target machine would actually generate as a result for the particular operation (e.g. differences with bit-lengths, rounding, epsilon values etc). These libraries provide functions that should generate the correct result on a particular target architecture, regardless of the processor the library itself is actually running on.
Regards,
John.
Posted: Wed Jun 04, 2008 4:31 am
by AJ
I'll get it up on the main wiki and do some tidying up later today. I've followed the build process from scratch again and it all seems OK - perhaps someone else would like to try, though?
@jnc100: Please do add a more detailed intro - you seem to know a lot more about GCC's use of these libs than I do, so are in a better position to write it. If you want to wait until it's out of my user space and on the main wiki, I'll try to have that done later today.
Cheers,
Adam
[Edit]The page has now been moved to
Building GMP. When tried and tested, I will add some links to the article from relevant locations and set the 'yes' item in the main Cross-Compiler articles table.[/Edit]
Posted: Wed Jun 04, 2008 2:52 pm
by jnc100
AJ wrote:Please do add a more detailed intro
Thanks, I'll try and do that when I get a chance.
To confuse things slightly: I managed to get gcc 4.3 and gmp/mpfr to cross-compile in a slightly different way. Basically, if the gmp and mpfr sources are within the gcc source directory then it will use those, so you can do something like:
Code: Select all
cd /usr/src
tar zxf gcc-4.3.0.tar.gz
tar zxf mpfr-2.3.1.tar.gz
tar zxf gmp-4.2.2.tar.gz
cd gcc-4.3.0
ln -s ../mpfr-2.3.1 ./mpfr
ln -s ../gmp-4.2.2 ./gmp
cd ..
# the following as per cross compiler article
mkdir build-gcc
cd build-gcc
export PATH=$PATH:$PREFIX/bin
../gcc-4.3.0/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c,c++ --without-headers --with-newlib
make all-gcc
make install-gcc
and it magically compiles gmp and mpfr and uses those instead.
Regards,
John.