GPC cross-compilation error

Waldek Hebisch hebisch at
Sun Apr 29 15:45:55 CEST 2007

Ilya Minkov wrote:
> Hello.
> I'm trying to build a GPC for a deeply embedded non-unixoid platform (sh-elf) 
> and running into an error of this kind:
>  --- 8< ---
> ../../gcc-3.4.6/gcc/p/script/mkdir-p p/rts
> src=`cd ../../gcc-3.4.6/gcc && pwd` && \
> 	cd ./p/rts && \	
> CC="`echo /home/eye/dc/dc-chain/build-gcc-sh-elf-3.4.6/gcc/xgcc -B/home/eye/dc/dc-chain/build-gcc-sh-elf-3.4.6/gcc/ -B/home/eye/dc/sh-elf/sh-elf/bin/ -B/home/eye/dc/sh-elf/sh-elf/lib/ -isystem /home/eye/dc/sh-elf/sh-elf/include -isystem /home/eye/dc/sh-elf/sh-elf/sys-include' ' | 
> sed -e 's,\(-[BI]\)\([^/][^:]\),\1../../\2,g;s,^\([^/][^:]*/\),../../\1,'`" 
> PC="`echo ./xgpc -B./' ' | sed -e 's,\(-[BI]\)\([^/][^:]\),
> \1../../\2,g;s,^\([^/][^:]*/\),../../\1,'`" CONFIG_SITE=nonexisting-file \
> 	$src/p/rts/configure --silent > /dev/null --srcdir=$src/p/rts \
> 	 `if [ x at with_shared@ = xyes ]; then echo '--with-shared'; fi`
> configure: error: installation or configuration problem: C compiler cannot 
> create executables.
> make[2]: *** [p/rts/Makefile] Fehler 1
> make[2]: Verlasse 
> Verzeichnis '/home/eye/dc/dc-chain/build-gcc-sh-elf-3.4.6/gcc'
> make[1]: *** [all-gcc] Fehler 2
> make[1]: Verlasse Verzeichnis '/home/eye/dc/dc-chain/build-gcc-sh-elf-3.4.6'
>  --- >8 ---
> And i believe the error message is quite correct too. The build process is 
> working in the following steps, as far as i understood it. I am not the 
> author of the compilation script, so i'm not quite sure.
> 1. compile a semi-broken C cross-compiler.
> 2. compile newlib (a C standard library) using this compiler.
> 3. throw away the compiler, use something from newlib to reconfigure GCC
> 4. compile the correct cross-compiler for selected languages, namely C, C++, 
> and in my case also Pascal.
> It seems to me that xgcc is the broken compiler from the first step, which is 
> not intended to produce executables, just libraries. Besides, it generates 
> the code for the target system, where a compiler would be plain unable to 
> run. The compilers have to be compiled with ordinary GCC and would run on 
> this computer.

Gpc configure script is generated by autoconf.  AFAICS the error message
comes from standard autoconf check for compilers.  The autoconf checks
are intended to verify that the compiler which is going to compile 
(C part of) gpc runtime works.  The test is if compiler can create
an executable -- there is a separate test which checks is the executable
can run (and if the executable can not run then configure concludes that
we are cross-compiling).
Why gpc build fails and other compilers works:

1) configure tests in other compiler may be tweaked to work around the
2) gpc runtime is build quite early and C compiler may be not ready yet

The second problem is a deep structural one: gpc runtime is build just
after the compiler is build, because the build has to be triggered
from main gcc Makefile but gcc Makefile has hook for starting gpc
build but no separate hook for building runtime.

I did not try to build a newlib based cross-compiler but I have build
a glibc basied ones.  I worked, but glibc for target was installed
before building gcc (so presumably C compier could use startup files
installed together with glibc).  So my hint would be to make sure
that C runtime stuff (crt0 etc...) is installed before gpc build.

                              Waldek Hebisch
hebisch at 

More information about the Gpc mailing list