compiling native GCC for arm using cross-compiler

2019-05-07 10:50发布

问题:

I am looking to create a native build of GCC for an ARM system and I am running into some trouble. The build machine is i686-linux. Every tutorial I see tells me how to set up the actual cross compiling suite (which I have already done using crosstools-ng). However, I don't see anything related to compiling native ARM GCC. The configure string I used is below, I have set up the sysroot only with headers. I have also cross-compiled and installed GMP and MPFR.

../../gcc-4.3.5/configure \
    --host=arm-unknown-linux-gnueabi \
    --build=i686-build_pc-linux-gnu \
    --target=arm-unknown-linux-gnueabi \
    --prefix=/home/vm/gcc-native/sysroot \
    --with-sysroot=/home/vm/gcc-native/sysroot \
    --enable-shared --enable-threads --disable-libmudflap --disable-libssp \
    --disable-libgomp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld \
    --enable-languages=c,c++ --enable-symvers=gnu --enable-__cxa_atexit \
    --disable-nls --disable-multilib \
    --with-gmp=/home/vm/gcc-native/sysroot/ \
    --with-mpfr=/home/vm/gcc-native/sysroot/

GCC will build for a while but then dies with this:

checking for suffix of object files... configure: error: cannot compute suffix of object files: cannot compile.

I am not sure how this would even run on my system as I am building on i686-linux and the target/host are both arm-linux. My thought right now is to find a ltib distro and looking at a spec file for GCC and trying to follow all of the steps. The GCC that ltib shipped with for my board fails to compile on my system due to conflicts with the std namespace.

Any info/links would be appreciated!

回答1:

Look in the config.log file (maybe not the top-level one) and see what it was trying to do when the test failed. Just grep for the cannot compute suffix message and you should find the right bit (it won't be at the end of the file).

Note that you'll need a working arm-unknown-linux-gnueabi-gcc on your path somewhere if you want to build a cross-native toolchain. I.e. you need a cross compiler to build cross-native compiler.