Can't build gcc anymore since upgrade to 11.10
Solution 1
Apply this patch, and configure with --enable-multiarch (not to be confused with multilib):
(That supersedes this earlier patch.)
Solution 2
Some more material at:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644986
Rather than using the whole script, the key part seems to be:
make FLAGS_FOR_TARGET="-B/usr/lib/i386-linux-gnu -I/usr/include/i386-linux-gnu"
The result is not entirely clean because it still needs a wrapper script after installation to execute with the right additional options. For example here is the example from the article /usr/bin/gcc-4.7 :
#!/bin/sh
exec /opt/gcc-4.7/bin/gcc-4.7 -B/usr/lib/i386-linux-gnu -I/usr/include/i386-linux-gnu "$@"
Solution 3
Ubuntu 11.10 brings multi-arch support which means that you shouldn't put library files in /usr/lib
but /usr/lib/i386-linux-gnu
(32-bit) or /usr/lib/x86_64-linux-gnu
(64-bit).
Use something like:
CFLAGS=-I/usr/include/i386-linux-gnu ./configure [options]
You probably need to specify LDFLAGS=-L/usr/lib/i386-linux-gnu
too.
Aside: your paths do not look pretty: /usr/i686-pc-linux-gnu/lib/
, you might want to use options like --libdir
to correct it.
Solution 4
Since your building from SVN, are you sure your building from the same revision? AKA, make sure the issue isn't upstream :-)
Related videos on Youtube
Raphael R.
Updated on September 18, 2022Comments
-
Raphael R. almost 2 years
On Monday I've upgraded to from Ubuntu 11.04 (my initial installation) to 11.10 and now I can't build gcc from source anymore. Since I forgot to uninstall the gcc package before the upgrade, Ubuntu replaced my 4.7.0 compiler with it's stable 4.6.1. So I tried to build the SVN sources again, but it fails. I've most recently tried it with SVN revision 180193.
After some time, the build fails with the following message:
/home/raphael/devel/gcc/build/./gcc/xgcc -B/home/raphael/devel/gcc/build/./gcc/ -B/usr/i686-pc-linux-gnu/bin/ -B/usr/i686-pc-linux-gnu/lib/ -isystem /usr/i686-pc-linux-gnu/include -isystem /usr/i686-pc-linux-gnu/sys-include -g -O2 -O2 -I. -I. -I../../src/gcc -I../../src/gcc/. -I../../src/gcc/../include -I../../src/gcc/../libdecnumber -I../../src/gcc/../libdecnumber/bid -I../libdecnumber -I../../src/gcc/../libgcc -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 -fbuilding-libgcc -fno-stack-protector -I. -I. -I../.././gcc -I../../../src/libgcc -I../../../src/libgcc/. -I../../../src/libgcc/../gcc -I../../../src/libgcc/../include -I../../../src/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o _ashldi3.o -MT _ashldi3.o -MD -MP -MF _ashldi3.dep -DL_ashldi3 -c ../../../src/libgcc/../gcc/libgcc2.c \ -fvisibility=hidden -DHIDE_EXPORTS In file included from /usr/include/stdio.h:28:0, from ../../../src/libgcc/../gcc/tsystem.h:88, from ../../../src/libgcc/../gcc/libgcc2.c:29: /usr/include/features.h:323:26: fatal error: bits/predefs.h: File or directory not found.
I've cofigured it with:
~/devel/gcc/build$ ../src/configure --prefix=/usr --enable-languages=c++
And make it with:
~/devel/gcc/build$ make -j4
Just to be sure, I did a
rm -rf *
in the build directory in case there's some broken stuff inside. Didn't help, though.
That's the backstory. I tried to fix it and searched for the
bits/predefs.h
. It's inside/usr/include/i386-linux-gnu
. I temporarily fixed the problem by doing~/devel/gcc/build$ C_INCLUDE_PATH=/usr/include/i386-linux-gnu make -j4
Which is only temporary because now gcc complains that it can't find
crti.o
.Which i can find in
/usr/lib/i386-linux-gnu
.Now i could also set- actually it doesn't work - but I feel like I'm fighting the system here. Also, even if it succeeds, my newly built compiler would also not know about theC_LIBRARY_PATH
i386-linux-gnu
stuff. So I would have to setC_LIBRARY_PATH
andC_INCLUDE_PATH
before every build of every project I have. I could add it to my .bashrc but that subverts the system even more.So, how do I tell the build process:
- That there are additional include/lib directories, and
- That it should build a gcc which respects them too?
Edit: I forgot to include the command which causes the above error message. Also I can think of another solution: Copy the stuff from
/usr/include/i386-linux-gnu
to/usr/include
(same thing for/usr/lib/i386-linux-gnu
to/usr/lib
). But that doesn't feel right, either. Finally, the system's gcc 4.6.1 can compile other applications just fine, except mine, which use C++11 features not present in the 4.6 series.-
Admin over 12 years+1: I can't compile gcc trunk with the error-msg: /usr/bin/ld: cannot find crti.o: No such file or directory. Figuring out the correct configure-command is particularly painful, since it takes 20 minutes before the compile breaks.
-
jrg over 12 yearsIt was actually added in 11.04, but 11.10 was when things were complete.
-
Raphael R. over 12 yearsHmmm. The CFLAGS work, but if I set LDFLAGS it still can't find the crti.o . Also, the LDFLAGS don't appear in the command which links the libgcc_s.so . Then I added the -L/usr/lib/i386-linux-gnu to the CFLAGS. Now it appears in the command, but it STILL can't find it. I double-checked the path. It looks like gcc doesn't look at the -L paths when searching for .o files.
-
Lekensteyn over 12 yearsThen I'm out of ideas. Perhaps it's the scripts used for building
gcc
on Ubuntu show what you need (apt-get source --diff-only gcc
, then runtar xf ...
if it's a tarball andpatch -p0 < ...
if it's a diff file) -
mirk over 12 yearsWe are most likely not building from the same revision. We are unable to figure out reasonable ./configure command-options to complete a build with the new multiarch layout of Debian/Ubuntu.
-
ams over 12 yearsAnd, if you don't like patching your sources, and setting flags aren't working for you, just soft-link crt*.o into the /usr/lib dirctory (you'll find them in either /usr/lib/i386-linux-gnu or /usr/lib/x86_64-linux-gnu).
-
Raphael R. over 12 yearsI'm using Debian now so I can't check whether it works, but it looks OK so I'll accept it.