Bug 10331 - [x86 -> SH] can't compile c++ crosscompiler part of gcc crosscompiler for sh-elf
Summary: [x86 -> SH] can't compile c++ crosscompiler part of gcc crosscompiler for sh-elf
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-07 10:26 UTC by paras.rasmatazz
Modified: 2003-07-25 23:17 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Patch to prevent running fixprotos (194 bytes, patch)
2003-06-04 21:45 UTC, Dan Kegel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description paras.rasmatazz 2003-04-07 10:26:03 UTC
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
Comment 1 paras.rasmatazz 2003-04-22 19:09:56 UTC
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

Comment 2 Dara Hazeghi 2003-05-10 02:27:29 UTC
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
 
Comment 3 Giovanni Bajo 2003-05-12 11:37:36 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: See Dara's question.
Comment 4 dank 2003-06-04 16:32:16 UTC
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.

Comment 5 Dan Kegel 2003-06-04 21:45:04 UTC
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.
Comment 6 Dan Kegel 2003-06-04 21:46:13 UTC
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?
Comment 7 dank 2003-06-05 14:26:24 UTC
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
Comment 8 Dara Hazeghi 2003-06-08 02:38:00 UTC
Patch committed: http://gcc.gnu.org/ml/gcc-cvs/2003-06/msg00242.html.