Search code examples
macosgcccompilationldbinutils

Can't seem to get gcc or binutils to build a new linker or assembler


I am trying to set up a completely recent and up to date gcc environment... basically gcc 4.6.3 and binutils 2.22. Not the fairly old gcc 4.2.1 (llvm) that comes with Xcode 4.2.1. My problem is not with compiling (for now, at least). I can compile binutils, gcc, and both at the same time perfectly. However each time I try to compile I find something like this appear at the end of configure's output

checking where to find the target ar... just compiled
checking where to find the target as... host tool
checking where to find the target cc... just compiled
checking where to find the target c++... just compiled
checking where to find the target c++ for libstdc++... just compiled
checking where to find the target dlltool... just compiled
checking where to find the target gcc... just compiled
checking where to find the target gcj... just compiled
checking where to find the target gfortran... just compiled
checking where to find the target gccgo... host tool
checking where to find the target ld... host tool
checking where to find the target lipo... host tool
checking where to find the target nm... just compiled
checking where to find the target objdump... just compiled
checking where to find the target ranlib... just compiled
checking where to find the target strip... just compiled
checking where to find the target windres... just compiled
checking where to find the target windmc... just compiled

I made a symlinks for ld, opcodes, bfd, gas, gprof, and binutils in the gcc source folder to get this output... (if that helps)

As you can see I can get a "just compiled" version of most software, by I just can't figure out how to compile as and ld. I have read the README file in the ld folder (which in the the binutils package) and it says to execute:

make all-ld

I do and being that I already "made" the source, it tells me nothing is left to do...

The only thing I can think of now is to temporally modify my path to not include ld. This would be pretty easy...

aka a quick check with

whereis ld

anyway immediately after thinking of this I relized it would be stupid being now I would have nothing to link gcc (or even a new version of ld (if I got to work at all))

So, in conclusion, I am trying to compile a new copy of ld and as...

The facts:

  • I am running Mac OS X Lion.
  • I am trying to compile gcc 4.6.3 using the default gcc that comes with Mac OS X Lion (gcc 4.2.1).
  • The configure scripts seem to think I do not want to compile a new linker and assembler.
  • I have successfully built a working gcc and binutils but without a new linker and assembler.
  • I have tried to compile binutils and gcc with the --with-ld=yes and --with-gold=no option, they didn't seem to do anything.
  • I built gmp v5.0.4, mpfr v3.1.0, and mpc v0.9 using gcc v4.2.1, installing them in the same prefix as used in the gcc and binutils configure.
  • For each configure I am explicitly stating the locations of gmp, mpfr, and mpc.
  • I built gmp, mpfr, and mpc separately from gcc (doing so, resulted in some build errors).
  • gcc, binutils, gmp, mpfr, and mpc are all build in a separate directory which is not a subdirectory of the source directory (as recommended by the gcc installation instructions).
  • I am compiling gcc with the following options:
    ../gcc-4.6.3/configure --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --enable-checking=release --program-suffix=-4.6.3 --enable-ld=yes --enable-gold=no
  • I mainly followed this tutorial.
  • Because I have no other compiler on my computer I am forced to use the mac os x default llvm compiler (what I described earlier as gcc 4.2.1) which I read here doesn't work, however I don't have gcc-4.2 on my computer.
  • Compiling gcc-4.7.0 (the very recent snapshot) using the new version of gcc I just compiled (gcc-4.6.3) results in compiler errors (I set the environment variables CC and CXX).
  • I have tried compiling gcc first, than binutils, and the other way around, eventually I decided building gcc with binutils was the way to go. The output above you was with both compiled at once
  • I read this little post on gold, and tried adding --enable-gold and --enable-ld. They changed nothing
  • The order in which I did things:
    1. Compile gmp.
    2. Install it.
    3. Compile mpfr.
    4. Install it.
    5. Compile mpc.
    6. Install it.
    7. Make symlinks to the main gcc src directory for ld, gas, binutils, opcodes, gprof, bfd.
    8. Configure gcc.
    9. Find that "status report."
    10. Think of another way to possibly build ld and as.
    11. Fail at that.
    12. Go on Stack Overflow.

as "fazo" said, I am not really telling anyone much about how I compiled binutils... so here it is...

I tried first compiling gcc, than building binutils using gcc, that compiled fine, but no ld, as, or even gold. Then I tried using the llvm compiler to build binutils then gcc. It also worked fine, but still no ld, as, or gold. Finally, I read here that I could make symlinks to some items in binutils and gcc would detect and build them... I did. and gcc found most of them (as stated before I put symlinks in the gcc directory for ld, opcodes, bfd, gas, gprof, and binutils) My actual problem here is telling the configure script to compile a new assembler and linker. Also, what boggles me, is in the binutils README folder it says that a mere ./configure make make install will build and install all the tools, I am trying to figure out why this is not the case.

The final command comes out to be: ../binutils-2.22/configure --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --program-suffix=-4.6.3 --enable-ld --with-gnu-as --with-gnu-ld

yet I still get no ld and no gas.

Any help is greatly appreciated! (also if you want some info I haven't supplied, just ask)

thanks... :)


Solution

  • I realized, that it was basically a mac issue. After installing and getting Ubuntu it built the linker and assembler just fine... still having a bit of trouble compiling gcc, but that is because of Debian's new multi architecture support... but this is another issue... Thanks for your help Marco van de Voort