building llvm-gcc on Ubuntu 11.04 Natty Narwhal

Hi,

I'm trying to build llvm-gcc-4.2 on Ubuntu 11.04 (the Natty Narwhal).
The "make" fails here, trying to build libgcc:

/home/jay/llvm/gitobjdir-gcc/./gcc/xgcc
-B/home/jay/llvm/gitobjdir-gcc/./gcc/
-B/home/jay/llvm/local/x86_64-unknown-linux-gnu/bin/
-B/home/jay/llvm/local/x86_64-unknown-linux-gnu/lib/ -isystem
/home/jay/llvm/local/x86_64-unknown-linux-gnu/include -isystem
/home/jay/llvm/local/x86_64-unknown-linux-gnu/sys-include -O2 -O2 -g
-O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC
-g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -shared
-nodefaultlibs -Wl,--soname=libgcc_s.so.1
-Wl,--version-script=libgcc/./libgcc.map -o ./libgcc_s.so.1.tmp
libgcc/./_muldi3_s.o libgcc/./_negdi2_s.o libgcc/./_lshrdi3_s.o
libgcc/./_ashldi3_s.o libgcc/./_ashrdi3_s.o libgcc/./_cmpdi2_s.o
libgcc/./_ucmpdi2_s.o libgcc/./_clear_cache_s.o
libgcc/./_enable_execute_stack_s.o libgcc/./_trampoline_s.o
libgcc/./__main_s.o libgcc/./_absvsi2_s.o libgcc/./_absvdi2_s.o
libgcc/./_addvsi3_s.o libgcc/./_addvdi3_s.o libgcc/./_subvsi3_s.o
libgcc/./_subvdi3_s.o libgcc/./_mulvsi3_s.o libgcc/./_mulvdi3_s.o
libgcc/./_negvsi2_s.o libgcc/./_negvdi2_s.o libgcc/./_ctors_s.o
libgcc/./_ffssi2_s.o libgcc/./_ffsdi2_s.o libgcc/./_clz_s.o
libgcc/./_clzsi2_s.o libgcc/./_clzdi2_s.o libgcc/./_ctzsi2_s.o
libgcc/./_ctzdi2_s.o libgcc/./_popcount_tab_s.o
libgcc/./_popcountsi2_s.o libgcc/./_popcountdi2_s.o
libgcc/./_paritysi2_s.o libgcc/./_paritydi2_s.o libgcc/./_powisf2_s.o
libgcc/./_powidf2_s.o libgcc/./_powixf2_s.o libgcc/./_powitf2_s.o
libgcc/./_mulsc3_s.o libgcc/./_muldc3_s.o libgcc/./_mulxc3_s.o
libgcc/./_multc3_s.o libgcc/./_divsc3_s.o libgcc/./_divdc3_s.o
libgcc/./_divxc3_s.o libgcc/./_divtc3_s.o libgcc/./_bswapsi2_s.o
libgcc/./_bswapdi2_s.o libgcc/./_fixunssfsi_s.o
libgcc/./_fixunsdfsi_s.o libgcc/./_fixunsxfsi_s.o
libgcc/./_fixsfdi_s.o libgcc/./_fixunssfdi_s.o libgcc/./_floatdisf_s.o
libgcc/./_floatundisf_s.o libgcc/./_fixdfdi_s.o
libgcc/./_fixunsdfdi_s.o libgcc/./_floatdidf_s.o
libgcc/./_floatundidf_s.o libgcc/./_fixxfdi_s.o
libgcc/./_fixunsxfdi_s.o libgcc/./_floatdixf_s.o
libgcc/./_floatundixf_s.o libgcc/./_fixtfdi_s.o
libgcc/./_fixunstfdi_s.o libgcc/./_floatditf_s.o
libgcc/./_floatunditf_s.o libgcc/./_divdi3_s.o libgcc/./_moddi3_s.o
libgcc/./_udivdi3_s.o libgcc/./_umoddi3_s.o libgcc/./_udiv_w_sdiv_s.o
libgcc/./_udivmoddi4_s.o libgcc/./unwind-dw2_s.o
libgcc/./unwind-dw2-fde-glibc_s.o libgcc/./unwind-sjlj_s.o
libgcc/./gthr-gnat_s.o libgcc/./unwind-c_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
/usr/bin/ld: warning: wildcard match appears in both version 'GCC_3.0'
and 'GCC_4.3.0' in script
/usr/bin/ld: error: cannot find -lc
collect2: ld returned 1 exit status
make[1]: *** [libgcc_s.so] Error 1
make[1]: Leaving directory `/home/jay/llvm/gitobjdir-gcc/gcc'

If I repeat this command with -v I can see that it runs collect2 like this:

/home/jay/llvm/gitobjdir-gcc/./gcc/collect2 --eh-frame-hdr -m
elf_x86_64 -shared -o ./libgcc_s.so.1.tmp /usr/lib/../lib64/crti.o
/home/jay/llvm/gitobjdir-gcc/./gcc/crtbeginS.o
-L/home/jay/llvm/gitobjdir-gcc/./gcc
-L/home/jay/llvm/local/lib/gcc/x86_64-unknown-linux-gnu/4.2.1
-L/home/jay/llvm/local/lib/gcc/x86_64-unknown-linux-gnu/4.2.1/../../../../lib64
-L/lib/../lib64 -L/usr/lib/../lib64
-L/home/jay/llvm/local/lib/gcc/x86_64-unknown-linux-gnu/4.2.1/../../..
--soname=libgcc_s.so.1 --version-script=libgcc/./libgcc.map
libgcc/./_muldi3_s.o libgcc/./_negdi2_s.o libgcc/./_lshrdi3_s.o
libgcc/./_ashldi3_s.o libgcc/./_ashrdi3_s.o libgcc/./_cmpdi2_s.o
libgcc/./_ucmpdi2_s.o libgcc/./_clear_cache_s.o
libgcc/./_enable_execute_stack_s.o libgcc/./_trampoline_s.o
libgcc/./__main_s.o libgcc/./_absvsi2_s.o libgcc/./_absvdi2_s.o
libgcc/./_addvsi3_s.o libgcc/./_addvdi3_s.o libgcc/./_subvsi3_s.o
libgcc/./_subvdi3_s.o libgcc/./_mulvsi3_s.o libgcc/./_mulvdi3_s.o
libgcc/./_negvsi2_s.o libgcc/./_negvdi2_s.o libgcc/./_ctors_s.o
libgcc/./_ffssi2_s.o libgcc/./_ffsdi2_s.o libgcc/./_clz_s.o
libgcc/./_clzsi2_s.o libgcc/./_clzdi2_s.o libgcc/./_ctzsi2_s.o
libgcc/./_ctzdi2_s.o libgcc/./_popcount_tab_s.o
libgcc/./_popcountsi2_s.o libgcc/./_popcountdi2_s.o
libgcc/./_paritysi2_s.o libgcc/./_paritydi2_s.o libgcc/./_powisf2_s.o
libgcc/./_powidf2_s.o libgcc/./_powixf2_s.o libgcc/./_powitf2_s.o
libgcc/./_mulsc3_s.o libgcc/./_muldc3_s.o libgcc/./_mulxc3_s.o
libgcc/./_multc3_s.o libgcc/./_divsc3_s.o libgcc/./_divdc3_s.o
libgcc/./_divxc3_s.o libgcc/./_divtc3_s.o libgcc/./_bswapsi2_s.o
libgcc/./_bswapdi2_s.o libgcc/./_fixunssfsi_s.o
libgcc/./_fixunsdfsi_s.o libgcc/./_fixunsxfsi_s.o
libgcc/./_fixsfdi_s.o libgcc/./_fixunssfdi_s.o libgcc/./_floatdisf_s.o
libgcc/./_floatundisf_s.o libgcc/./_fixdfdi_s.o
libgcc/./_fixunsdfdi_s.o libgcc/./_floatdidf_s.o
libgcc/./_floatundidf_s.o libgcc/./_fixxfdi_s.o
libgcc/./_fixunsxfdi_s.o libgcc/./_floatdixf_s.o
libgcc/./_floatundixf_s.o libgcc/./_fixtfdi_s.o
libgcc/./_fixunstfdi_s.o libgcc/./_floatditf_s.o
libgcc/./_floatunditf_s.o libgcc/./_divdi3_s.o libgcc/./_moddi3_s.o
libgcc/./_udivdi3_s.o libgcc/./_umoddi3_s.o libgcc/./_udiv_w_sdiv_s.o
libgcc/./_udivmoddi4_s.o libgcc/./unwind-dw2_s.o
libgcc/./unwind-dw2-fde-glibc_s.o libgcc/./unwind-sjlj_s.o
libgcc/./gthr-gnat_s.o libgcc/./unwind-c_s.o -lc
/home/jay/llvm/gitobjdir-gcc/./gcc/crtendS.o /usr/lib/../lib64/crtn.o
/usr/bin/ld: warning: wildcard match appears in both version 'GCC_3.0'
and 'GCC_4.3.0' in script
/usr/bin/ld: error: cannot find -lc
collect2: ld returned 1 exit status

The problem seems to be that it's looking for libc in /lib64 and
/usr/lib64, but on my system it's in /lib/x86_64-linux-gnu (with
/lib64 a symlink to /lib).

Anyone know what to do about this?

I found:

https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/738098

which is supposedly fixed in binutils .2.21.0.20110322-1ubuntu2. But
I've got a slightly later binutils than that, and I'm still having
this problem.

Thanks,
Jay.

Hi Jay,

I'm trying to build llvm-gcc-4.2 on Ubuntu 11.04 (the Natty Narwhal).

I can build it here on x86-64 natty without any problems.

Ciao, Duncan.

I'm trying to build llvm-gcc-4.2 on Ubuntu 11.04 (the Natty Narwhal).

I can build it here on x86-64 natty without any problems.

Do you have any /lib64/libc.so* or /usr/lib64/libc.so* ?

Are you still setting LIBRARY_PATH or LD_LIBRARY_PATH, as mentioned in:

https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/738098

?

Thanks,
Jay.

Hi Jay,

I'm trying to build llvm-gcc-4.2 on Ubuntu 11.04 (the Natty Narwhal).

I can build it here on x86-64 natty without any problems.

Do you have any /lib64/libc.so* or /usr/lib64/libc.so* ?

no.

Are you still setting LIBRARY_PATH or LD_LIBRARY_PATH, as mentioned in:

https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/738098

Indeed I'd forgotten about this: I have LIBRARY_PATH set to
/usr/lib/x86_64-linux-gnu/

If I unset LIBRARY_PATH then llvm-gcc-4.2 still builds.

Ciao, Duncan.

Duncan,

Can you try another experiment please? I get:

$ ls -l `which ld`
lrwxrwxrwx 1 root root 7 2011-05-06 19:26 /usr/bin/ld -> ld.gold
$ ld.gold -lc
ld.gold: error: cannot find -lc
$ ld.bfd -lc
ld.bfd: warning: cannot find entry symbol _start; not setting start address

What do you get?

Thanks!
Jay.

Hi Jay,

Can you try another experiment please? I get:

I wasn't using the gold linker. However if I do (built today) then I get the
following:

$ ls -l `which ld`
lrwxrwxrwx 1 root root 7 2011-05-06 19:26 /usr/bin/ld -> ld.gold

$ ls -l `which ld`
-rwxr-xr-x 4 duncan duncan 47105033 2011-05-10 10:20 /usr/local/bin/ld

$ ld.gold -lc
ld.gold: error: cannot find -lc

$ /usr/local/bin/ld -lc
/usr/local/bin/ld: error: cannot find -lc

$ ld.bfd -lc
ld.bfd: warning: cannot find entry symbol _start; not setting start address

$ /usr/bin/ld -lc
/usr/bin/ld: warning: cannot find entry symbol _start; not setting start address

What do you get?

The llvm-gcc build fails with:

/usr/local/bin/ld: warning: wildcard match appears in both version 'GCC_3.0' and 'GCC_4.3.0' in script
/usr/local/bin/ld: error: cannot find -lc

This can be worked around using LIBRARY_PATH.

Ciao, Duncan.

I wasn't using the gold linker.

OK, that explains the difference. I installed package binutils-gold ages ago.

I've reported this as a bug against ld.gold here:

https://bugs.launchpad.net/bugs/780455

This can be worked around using LIBRARY_PATH.

Yes, this works for me too -- thanks!

Jay.