Summary: | bfd build fails in alloca-conf.h when built without gcc | ||
---|---|---|---|
Product: | binutils | Reporter: | Michael Haubenwallner <michael.haubenwallner> |
Component: | binutils | Assignee: | unassigned |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bug-binutils |
Priority: | P2 | ||
Version: | 2.18 | ||
Target Milestone: | --- | ||
Host: | hppa2.0w-hp-hpux11.11 | Target: | hppa2.0w-hp-hpux11.11 |
Build: | hppa2.0w-hp-hpux11.11 | Last reconfirmed: |
Description
Michael Haubenwallner
2007-10-09 08:09:03 UTC
Subject: Re: New: bfd build fails in alloca-conf.h when
built without gcc
Hi Michael,
> When building binutils-2.18 with native cc on hppa-hpux11.11,
> include/alloca-conf.h fails to correctly include <alloca.h>, or to define 'PTR'
> when included in bfd/som.c.
Hmm, the problem here, it seems to me, is the alloca-conf.h header using PTR
when it is not defined. (It is defined in include/ansidecl.h, but
alloca-conf.h does not include that header).
Fixing the bfd configure script so that the system alloca.h is used instead
does not seem to me to be sufficient - the problem can still arise in other
build directories. So please could you try out the patch below (which fixes
the header itself) and let me know if it works for you ?
Cheers
Nick
Index: include/alloca-conf.h
===================================================================
RCS file: /cvs/src/src/include/alloca-conf.h,v
retrieving revision 1.1
diff -c -3 -p -r1.1 alloca-conf.h
*** include/alloca-conf.h 28 Sep 2000 08:00:54 -0000 1.1
--- include/alloca-conf.h 12 Oct 2007 16:42:35 -0000
***************
*** 12,20 ****
# include <alloca.h>
# else /* ! defined (HAVE_ALLOCA_H) */
# ifdef __STDC__
! extern PTR alloca (size_t);
# else /* ! defined (__STDC__) */
! extern PTR alloca ();
# endif /* ! defined (__STDC__) */
# endif /* ! defined (HAVE_ALLOCA_H) */
# ifdef _WIN32
--- 12,20 ----
# include <alloca.h>
# else /* ! defined (HAVE_ALLOCA_H) */
# ifdef __STDC__
! extern void * alloca (size_t);
# else /* ! defined (__STDC__) */
! extern char * alloca ();
# endif /* ! defined (__STDC__) */
# endif /* ! defined (HAVE_ALLOCA_H) */
# ifdef _WIN32
Hi Nick, (In reply to comment #1) > Fixing the bfd configure script so that the system alloca.h is used instead > does not seem to me to be sufficient - the problem can still arise in other > build directories. Did not have this problem in other directories - actually, "alloca-conf.h" is used in bfd only. But agreed, this is not sufficient for platforms really lacking alloca.h > So please could you try out the patch below (which fixes > the header itself) and let me know if it works for you ? With this patch only (without checking for <alloca.h> in bfd/configure), the next unknown symbol is 'size_t': libtool: compile: cc -Wp,-H256000 -DHAVE_CONFIG_H -I. -I/source/binutils-2.18/bfd -I. -DHOST_HPPAHPUX -D_LARGEFILE64_SOURCE -DHPUX_CORE -I. -I/source/binutils-2.18/bfd -I/source/binutils-2.18/bfd/../include -g -c /source/binutils-2.18/bfd/som.c -o som.o cc: "/source/binutils-2.18/bfd/../include/alloca-conf.h", line 15: error 1506: Parameters allowed in function definition only. So in case <alloca.h> is missing, alloca-conf.h should include both ansidecl.h for PTR (as there is a complex #ifdef for __STDC__) as well as sys/types.h (if available) for size_t ? Eh, in gas/ChangeLog-9295 there is this log entry: "Replace alloca-conf.h inclusion with code recommended in autoconf documentation." Maybe this should be done for bfd too ? Thanks! /haubi/ Subject: Re: bfd build fails in alloca-conf.h when built without gcc Hi Haubi, > With this patch only (without checking for <alloca.h> in bfd/configure), the > next unknown symbol is 'size_t': Doh. > Eh, in gas/ChangeLog-9295 there is this log entry: "Replace alloca-conf.h > inclusion with code recommended in autoconf documentation." > > Maybe this should be done for bfd too ? Yup. Please try this revised patch which changes the som.c file directly. If it works for you then I will check it in along with a similar change to elf64-hppa.c and an update of the dependencies in bfd/Makefile.am. (I think that it is best not to include this code in the bfd.h header since I do not want to encourage the use of alloca. It is a poor programming tool and one that can lead to very mysterious and hard to track down bugs). Cheers Nick Index: bfd/som.c =================================================================== RCS file: /cvs/src/src/bfd/som.c,v retrieving revision 1.68 diff -c -3 -p -r1.68 som.c *** bfd/som.c 26 Sep 2007 08:12:59 -0000 1.68 --- bfd/som.c 16 Oct 2007 14:05:42 -0000 *************** *** 23,29 **** Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ - #include "alloca-conf.h" #include "sysdep.h" #include "bfd.h" --- 23,28 ---- *************** *** 38,43 **** --- 37,71 ---- #include <machine/reg.h> #include <sys/file.h> + /* This is the code recommended in the autoconf documentation, almost + verbatim. If it doesn't work for you, let me know, and notify + djm@gnu.ai.mit.edu as well. */ + /* Added void* version for STDC case. This is to be compatible with + the declaration in bison.simple, used for m68k operand parsing. + --KR 1995.08.08 */ + /* Force void* decl for hpux. This is what Bison uses. --KR 1995.08.16 */ + + #ifndef __GNUC__ + # if HAVE_ALLOCA_H + # include <alloca.h> + # else + # ifdef _AIX + /* Indented so that pre-ansi C compilers will ignore it, rather than + choke on it. Some versions of AIX require this to be the first + thing in the file. */ + #pragma alloca + # else + # ifndef alloca /* predefined by HP cc +Olibcalls */ + # if !defined (__STDC__) && !defined (__hpux) + extern char *alloca (); + # else + extern void *alloca (); + # endif /* __STDC__, __hpux */ + # endif /* alloca */ + # endif /* _AIX */ + # endif /* HAVE_ALLOCA_H */ + #endif /* __GNUC__ */ + static bfd_reloc_status_type hppa_som_reloc (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); static bfd_boolean som_mkobject (bfd *); Well, compiling bfd/som.c succeeded, so the patch for bfd/som.c seems ok. But linking the first executable in binutils/ now gives: /bin/sh ./libtool --tag=CC --mode=link cc -Wp,-H256000 -g -o size size.o bucomm.o version.o filemode.o ../bfd/libbfd.la ../libiberty/libiberty.a -lm libtool: link: cc -Wp,-H256000 -g -o size size.o bucomm.o version.o filemode.o ../bfd/.libs/libbfd.a ../libiberty/libiberty.a -lm /usr/ccs/bin/ld: Unsatisfied symbols: alloca (first referenced in ../bfd/.libs/libbfd.a(som.o)) (code) Currently bfd/configure does _not_ check for <alloca.h> - IMO this still is required, as that patch tests HAVE_ALLOCA_H too. Subject: Re: bfd build fails in alloca-conf.h when built
without gcc
Hi Haubi,
> Currently bfd/configure does _not_ check for <alloca.h> - IMO this still is
> required, as that patch tests HAVE_ALLOCA_H too.
Well bum. OK, I'll check your patch in as well as mine, and that should take
care of it, right ?
Cheers
Nick
Hi Nick,
> Well bum. OK, I'll check your patch in as well as mine, and that should take
> care of it, right ?
Yep - both bfd/som.c and bfd/elf64-hppa.c get "config.h" through "sysdep.h" -
should work.
And you drop "include/alloca-conf.h" ?
OTOH, why not simply put your patch into alloca-conf.h ?
Anyway, thank you!
/haubi/
Patches checked in with this ChangeLog entry. bfd/ChangeLog 2007-10-16 Nick Clifton <nickc@redhat.com> PR 5146 * configure.in (AC_CHECK_HEADERS): Add alloca.h * configure: Regenerate. * config.in: Regenerate. * som.c: Replace alloca-conf.h inclusion with code recommended in autoconf documentation. * elf64-hppa.c: Likewise. Native build with gcc 4.2.2 on hppa64-hp-hpux11.11 fails: /bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../src/bf d -I. -DHOST_HPPAHPUX -D_LARGEFILE64_SOURCE -DHPUX_CORE -DHPUX_LARGE_AR_IDS -I. -I../../src/bfd -I../../src/bfd/../include -W -Wall -Wstrict-prototypes -Wm issing-prototypes -Werror -g -O2 -c -o elf64-hppa.lo ../../src/bfd/elf64-hppa.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../src/bfd -I. -DHOST_HPPAHPUX - D_LARGEFILE64_SOURCE -DHPUX_CORE -DHPUX_LARGE_AR_IDS -I. -I../../src/bfd -I../.. /src/bfd/../include -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror -g -O2 -c ../../src/bfd/elf64-hppa.c -DPIC -o .libs/elf64-hppa.o cc1: warnings being treated as errors ../../src/bfd/elf64-hppa.c: In function 'allocate_global_data_opd': ../../src/bfd/elf64-hppa.c:1189: warning: implicit declaration of function 'allo ca' ../../src/bfd/elf64-hppa.c:1189: warning: incompatible implicit declaration of b uilt-in function 'alloca' ../../src/bfd/elf64-hppa.c: In function 'elf64_hppa_finalize_opd': ../../src/bfd/elf64-hppa.c:2189: warning: incompatible implicit declaration of b uilt-in function 'alloca' make[4]: *** [elf64-hppa.lo] Error 1 This is now fixed for builds with gcc by the following change: http://sources.redhat.com/ml/binutils/2007-12/msg00160.html |