1

I am trying to build GCC 4.7.3. When I am building it with pretty old system GCC 4.1 everything is ok and I get GCC 4.7.3. But when I am trying to rebuild it with just compiled GCC 4.7.3 (actually build itself) I get in troubles with AS (GNU assembler). I am going to build it without using old and buggy system compilers. All paths and all libraries are correct (I checked that). I can build all prerequisites.

But when it starts to build libgcc it stucks on detecting C-compiller.

Here is part of config.log with error:

configure:3335: checking for C compiler version
configure:3344: /root/build/tmp/gcc-build/./gcc/xgcc -B/root/build/tmp/gcc-build/./gcc/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/bin/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/lib/ -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/include -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/sys-include    --version >&5
xgcc (GCC) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3355: $? = 0
configure:3344: /root/build/tmp/gcc-build/./gcc/xgcc -B/root/build/tmp/gcc-build/./gcc/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/bin/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/lib/ -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/include -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/sys-include    -v >&5
Reading specs from /root/build/tmp/gcc-build/./gcc/specs
COLLECT_GCC=/root/build/tmp/gcc-build/./gcc/xgcc
COLLECT_LTO_WRAPPER=/root/build/tmp/gcc-build/./gcc/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../../gcc-4.7.3/configure --prefix=/root/build/tmp/gcc --program-suffix=-4.7 --enable-static --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++ --disable-libssp --disable-multilib --disable-bootstrap --disable-lto --disable-tls --disable-nls --with-as=/root/build/gcc/bin/gcc --enable-version-specific-runtime-libs --with-host-libstdcxx=-lstdc++ --with-mpc=/root/build/tmp/mpc --with-mpfr=/root/build/tmp/mpfr --with-gmp=/root/build/tmp/gmp --with-ppl=/root/build/tmp/ppl --with-cloog=/root/build/tmp/cloog-ppl
Thread model: posix
gcc version 4.7.3 (GCC) 
configure:3355: $? = 0
configure:3344: /root/build/tmp/gcc-build/./gcc/xgcc -B/root/build/tmp/gcc-build/./gcc/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/bin/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/lib/ -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/include -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/sys-include    -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3355: $? = 1
configure:3344: /root/build/tmp/gcc-build/./gcc/xgcc -B/root/build/tmp/gcc-build/./gcc/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/bin/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/lib/ -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/include -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/sys-include    -qversion >&5
xgcc: error: unrecognized command line option '-qversion'
xgcc: fatal error: no input files
compilation terminated.
configure:3355: $? = 1
configure:3371: /root/build/tmp/gcc-build/./gcc/xgcc -B/root/build/tmp/gcc-build/./gcc/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/bin/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/lib/ -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/include -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/sys-include    -o conftest -g -O2 -m32 -march=i686 -msse2 -mfpmath=sse   conftest.c  >&5
gcc: error: unrecognized command line option '--32'
configure:3374: $? = 1
configure:3562: checking for suffix of object files
configure:3584: /root/build/tmp/gcc-build/./gcc/xgcc -B/root/build/tmp/gcc-build/./gcc/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/bin/ -B/root/build/tmp/gcc/i686-pc-linux-gnu/lib/ -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/include -isystem /root/build/tmp/gcc/i686-pc-linux-gnu/sys-include    -c -g -O2 -m32 -march=i686 -msse2 -mfpmath=sse  conftest.c >&5
gcc: error: unrecognized command line option '--32'
configure:3588: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3602: error: in `/root/build/tmp/gcc-build/i686-pc-linux-gnu/libgcc':
configure:3605: error: cannot compute suffix of object files: cannot compile

The problem is that xgcc (internally?) calls GCC as assembler with GNU AS flags (--32 for example), but I don't use GNU AS! I have only GCC and going to use its assembler! Is there any configure option or something to force using GCC assembler when it builds libgcc? My GCC configure parameters:

./configure \
  --prefix=$INST_DIR \
  --program-suffix=-4.7 \
  --enable-static \
  --enable-shared \
  --enable-threads=posix \
  --enable-__cxa_atexit \
  --enable-clocale=gnu \
  --enable-languages=c,c++ \
  --disable-libssp \
  --disable-multilib \
  --disable-bootstrap \
  --disable-lto \
  --disable-tls \
  --disable-nls \
  "--with-as=$GCC_DIR/bin/gcc" \
  --enable-version-specific-runtime-libs \
  --with-host-libstdcxx=-lstdc++ \
  "--with-mpc=$MPC_INST_DIR" \
  "--with-mpfr=$MPFR_INST_DIR" \
  "--with-gmp=$GMP_INST_DIR" \
  "--with-ppl=$PPL_INST_DIR" \
  "--with-cloog=$CLOOG_INST_DIR"

As u can see on building GCC itself I force using GCC as assembler by "--with-as=" command. But how can I do that on GCC internal libgcc compiling stage? Or GCC depends on GNU AS assembler?

Note:

xgcc calls 'as' script which calls assembler. In my case 'as' has string: ORIGINAL_AS_FOR_TARGET="/build/gcc/bin/gcc" and supposed to use GCC as assembler. But xgcc calls it with GNU AS-specific parameters.

Sap
  • 914
  • 1
  • 6
  • 20

2 Answers2

1

You very probably have (on Linux) a GNU as assembler installed in /usr/bin/as so you should configure

 "--with-as=/usr/bin/as" 

(Most x86-64 Linux systems I know about have a GNU as - which accepts both 32 and 64 bits directives and instructions).

Also, unless configured with --disable-bootstrap a (non-cross compiler) GCC build is bootstrapped: it is recompiling itself with itself.

BTW, gcc-help@gcc.gnu.org is probably a better place to ask such very GCC specific questions.

At last, GCC 4.9 is being released these days (mid-april 2014). Better compile this version (or at the very least a GCC 4.8.2) instead of an old GCC 4.7.3

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • Sure. But I don't want to use system assembler because it's old and buggy (and doesn't support modern architectures). I need to build GCC with GCC - it doesn't have GNU assembler in prerequisites. – Sap Apr 17 '14 at 11:59
  • Then it seems like a bug - GCC itself can be build without GNU AS (and in my case it's already built when the error comes). But it tries to use AS when build libgcc - what's the reason? – Sap Apr 17 '14 at 12:01
  • I have VERY old kernel and binutils can can't change them. I have some compatibility problems even with GCC 4.7. I afraid GCC 4.9 can not be build on this system. – Sap Apr 17 '14 at 12:04
0

As I found - yes GCC depends on binutils and AS/LD tools. So if you are trying to build modern GCC on very old or broken system you may need to build binutils as well. And there are some non-critical but annoying minor incompatibilities with modern GCC and older binutils. The good news are that GCC can build binutils itself if they are on the top of his source tree - there a lot of examples about that over internet. Or you have to build them manually and setup environment for GCC.

Sap
  • 914
  • 1
  • 6
  • 20