That's not much information, but I would guess that you are on a 64-bit
x86_64 system and that this is happening when building the 32-bit
version of libgcc_s.so and that you don't have the 32-bit libc
installed. If that is the problem, then the fix would be to either
install the 32-bit development libraries or to use --disable-multilib
when you run configure.
Ian
mkdir objdir cd objdir ../gccgo/configure --enable-languages=c,c++,go --with-ld=/opt/gold/bin/ld make
What OS?
Show 10 or 20 lines of make output before and after the error.
Ian
> OS is Ubuntu 11.04
> /opt/gold/bin/ld: cannot find -lc
Do you have the file /usr/lib/libc.so? It normally comes from the
libc6-dev package (sudo apt-get install libc6-dev).
Ian
> Yes, and apt-get reports "libc6-dev is already the newest version".
Does this work?
echo 'int main() { return 0; }' > foo.c
gcc -o foo foo.c -B /opt/gold/bin
If that works, tell us the output of this:
gcc -o foo foo.c -B /opt/gold/bin -Wl,-t
If that does not work, why can't gold find libc? How did you build
gold?
Ian
Hmmm, OK, that found libc.so via paths passed in from the gcc driver, so
that doesn't tell us much.
Did you build gold yourself? How did you configure it?
What is the output of
strings /opt/gold/bin/ld | grep /usr/lib
?
Ian
cvs -z 9 -d :pserver:ano...@sourceware.org:/cvs/src login [password is "anoncvs"] cvs -z 9 -d :pserver:ano...@sourceware.org:/cvs/src co binutils mkdir binutils-objdir cd binutils-objdir ../src/configure --enable-gold --prefix=/opt/gold make make install
> I built gold with the command on the website.
>
> cvs -z 9 -d :pserver:ano...@sourceware.org:/cvs/src login
> [password is "anoncvs"]
> cvs -z 9 -d :pserver:ano...@sourceware.org:/cvs/src co binutils
> mkdir binutils-objdir
> cd binutils-objdir
> ../src/configure --enable-gold --prefix=/opt/gold
> make
> make install
>
>
>
> strings /opt/gold/bin/ld | grep /usr/lib
> SEARCH_DIR("/opt/gold/x86_64-unknown-linux-gnu/lib64");
> SEARCH_DIR("/opt/gold/lib64"); SEARCH_DIR("/usr/local/lib64");
That's not gold. I don't know what went wrong, because your configure
script should have built gold, but that is GNU ld.
Ian
When I built binutils following the gccgo instructions I ended up with
ld, ld.bfd and ld.gold in my bin directory ...
ld and ld.bfd were hard links to the same binary.
jp3@wraith: bin>ls -li ld*
168185 -rwxr-xr-x 4 jp3 jp3 6597015 Sep 1 15:38 ld
168185 -rwxr-xr-x 4 jp3 jp3 6597015 Sep 1 15:38 ld.bfd
167607 -rwxr-xr-x 2 jp3 jp3 49445141 Sep 1 15:38 ld.gold
jp3@wraith: bin>./ld --version
GNU ld (GNU Binutils) 2.21.53.20110902
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms
of
the GNU General Public License version 3 or (at your option) a later
version.
This program has absolutely no warranty.
jp3@wraith: bin>./ld.gold --version
GNU gold (GNU Binutils 2.21.53.20110902) 1.11
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms
of
the GNU General Public License version 3 or (at your option) a later
version.
This program has absolutely no warranty.
When I build gccgo I pointed it at ld.gold ...
--
Julian
> When I built binutils following the gccgo instructions I ended up with
> ld, ld.bfd and ld.gold in my bin directory ...
> ld and ld.bfd were hard links to the same binary.
Hmmmm, looks like --enable-gold has changed so that it just installs
gold as ld.gold. You now need to use --enable-gold=default to get it to
be installed as ld. I will update the Go docs accordingly.
Ian
>script should have built gold, but that is GNU ld.
> opt/gold/bin/ld: error: cannot find -lc
> collect2: error: ld returned 1 exit status
> make[3]: *** [libgcc_s.so] Error 1
I have to admit that I am stumped by this. I cannot recall seeing any
similar report on a system where the file /usr/lib/libc.so exists.
There is probably a simple explanation but without being able to see
your system I don't know what it could be.
Can you send the contents of /usr/lib/libc.so? It should be a short
text file.
From a previous e-mail, the command which failed was:
/home/rhancock/objdir/./gcc/xgcc -B/home/rhancock/objdir/./gcc/ -B/usr/local/x86_64-unknown-linux-gnu/bin/ -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-include -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -fno-stack-protector -shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1 -Wl,--version-script=libgcc.map -o ./libgcc_s.so.1.tmp -g -O2 -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _enable_execute_stack_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _bswapsi2_s.o _bswapdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o _moddi3_s.o _udivdi3_s.o _umoddi3_s.o _udiv_w_sdiv_s.o _udivmoddi4_s.o addtf3_s.o divtf3_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o trunctfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o getf2_s.o letf2_s.o eqtf2_s.o _divtc3_s.o _multc3_s.o _powitf2_s.o unwind-dw2_s.o unwind-dw2-fde-glibc_s.o unwind-sjlj_s.o gthr-gnat_s.o unwind-c_s.o emutls_s.o -lc && rm -f ./libgcc_s.so && if [ -f ./libgcc_s.so.1 ]; then mv -f ./libgcc_s.so.1 ./libgcc_s.so.1.backup; else true; fi && mv ./libgcc_s.so.1.tmp ./libgcc_s.so.1 && ln -s libgcc_s.so.1 ./libgcc_s.so
run in the directory
/home/rhancock/objdir/x86_64-unknown-linux-gnu/libgcc
Please try running that some command with the additional option
-Wl,--verbose,-t
and send the output.
Ian
ron
> strace has belped
This reminds me of our old PROM burner that turned on way day and displayed:
RELF TEST PASSED
-rob
> sudo find / -name libc.so
> [sudo] password for rhancock:
> /usr/lib32/libc.so
> /usr/lib/x86_64-linux-gnu/libc.so
>
> Nothing in /usr/lib. Do I need to make a link?
Argh, this is because Debian or Ubuntu has decided to change the
standard library locations and gcc has not caught up. Their version of
gcc presumably has the necessary patches.
I'm not entirely sure, but I suspect this is the patch:
http://patch-tracker.debian.org/patch/series/view/gcc-4.6/4.6.1-4/gcc-multiarch-trunk.diff
Or, as you say, add a symlink from the files in
/usr/lib/x86_64-linux-gnu to /usr/lib.
Ian
> I then created a symlink.
> cd /usr/lib/x86_64-linux-gnu
> ln -s libc.so /usr/lib/libc.so.6
It needs to be named /usr/lib/libc.so, not /usr/lib/libc.so.6. For
libc, the trailing .6 implies a shared library, a large binary file.
The plain libc.so is a small text file.
> Is it looking for another libgcc_s.so?
It's looking for libc.so. It's trying to build a new libgcc_s.so in
your working directory.
Another gcc patch that is said to fix this problem is
http://gcc.gnu.org/ml/gcc-patches/2011-08/msg01649.html .
Ian
>It needs to be named /usr/lib/libc.so, not /usr/lib/libc.so.6. For
l>ibc, the trailing .6 implies a shared library, a large binary file.
>The plain libc.so is a small text file.
cd /usr/lib/x86_64-linux-gnu
ln -s libc.so /usr/lib/libc.so
And the result during make is:
/opt/gold/bin/ld: error: cannot open /usr/lib/../lib64/libc.so: Too many levels of symbolic links
collect2: error: ld returned 1 exit status
> The error with the symlink states: /opt/gold/bin/ld: error: cannot open
> /usr/lib/../lib64/libc.so: Too many levels of symbolic links
> but there is no lib64 under /usr/lib. Is it looking for another path other
> than /usr/lib/libc.so?
Note the /../. Is there is a /usr/lib64/libc.so?
I'm sorry for all this trouble. It is quite annoying that Debian chose
to make this unilateral change to library locations that had worked fine
for everybody for many years.
Ian
From your earlier report it sounds like gcc is looking for
/usr/lib64/libc.so as well. Perhaps there should be a symlink in /usr
from lib64 -> x86_64-linux-gnu.
Ian
Most likely you need to set up a symlink for libpthread.so just as you
did for libc.so. libpthread.so should also be a small text file. You
may also need one for libdl.so; libdl.so is a binary, not a text file.
Ian
> -lmpc -lmpfr -lgmp -rdynamic -ldl -L../zlib -lz
> /opt/gold/bin/ld: error: cannot find -lmpc
Current gcc requires some additional libraries: mpc, mpfr, and gmp. It
looks like you have mpfr and gmp. You also need mpc. It may be in the
libmpc-dev package. Then you may need symlinks for those three
libraries, or you may not, I don't know. The linker didn't complain
about missing -lmpfr or -lgmp, so you may not need symlinks for those.
In any case, that should be all you need, I hope.
Ian
> Eureka! The build completed and installed. I'm going to try to duplicate
> the process on another machine tomorrow, and I will post the results.
Cool!
> Last question, when specifying LD_LIBRARY_PATH does MACHINE a string like "amd64"?
> To what does VERSION refer?
MACHINE is something like x86_64-unknown-linux-gnu. VERSION is the
version of gcc, something like 4.7.0.
To put it another way, MACHINE is what gcc (or gccgo) -v prints after
"Target:". VERSION is what it prints immediately after "version".
Ian
> sysinfo.o:/home/rhancock/binutils-objdir/binutils/sysinfo.y:409: first
> defined here sysinfo.o: In function `yyparse': sysinfo.c:(.text+0x3e9):
> undefined reference to `yylex' collect2: ld returned 1 exit status make[2]:
> *** [sysinfo] Error 1 make[2]: Leaving directory
I think this error normally means that you need to install the flex
package, and then start over with a fresh directory.
Ian