Build of a m68k-cross compiler fails with the following error: G_H -O2 -g -O2 -I. -I../../../gcc/libiberty/../include -W -Wall -Wtraditional -pedantic ../../../gcc/libiberty/hashtab.c -o hashtab.o ../../../gcc/libiberty/hashtab.c: In function `higher_prime_number': ../../../gcc/libiberty/hashtab.c:133: warning: implicit declaration of function `abort' ../../../gcc/libiberty/hashtab.c: In function `htab_create': ../../../gcc/libiberty/hashtab.c:204: error: `free' undeclared (first use in this function) ../../../gcc/libiberty/hashtab.c:204: error: (Each undeclared identifier is reported only once ../../../gcc/libiberty/hashtab.c:204: error: for each function it appears in.) ../../../gcc/libiberty/hashtab.c: In function `htab_try_create': ../../../gcc/libiberty/hashtab.c:214: error: `calloc' undeclared (first use in this function) ../../../gcc/libiberty/hashtab.c:214: error: `free' undeclared (first use in this function) make[1]: *** [hashtab.o] Error 1 make[1]: Leaving directory `/home/rrude/src/gnu/build-m68k-gcc/m68k-elf/libiberty' make: *** [all-target-libiberty] Error 2 This failure is also present in GCC 3.3: http://gcc.gnu.org/ml/gcc/2003-05/msg01930.html native gcc -v: Reading specs from /home/rrude/tools/native/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs Configured with: ../gcc/configure --verbose --prefix=/home/rrude/tools/native --enable-languages=c,c++,ada,java Thread model: posix gcc version 3.3 20030407 (prerelease) This trivial patch addresses the problem: -- snip diff -Nwupr gcc-20030407/libiberty/hashtab.c /home/rrude/src/gnu/gcc-20030407/libiberty/hashtab.c --- gcc-20030407/libiberty/hashtab.c 2003-01-20 11:41:47.000000000 -0700 +++ /home/rrude/src/gnu/gcc-20030407/libiberty/hashtab.c 2003-04-07 16:21:51.000000000 -0600 @@ -46,6 +46,7 @@ Boston, MA 02111-1307, USA. */ #endif #include <stdio.h> +#include <malloc.h> #include "libiberty.h" #include "hashtab.h" -- snip This patch was submitted to gcc-patches: http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00726.html and a better solution was requested. It's unlikely I will be able to supply the requested changes anytime soon.
Created attachment 4062 [details] Copy of the initial bug report. The initial report in bugzilla appears unreadable.
From the attachment: Build of a m68k-cross compiler fails with the following error: G_H -O2 -g -O2 -I. -I../../../gcc/libiberty/../include -W -Wall -Wtraditional -pedantic ../../../gcc/libiberty/hashtab.c -o hashtab.o ../../../gcc/libiberty/hashtab.c: In function `higher_prime_number': ../../../gcc/libiberty/hashtab.c:133: warning: implicit declaration of function `abort' ../../../gcc/libiberty/hashtab.c: In function `htab_create': ../../../gcc/libiberty/hashtab.c:204: error: `free' undeclared (first use in this function) ../../../gcc/libiberty/hashtab.c:204: error: (Each undeclared identifier is reported only once ../../../gcc/libiberty/hashtab.c:204: error: for each function it appears in.) ../../../gcc/libiberty/hashtab.c: In function `htab_try_create': ../../../gcc/libiberty/hashtab.c:214: error: `calloc' undeclared (first use in this function) ../../../gcc/libiberty/hashtab.c:214: error: `free' undeclared (first use in this function) make[1]: *** [hashtab.o] Error 1 make[1]: Leaving directory `/home/rrude/src/gnu/build-m68k-gcc/m68k-elf/libiberty' make: *** [all-target-libiberty] Error 2 This failure is also present in GCC 3.3: http://gcc.gnu.org/ml/gcc/2003-05/msg01930.html native gcc -v: Reading specs from /home/rrude/tools/native/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs Configured with: ../gcc/configure --verbose --prefix=/home/rrude/tools/native --enable-languages=c,c++,ada,java Thread model: posix gcc version 3.3 20030407 (prerelease) This trivial patch addresses the problem: -- snip diff -Nwupr gcc-20030407/libiberty/hashtab.c /home/rrude/src/gnu/gcc-20030407/libiberty/hashtab.c --- gcc-20030407/libiberty/hashtab.c 2003-01-20 11:41:47.000000000 -0700 +++ /home/rrude/src/gnu/gcc-20030407/libiberty/hashtab.c 2003-04-07 16:21:51.000000000 -0600 @@ -46,6 +46,7 @@ Boston, MA 02111-1307, USA. */ #endif #include <stdio.h> +#include <malloc.h> #include "libiberty.h" #include "hashtab.h" -- snip This patch was submitted to gcc-patches: http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00726.html and a better solution was requested. It's unlikely I will be able to supply the requested changes anytime soon.
This requires a configure.in fix which has yet to be written/submitted... Dara
Rudy, I made a quick patch to configure.in to check for malloc.h. I've attached a patch for it. Is it possible for you to check whether the patch works (I don't have to necessary odds and ends for a full cross compile). All that should be needed is apply the patch, and then rerun autoconf and autoheader in that directory. Thanks, Dara
Created attachment 4162 [details] libiberty patch
Apologies, I meant Randy of course (that's what I get for doing this late at night...)
Dara, your configure patch works for me (my system has malloc.h). I can't test the non-malloc.h case.
Randy, sorry to make another request, but it looks like there was a simpler fix someone found to a problem similar to this (PR 10331). Would it be possible for you to check whether just adding the line: STMP_FIXPROTO = to config/m68k/t-m68kelf fixes the problem? Thanks, Dara
Dara, I created the file config/m68k/t-m68kelf containing the line: STMP_FIXPROTO = and rebuilt. This change did not fix the problem. Is the filename correct?
Yup, that was the change. Okay, so I guess my original patch must have been closer. I'll send it off to the mailing list, and hopefully it (or something like it) will get in soon... Thanks for testing. Dara
I applied the configure patch to 3.3 and 3.4
Randy, I'm having problems reproducing this (without the malloc.h patch installed). Doing a build with gcc 3.3, newlib 1.11.0 and binutils 2.14, I get no errors building a combined tree for m68k-elf. Can you describe how you configured, and what versions of newlib and binutils you used? Thanks, Dara
I just tried again with GCC 3.3, binutils 2.13, and newlib 1.11 (the same binutils and newlib as I reported originally). I still see the problem while building the cross: ../../../gcc/libiberty/hashtab.c: In function `higher_prime_number': ../../../gcc/libiberty/hashtab.c:133: warning: implicit declaration of function `abort' ../../../gcc/libiberty/hashtab.c: In function `htab_create': ../../../gcc/libiberty/hashtab.c:204: error: `free' undeclared (first use in this function) ../../../gcc/libiberty/hashtab.c:204: error: (Each undeclared identifier is reported only once ../../../gcc/libiberty/hashtab.c:204: error: for each function it appears in.) ../../../gcc/libiberty/hashtab.c: In function `htab_try_create': ../../../gcc/libiberty/hashtab.c:214: error: `calloc' undeclared (first use in this function) ../../../gcc/libiberty/hashtab.c:214: error: `free' undeclared (first use in this function) make[1]: *** [hashtab.o] Error 1 make[1]: Leaving directory `/home/rrude/src/gnu/build-m68k-gcc/m68k-elf/libiberty' make: *** [all-target-libiberty] Error 2
Created attachment 4331 [details] native build script Here's my native build script. I place links to the sources (gcc, newlib, binutils) in the current dir and the ./native lrwxrwxrwx 1 rrude rrude 14 Apr 9 13:04 binutils -> binutils-2.13// drwxr-xr-x 14 rrude rrude 1312 Mar 27 09:39 binutils-2.13/ -rwxr--r-- 1 rrude rrude 1347 Apr 16 16:21 cross* lrwxrwxrwx 1 rrude rrude 8 Jul 2 09:53 gcc -> gcc-3.3// drwxr-xr-x 17 rrude rrude 1472 May 13 20:47 gcc-3.3/ -rwxr--r-- 1 rrude rrude 894 Apr 17 14:53 native* lrwxrwxrwx 1 rrude rrude 14 Apr 9 13:05 newlib -> newlib-1.11.0// drwxr-xr-x 8 rrude rrude 1432 Dec 20 2002 newlib-1.11.0/
Created attachment 4332 [details] m68k cross build script See comments for the native build script.
tree-ssa is branch but you tried with 3.3 not with the tree-ssa branch.
Hmm... Oddly enough I can't replicate this with newlib 1.11, binutils 2.13 and gcc 3.3 branch (without the malloc.h include in hashtab.c). Can you try with the 3.3 branch (after disabling the malloc.h include)? Dara
Fixed for 3.4 by: 2003-06-19 Dara Hazeghi * configure.in: Add check for malloc.h needed by m68k for function free(). * configure: Regenerated. * config.in: Add HAVE_MALLOC_H. * hashtab.c: include malloc.h were available for free().