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

3

5

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... :)

Fotheringhay answered 5/3, 2012 at 21:9 Comment(10)
when you compiled binutils, did you have AS and LD compiled? after compiling binutils did you install it? did you compile gcc after compiling and installing binutils?Mittiemittimus
I just updated the question, it should tell you what you needFotheringhay
you have problem compiling as and ld but you mostly describe how you compile gcc. reedit it and describe only what you do and how you compile binutils.Mittiemittimus
btw. do you have --with-gnu-as and --with-gnu-ld included when building binutils?Mittiemittimus
I just added that, as well as --enable-ld and still no change... still not getting gas or ldFotheringhay
by the way, just added new info... didn't want to rewrite it, just because I thought the more info the better, but I added a section that describes what I did in detailFotheringhay
I sympathize; I tried getting 4.6.3 to build on Mac OS X 10.7.3 this morning, using GCC 4.6.1 that I managed to compile a while ago, and that works fine most of the time - but when run to build GCC, it can't work out how to determine the size of long long. In my case, I think the problem is something to do with the directory gcc being created and then execlp() trying to execute the directory, or maybe cc1 in that directory instead of its configured location; something weird. Good luck...no helpful information here except to reassure you that you are not alone.Beasley
oh man, I have had the same problem, exactly, I compile gcc 4.6.3 alright, but when using it to compile the recent snapshot (4.7.0) it says it can't determine the size of long long... wow. it's nice to know it's not just me.... thanks :)!Fotheringhay
GNU gold is an ELF linker. OS X uses Mach-O, so you should disable gold in the build. It shouldn't be built by default on OS X anyway.Midget
oh, alright, being that mac is a unix derivative, I assumed it used elfFotheringhay
F
0

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

Fotheringhay answered 19/3, 2012 at 21:50 Comment(0)
M
3

Afaik with standard builds (configure;make), the results are named differently. gas-new and gld-new or so.

Note that OS X doesn't normally use binutils but Apple's own Mach-O linker (cctools). Even if you succeeded, it might not lead to a workable solution

Maier answered 6/3, 2012 at 12:27 Comment(0)
P
3

Binutils does not support an assembler or linker on OS X, see the binutils configure script:

case "${target}" in
  *-*-chorusos)
    ;;
  aarch64-*-darwin*)
    noconfigdirs="$noconfigdirs ld gas gdb gprof"
    noconfigdirs="$noconfigdirs sim target-rda"
    ;;
  arm-*-darwin*)
    noconfigdirs="$noconfigdirs ld gas gdb gprof"
    noconfigdirs="$noconfigdirs sim target-rda"
    ;;
  powerpc-*-darwin*)
    noconfigdirs="$noconfigdirs ld gas gdb gprof"
    noconfigdirs="$noconfigdirs sim target-rda"
    ;;
  i[3456789]86-*-darwin*)
    noconfigdirs="$noconfigdirs ld gprof"
    noconfigdirs="$noconfigdirs sim target-rda"
    ;;
  x86_64-*-darwin[912]*)
    noconfigdirs="$noconfigdirs ld gas gprof"
    noconfigdirs="$noconfigdirs sim target-rda"
    ;;
  *-*-darwin*)
    noconfigdirs="$noconfigdirs ld gas gdb gprof"
    noconfigdirs="$noconfigdirs sim target-rda"
    ;;

For any darwin (i.e. OS X) target, this adds ld and gas to the noconfigdirs list. That means those directories will be skipped during the build.

To build GCC on OS X you need to use the native OS X assembler and linker (which are part of the "Xcode Command Line Tools" package, from the App Store).

Pahlavi answered 29/8, 2018 at 14:35 Comment(0)
F
0

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

Fotheringhay answered 19/3, 2012 at 21:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.