3

I've spent quite a few days now trying to cross-compile gcc 4.8.2 so I can use that generated compiler to compile an older version of strace for a big-endian MIPS system, and I've mainly been following this guide: https://comparch-resources.ece.gatech.edu/resources/gcc-mips/gcc-from-source/

Everything in that guide works up to the point of rebuilding gcc with newlib. Upon executing that rebuild command, I get the following error:

checking for mips-linux-gnu-gcc... /opt/cross/gcc-build/./gcc/xgcc -B/opt/cross/gcc-build/./gcc/ -B/opt/cross/gcc-mips/mips-linux-gnu/bin/ -B/opt/cross/gcc-mips/mips-linux-gnu/lib/ -isystem /opt/cross/gcc-mips/mips-linux-gnu/include -isystem /opt/cross/gcc-mips/mips-linux-gnu/sys-include   
checking for suffix of object files... configure: error: in `/opt/cross/gcc-build/mips-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[1]: *** [configure-target-libgcc] Error 1
make[1]: Leaving directory `/opt/cross/gcc-build'
make: *** [all] Error 2

Here is a partial excerpt from /opt/cross/gcc-build/mips-linux-gnu/libgcc/config.log:

Configured with: ../gcc-4.8.2/configure --target=mips-linux-gnu --prefix=/opt/cross/gcc-mips --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --disable-multilib --with-newlib
Thread model: posix
gcc version 4.8.2 (GCC)
configure:3358: $? = 0
configure:3347: /opt/cross/gcc-build/./gcc/xgcc -B/opt/cross/gcc-build/./gcc/ -B/opt/cross/gcc-mips/mips-linux-gnu/bin/ -B/opt/cross/gcc-mips/mips-linux-gnu/lib/ -isystem /opt/cross/gcc-mips/mips-linux-gnu/include -isystem /opt/cross/gcc-mips/mips-linux-gnu/sys-include    -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3358: $? = 1
configure:3347: /opt/cross/gcc-build/./gcc/xgcc -B/opt/cross/gcc-build/./gcc/ -B/opt/cross/gcc-mips/mips-linux-gnu/bin/ -B/opt/cross/gcc-mips/mips-linux-gnu/lib/ -isystem /opt/cross/gcc-mips/mips-linux-gnu/include -isystem /opt/cross/gcc-mips/mips-linux-gnu/sys-include    -qversion >&5
xgcc: error: unrecognized command line option '-qversion'
xgcc: fatal error: no input files
compilation terminated.
configure:3358: $? = 1
configure:3374: /opt/cross/gcc-build/./gcc/xgcc -B/opt/cross/gcc-build/./gcc/ -B/opt/cross/gcc-mips/mips-linux-gnu/bin/ -B/opt/cross/gcc-mips/mips-linux-gnu/lib/ -isystem /opt/cross/gcc-mips/mips-linux-gnu/include -isystem /opt/cross/gcc-mips/mips-linux-gnu/sys-include    -o conftest -g -O2 -Wno-error -minterlink-mips16   conftest.c  >&5
/opt/cross/gcc-build/./gcc/as: 87: exec: -EB: not found
configure:3377: $? = 1
configure:3565: checking for suffix of object files
configure:3587: /opt/cross/gcc-build/./gcc/xgcc -B/opt/cross/gcc-build/./gcc/ -B/opt/cross/gcc-mips/mips-linux-gnu/bin/ -B/opt/cross/gcc-mips/mips-linux-gnu/lib/ -isystem /opt/cross/gcc-mips/mips-linux-gnu/include -isystem /opt/cross/gcc-mips/mips-linux-gnu/sys-include    -c -g -O2 -Wno-error -minterlink-mips16  conftest.c >&5
/opt/cross/gcc-build/./gcc/as: 87: exec: -EB: not found
configure:3591: $? = 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:3605: error: in `/opt/cross/gcc-build/mips-linux-gnu/libgcc':
configure:3608: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.

Opening up /opt/cross/gcc-build/gcc/as, we see that line 87 is exec $original ${1+"$@"}, and since exec is trying to execute -EB as opposed to <correct compiler> -EB, I think that this means $original is blank (i.e. not set) when being called by exec. However, I'm not sure what compiler $original should be set to in order for the configure script to not fail, and I've tried various options such as /opt/cross/gcc-build/./gcc/xgcc that all fail.

While superficially this post seems similar to some other ones from older times, I don't think anyone else ran into this particular obstacle with the exec issue. As such, any help would be greatly appreciated!

  • Stupid question maybe, but have you tried passing "--build and --host" set to your local machine's architecture instead of setting "--target" only? – alagner Aug 09 '21 at 06:42
  • I actually have not. What should I supply into those fields? I'm assuming --host should be like x86_64 or something, but what about --build? Thanks for the quick response! – exclamationmark Aug 09 '21 at 06:45
  • See [this](https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html). But generally host and build should be the same unless you're doing a "Canadian", i.e. building compiler on X (build) to be run on Y (host) and producing binary for Z (target). Usually host==build though. – alagner Aug 09 '21 at 06:50
  • As for the actual setting: most likely it will be amd64-linux-gnu or x86_64-linux-gnu. As Ubuntu is generally Debian-based, [Debian's triplet list](https://wiki.debian.org/Multiarch/Tuples) might be applicable. – alagner Aug 09 '21 at 06:55
  • I'll check out the link, thanks so much for the reference. Hopefully this gets me further in the process but with my luck who knows haha; will report back tomorrow. – exclamationmark Aug 09 '21 at 07:06
  • Hmm so now when I do ```../gcc-4.8.2/configure --target=mips-linux-gnu --prefix=$PREFIX --host=amd64-linux-gnu --build=amd64-linux-gnu --with-newlib --without-headers --with-gnu-as --with-gnu-ld --disable-shared --disable-threads --disable-libssp --enable-languages=c``` I get an error saying `crt1.o, -lc, crti.o` are not found. I think this is because of sysroot issues, but when I set my sysroot via `CFLAGS` I think this leads to "configure: error: C compiler cannot create executables." – exclamationmark Aug 09 '21 at 07:37
  • See https://stackoverflow.com/q/6329887/1216776 for a variety of possibilities – stark Aug 09 '21 at 10:55

0 Answers0