I want to crosscompile gcc for the sh-elf target. First i compile binutils-2.12 Then i configure and compile gcc (for compiling newlib) with --target=sh-elf --prefix=/usr/local/dc --with-newlib --enable-languages=c then i compile newlib with that gcc. then i reconfigure gcc with --target=sh-elf --prefix=/usr/local/dc --with-newlib --enable-languages=c,c++ when typing 'make all install' after awhile, compiling fails with the following error: /gcc/build-gcc/gcc/xgcc -B/gcc/build-gcc/gcc/ -B/usr/local/dc/sh-elf/sh-elf/bin/ -B/usr/local/dc/sh-elf/sh-elf/lib/ -isystem /usr/local/dc/sh-elf/sh-elf/include -c -DHAVE_CONFIG_H -O2 -g -O2 -I. -I../../../gcc-20030331/libiberty/../include -W -Wall -Wtraditional -pedantic ../../../gcc-20030331/libiberty/hashtab.c -o hashtab.o ../../../gcc-20030331/libiberty/hashtab.c: In function `higher_prime_number': ../../../gcc-20030331/libiberty/hashtab.c:133: Warnung: implicit declaration of function `abort' ../../../gcc-20030331/libiberty/hashtab.c: In function `htab_create': ../../../gcc-20030331/libiberty/hashtab.c:204: error: `free' undeclared (first use in this function) ../../../gcc-20030331/libiberty/hashtab.c:204: error: (Each undeclared identifier is reported only once ../../../gcc-20030331/libiberty/hashtab.c:204: error: for each function it appears in.) ../../../gcc-20030331/libiberty/hashtab.c: In function `htab_try_create': ../../../gcc-20030331/libiberty/hashtab.c:214: error: `calloc' undeclared (first use in this function) ../../../gcc-20030331/libiberty/hashtab.c:214: error: `free' undeclared (first use in this function) make[1]: *** [hashtab.o] Fehler 1 make[1]: Verlassen des Verzeichnisses »/gcc/build-gcc/sh-elf/libiberty« make: *** [all-target-libiberty] Fehler 2 Release: gcc-Version 3.3 20030331 (prerelease) Environment: linux-2.4.20, ia32, gcc configured with --target=$sh-elf --prefix=/usr/local/dc --with-newlib --enable-languages=c How-To-Repeat: binutils-2.12: configure --target=sh-elf --prefix=/usr/local/dc/sh-elf make install export PATH=$PATH:/usr/local/dc/sh-elf/bin gcc-20030331: configure --target=sh-elf --prefix=/usr/local/dc/sh-elf --with-newlib --enable-languages=c make all install newlib-1.10.0: configure --target=sh-elf --prefix=/usr/local/dc/sh-elf make all install gcc-20030331: configure --target=sh-elf --prefix=/usr/local/dc/sh-elf --with-newlib --enable-languages=c,c++ make all install
From: paras.rasmatazz@t-online.de (Christian Herrmann) To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org Cc: Subject: Re: target/10331: [x86 -> SH] can't compile c++ crosscompiler part of gcc crosscompiler for sh-elf Date: Tue, 22 Apr 2003 19:09:56 +0200 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audit-trail&database=3D= gcc&pr=3D10331
From: Dara Hazeghi <dhazeghi@yahoo.com> To: gcc-gnats@gcc.gnu.org, paras.rasmatazz@t-online.de Cc: Subject: Re: target/10331: [x86 -> SH] can't compile c++ crosscompiler part of gcc crosscompiler for sh-elf Date: Sat, 10 May 2003 02:27:29 -0700 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- trail&database=gcc&pr=10331 Hello, could the submitter try passing --with-headers=/where/my/newlib/headers/are to configure, before building gcc (with the appropriate directory), and report on any progress. It looks like your cross-compile build is failing because it can't find the target headers. Dara
State-Changed-From-To: open->feedback State-Changed-Why: See Dara's question.
I can reproduce this here, and I think I understand what's going on. Try this after configuring a cross gcc: egrep "STMP_FIXPROTO =|Don't run fix" */*/build-gcc/gcc/Makefile On architectures I can build, I see e.g. ppc-405-linux/gcc-3.3-glibc-2.2.5/build-gcc/gcc/Makefile:STMP_FIXPROTO = stmp-fixproto ppc-405-linux/gcc-3.3-glibc-2.2.5/build-gcc/gcc/Makefile:# Don't run fixproto ppc-405-linux/gcc-3.3-glibc-2.2.5/build-gcc/gcc/Makefile:STMP_FIXPROTO = On sh4, which fails with the current bug, I see e.g. sh4-linux/gcc-3.3-glibc-2.2.5/build-gcc/gcc/Makefile:STMP_FIXPROTO = stmp-fixproto So, where's that "Don't run fixproto" come from? $ find . -type f | xargs grep " ./gcc/ChangeLog.4: * config/i386/x-beos (STMP_FIXPROTO): Don't run fixproto. ./gcc/config/t-freebsd:# Don't run fixproto ./gcc/config/t-interix:# Don't run fixproto ./gcc/config/t-linux:# Don't run fixproto ./gcc/config/t-linux-aout:# Don't run fixproto ./gcc/config/t-netbsd:# Don't run fixproto ./gcc/config/t-openbsd:# Don't run fixproto ./gcc/config/cris/t-cris:# Don't run fixproto ./gcc/config/i386/t-beos:# Don't run fixproto ./gcc/config/i386/t-cygwin:# Don't run fixproto ./gcc/config/xtensa/t-xtensa:# Don't run fixproto That's as far as I've gotten. I don't really understand the gcc/config files, but it seems this is where the problem may lie.
Created attachment 4170 [details] Patch to prevent running fixprotos No idea if it is really the right thing to do, but it lets me build the toolchain.
OK, learned a little more. It seems that when building a cross-compiler for ppc, the Makefile is assembled from the following fragments: rs6000/t-ppcos t-slibgcc-elf-ver t-linux rs6000/t-ppccomm rs6000/t-rs6000-c-rule whereas when building a cross-compiler for sh4, the list is sh/t-sh sh/t-elf sh/t-linux sh/t-le sh/t-monolib (found by adding set -x to configure, and grepping for dep_tmake_file=). t-linux contains the magic line # Don't run fixproto STMP_FIXPROTO = but sh/t-linux doesn't. Doing the obvious stupid thing -- adding the missing line -- seems to fix the problem. Patch attached. Is this proper?
Kaz said: "Your change seems to be safe and 3.4 already uses gcc/config/t-linux which nullifies STMP_FIXPROTO, so the patch is OK for 3.3 as an regression fix on sh-linux target. Thanks." http://gcc.gnu.org/ml/gcc-patches/2003-06/msg00423.html
Patch committed: http://gcc.gnu.org/ml/gcc-cvs/2003-06/msg00242.html.