public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: recent change broke gdb build
  2012-05-16 18:36 recent change broke gdb build Tom Tromey
@ 2012-05-16 18:30 ` Tom Tromey
  2012-05-16 19:30   ` Pedro Alves
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2012-05-16 18:30 UTC (permalink / raw)
  To: Binutils Development

Tom> I tried a quick fix of renaming BFD's config.h to bfd_config.h, but that
Tom> breaks alloca-conf.h, which assumes that every project has a config.h.

Here's a patch that works for me.

This is a bit of a frankenstein patch since I did a bit in a gdb git
repo and another in the binutils git repo.

I haven't checked the GCC tree for uses of alloca-conf.h.

A couple of other minor hacks:

BFD now exports the _ define via sysdeps.h.  I changed it to make this
conditional, so that gdb can define _ and pick up its version.  This
will fail if any BFD header needs to actually use its definition of _.

I changed gdb/defs.h to follow BFD's logic for including fopen-*.h.
I don't think it is too good to depend on some other package's configury
like this.

Any thoughts on this?

Tom

b/bfd/ChangeLog:
2012-05-16  Tom Tromey  <tromey@redhat.com>

	* sysdep.h: Include bfd_config.h.
	(BFD_PACKAGE): New define.
	(_): Redefine.  Make conditional.
	* plugin.c: Include bfd_config.h.
	* compress.c: Include bfd_config.h.
	* elf32-m68hc12x.c: Include bfd_config.h.
	* elf64-hppa.c: Include bfd_config.h.
	* som.c: Include bfd_config.h.
	* xsym.c: Include bfd_config.h.
	* configure, Makefile.in, doc/Makefile.in: Rebuild.
	* configure.in: Generate bfd_config.h, not config.h.
	Pass no-define to AM_INIT_AUTOMAKE.
	* Makefile.am (LOCAL_H_DEPS): Use bfd_config.h.

b/gdb/ChangeLog:
2012-05-16  Tom Tromey  <tromey@redhat.com>

	* defs.h: Include bfd_config.h.  Use BFD logic to include
	fopen-bin.h or fopen-same.h.

b/include/ChangeLog:
2012-05-16  Tom Tromey  <tromey@redhat.com>

	* alloca-conf.h: Don't include config.h.

b/opcodes/ChangeLog:
2012-05-16  Tom Tromey  <tromey@redhat.com>

	* cgen-opc.c: Include config.h.

b/gas/ChangeLog:
2012-05-16  Tom Tromey  <tromey@redhat.com>

	* as.h: Include config.h.

diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index b7271cc..5fc9cf2 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -909,7 +909,7 @@ pex64igen.c: peXXigen.c
 	mv -f pex64igen.new pex64igen.c
 
 BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
-LOCAL_H_DEPS= libbfd.h sysdep.h config.h
+LOCAL_H_DEPS= libbfd.h sysdep.h bfd_config.h
 $(BFD32_LIBS) \
  $(BFD64_LIBS) \
  $(ALL_MACHINES) \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 7a48fda..a76a44e 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -68,7 +68,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
-CONFIG_HEADER = config.h
+CONFIG_HEADER = bfd_config.h
 CONFIG_CLEAN_FILES = bfd-in3.h po/Makefile.in
 CONFIG_CLEAN_VPATH_FILES =
 LIBRARIES = $(noinst_LIBRARIES)
@@ -1085,7 +1085,7 @@ libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL)
 noinst_LIBRARIES = libbfd.a
 libbfd_a_SOURCES = 
 BFD_H_DEPS = $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
-LOCAL_H_DEPS = libbfd.h sysdep.h config.h
+LOCAL_H_DEPS = libbfd.h sysdep.h bfd_config.h
 BFD_H_FILES = bfd-in.h init.c opncls.c libbfd.c section.c archures.c \
 	reloc.c syms.c bfd.c bfdio.c bfdwin.c \
 	archive.c corefile.c targets.c format.c compress.c
@@ -1100,7 +1100,7 @@ CLEANFILES = bfd.h dep.sed stmp-bfd-h DEP DEPA DEP1 DEP2 libbfd.a stamp-lib \
 	stmp-bin2-h stmp-lbfd-h stmp-lcoff-h
 
 DISTCLEANFILES = $(BUILD_CFILES) $(BUILD_HFILES) libtool-soversion
-all: $(BUILT_SOURCES) config.h
+all: $(BUILT_SOURCES) bfd_config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
 .SUFFIXES:
@@ -1140,7 +1140,7 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 $(am__aclocal_m4_deps):
 
-config.h: stamp-h1
+bfd_config.h: stamp-h1
 	@if test ! -f $@; then \
 	  rm -f stamp-h1; \
 	  $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
@@ -1148,14 +1148,14 @@ config.h: stamp-h1
 
 stamp-h1: $(srcdir)/config.in $(top_builddir)/config.status
 	@rm -f stamp-h1
-	cd $(top_builddir) && $(SHELL) ./config.status config.h
+	cd $(top_builddir) && $(SHELL) ./config.status bfd_config.h
 $(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
 	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
 	rm -f stamp-h1
 	touch $@
 
 distclean-hdr:
-	-rm -f config.h stamp-h1
+	-rm -f bfd_config.h stamp-h1
 bfd-in3.h: $(top_builddir)/config.status $(srcdir)/bfd-in2.h
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 po/Makefile.in: $(top_builddir)/config.status $(top_srcdir)/po/Make-in
@@ -1306,6 +1306,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m68hc12.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m68k.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m88k.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m9s12x.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m9s12xg.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-mcore.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-mep.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-microblaze.Plo@am__quote@
@@ -1736,7 +1738,7 @@ distclean-tags:
 check-am: all-am
 check: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) check-recursive
-all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) config.h
+all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) bfd_config.h
 installdirs: installdirs-recursive
 installdirs-am:
 	for dir in "$(DESTDIR)$(bfdlibdir)" "$(DESTDIR)$(bfdincludedir)"; do \
diff --git a/bfd/compress.c b/bfd/compress.c
index a82a8bc..f80a456 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -1,5 +1,5 @@
 /* Compressed section support (intended for debug sections).
-   Copyright 2008, 2010, 2011
+   Copyright 2008, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -19,7 +19,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "config.h"
+#include "bfd_config.h"
 #include "sysdep.h"
 #include "bfd.h"
 #include "libbfd.h"
diff --git a/bfd/configure b/bfd/configure
index 7c52478..6c5e91a 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -3991,15 +3991,6 @@ fi
  VERSION=2.22.52
 
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE "$PACKAGE"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define VERSION "$VERSION"
-_ACEOF
-
 # Some tools Automake needs.
 
 ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
@@ -11404,7 +11395,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11407 "configure"
+#line 11398 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11510,7 +11501,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11513 "configure"
+#line 11504 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12214,7 +12205,7 @@ fi
 
 
 
-ac_config_headers="$ac_config_headers config.h:config.in"
+ac_config_headers="$ac_config_headers bfd_config.h:config.in"
 
 
 if test -z "$target" ; then
@@ -16916,7 +16907,7 @@ do
   case $ac_config_target in
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
+    "bfd_config.h") CONFIG_HEADERS="$CONFIG_HEADERS bfd_config.h:config.in" ;;
     "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
     "bfd_stdint.h") CONFIG_COMMANDS="$CONFIG_COMMANDS bfd_stdint.h" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
diff --git a/bfd/configure.in b/bfd/configure.in
index 47631cc..7fb452a 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -8,7 +8,7 @@ AC_CONFIG_SRCDIR([libbfd.c])
 AC_CANONICAL_TARGET
 AC_ISC_POSIX
 
-AM_INIT_AUTOMAKE(bfd, 2.22.52)
+AM_INIT_AUTOMAKE(bfd, 2.22.52, no-define)
 
 dnl These must be called before LT_INIT, because it may want
 dnl to call AC_CHECK_PROG.
@@ -115,7 +115,7 @@ ACX_BUGURL([http://www.sourceware.org/bugzilla/])
 
 AM_BINUTILS_WARNINGS
 
-AC_CONFIG_HEADERS(config.h:config.in)
+AC_CONFIG_HEADERS(bfd_config.h:config.in)
 
 if test -z "$target" ; then
     AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
index 68e17f7..18f4aaf 100644
--- a/bfd/doc/Makefile.in
+++ b/bfd/doc/Makefile.in
@@ -62,7 +62,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_HEADER = $(top_builddir)/bfd_config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 depcomp =
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index 70bf09e..49867c3 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -20,6 +20,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#include "bfd_config.h"
 #include "alloca-conf.h"
 #include "sysdep.h"
 #include "bfd.h"
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index e3de2a6..674cae4 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -20,6 +20,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#include "bfd_config.h"
 #include "alloca-conf.h"
 #include "sysdep.h"
 #include "bfd.h"
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 733ba71..7bb3401 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -19,7 +19,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "config.h"
+#include "bfd_config.h"
 #include "sysdep.h"
 #include "bfd.h"
 
diff --git a/bfd/som.c b/bfd/som.c
index 0726f84..7d0290e 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1,6 +1,6 @@
 /* bfd back-end for HP PA-RISC SOM objects.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
@@ -23,6 +23,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
    02110-1301, USA.  */
 
+#include "bfd_config.h"
 #include "alloca-conf.h"
 #include "sysdep.h"
 #include "bfd.h"
diff --git a/bfd/sysdep.h b/bfd/sysdep.h
index 20ef56d..5fed75e 100644
--- a/bfd/sysdep.h
+++ b/bfd/sysdep.h
@@ -1,5 +1,5 @@
 /* sysdep.h -- handle host dependencies for the BFD library
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2007, 2009
+   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2007, 2009, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -23,7 +23,7 @@
 #ifndef BFD_SYSDEP_H
 #define BFD_SYSDEP_H
 
-#include "config.h"
+#include "bfd_config.h"
 
 #include "ansidecl.h"
 
@@ -169,9 +169,17 @@ extern int fseeko64 (FILE *stream, off64_t offset, int whence);
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #endif
 
+/* BFD users might define '_'.  Don't mess with that.  */
+#ifndef _
+
 #ifdef ENABLE_NLS
 #include <libintl.h>
-/* Note the use of dgetext() and PACKAGE here, rather than gettext().
+
+/* We don't want to use PACKAGE, because that will be defined by the
+   packages which use BFD.  */
+#define BFD_PACKAGE "bfd"
+
+/* Note the use of dgetext() and BFD_PACKAGE here, rather than gettext().
 
    This is because the code in this directory is used to build a library which
    will be linked with code in other directories to form programs.  We want to
@@ -181,9 +189,9 @@ extern int fseeko64 (FILE *stream, off64_t offset, int whence);
 
    In order to do this, we have to make sure that when we extract messages we
    use the OPCODES domain rather than the domain of the program that included
-   the bfd library, (eg OBJDUMP).  Hence we use dgettext (PACKAGE, String)
-   and define PACKAGE to be 'bfd'.  (See the code in configure).  */
-#define _(String) dgettext (PACKAGE, String)
+   the bfd library, (eg OBJDUMP).  Hence we use dgettext (BFD_PACKAGE, String)
+   and define BFD_PACKAGE to be 'bfd'.  (See the code in configure).  */
+#define _(String) dgettext (BFD_PACKAGE, String)
 #ifdef gettext_noop
 #define N_(String) gettext_noop (String)
 #else
@@ -199,4 +207,6 @@ extern int fseeko64 (FILE *stream, off64_t offset, int whence);
 # define N_(String) (String)
 #endif
 
+#endif /* defined _ */
+
 #endif /* ! defined (BFD_SYSDEP_H) */
diff --git a/bfd/xsym.c b/bfd/xsym.c
index 0926297..ef4884a 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -1,6 +1,6 @@
 /* xSYM symbol-file support for BFD.
    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011 Free Software Foundation, Inc.
+   2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -21,6 +21,7 @@
 
 /* xSYM is the debugging format used by CodeWarrior on Mac OS classic.  */
 
+#include "bfd_config.h"
 #include "alloca-conf.h"
 #include "sysdep.h"
 #include "xsym.h"
diff --git a/gdb/defs.h b/gdb/defs.h
index 004f335..d92b86c 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -757,16 +757,12 @@ enum val_prettyprint
 #include "nm.h"
 #endif
 
-/* Assume that fopen accepts the letter "b" in the mode string.
-   It is demanded by ISO C9X, and should be supported on all
-   platforms that claim to have a standard-conforming C library.  On
-   true POSIX systems it will be ignored and have no effect.  There
-   may still be systems without a standard-conforming C library where
-   an ISO C9X compiler (GCC) is available.  Known examples are SunOS
-   4.x and 4.3BSD.  This assumption means these systems are no longer
-   supported.  */
-#ifndef FOPEN_RB
-# include "fopen-bin.h"
+#include "bfd_config.h"
+
+#ifdef USE_BINARY_FOPEN
+#include "fopen-bin.h"
+#else
+#include "fopen-same.h"
 #endif
 
 /* Defaults for system-wide constants (if not defined by xm.h, we fake it).
diff --git a/include/alloca-conf.h b/include/alloca-conf.h
index 628a598..d75a1e4 100644
--- a/include/alloca-conf.h
+++ b/include/alloca-conf.h
@@ -1,5 +1,3 @@
-#include "config.h"
-
 /* This is a merge of code recommended in the autoconf-2.61 documentation
    with that recommended in the autoconf-2.13 documentation, with added
    tweaks to heed C_ALLOCA.  */
diff --git a/opcodes/cgen-opc.c b/opcodes/cgen-opc.c
index 263eb2c..2c6231d 100644
--- a/opcodes/cgen-opc.c
+++ b/opcodes/cgen-opc.c
@@ -1,6 +1,6 @@
 /* CGEN generic opcode support.
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2005, 2007, 2009
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2005, 2007, 2009, 2012
    Free Software Foundation, Inc.
 
    This file is part of libopcodes.
@@ -19,6 +19,7 @@
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
+#include "config.h"
 #include "alloca-conf.h"
 #include "sysdep.h"
 #include <stdio.h>
diff --git a/gas/as.h b/gas/as.h
index f2214e8..b343725 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -36,6 +36,7 @@
   	COMMON as "".
    If TEST is #defined, then we are testing a module: #define COMMON as "".  */
 
+#include "config.h"
 #include "alloca-conf.h"
 
 /* Now, tend to the rest of the configuration.  */

^ permalink raw reply	[flat|nested] 7+ messages in thread

* recent change broke gdb build
@ 2012-05-16 18:36 Tom Tromey
  2012-05-16 18:30 ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2012-05-16 18:36 UTC (permalink / raw)
  To: Binutils Development

This change broke the gdb --enable-targets=all build:

2012-05-16  Daniel Richard G.  <skunk@iskunk.org>

	PR binutils/13558
	* bfd/aout-cris.c: Include sysdep.h before bfd.h.
	* bfd/aout-ns32k.c: Likewise.
	* bfd/aout-sparcle.c: Likewise.
[...]

The failure is:

In file included from ../../archer/gdb/../bfd/sysdep.h:81:0,
                 from ../../archer/gdb/../bfd/mach-o.h:26,
                 from ../../archer/gdb/solib-darwin.c:43:
../../archer/gdb/../include/fopen-same.h:15:0: error: "FOPEN_RB" redefined [-Werror]
../../archer/gdb/../include/fopen-bin.h:15:0: note: this is the location of the previous definition
../../archer/gdb/../include/fopen-same.h:16:0: error: "FOPEN_WB" redefined [-Werror]
../../archer/gdb/../include/fopen-bin.h:16:0: note: this is the location of the previous definition
../../archer/gdb/../include/fopen-same.h:17:0: error: "FOPEN_AB" redefined [-Werror]
../../archer/gdb/../include/fopen-bin.h:17:0: note: this is the location of the previous definition
../../archer/gdb/../include/fopen-same.h:18:0: error: "FOPEN_RUB" redefined [-Werror]
../../archer/gdb/../include/fopen-bin.h:18:0: note: this is the location of the previous definition
../../archer/gdb/../include/fopen-same.h:19:0: error: "FOPEN_WUB" redefined [-Werror]
../../archer/gdb/../include/fopen-bin.h:19:0: note: this is the location of the previous definition
../../archer/gdb/../include/fopen-same.h:20:0: error: "FOPEN_AUB" redefined [-Werror]
../../archer/gdb/../include/fopen-bin.h:20:0: note: this is the location of the previous definition
In file included from ../../archer/gdb/../bfd/mach-o.h:26:0,
                 from ../../archer/gdb/solib-darwin.c:43:
../../archer/gdb/../bfd/sysdep.h:186:0: error: "_" redefined [-Werror]
../../archer/gdb/common/gdb_locale.h:28:0: note: this is the location of the previous definition


I guess I don't understand how all this is supposed to work.

BFD supplies a config.h -- but the gdb build will always pick up gdb's
config.h, not BFD's.  So, either the conditionals will randomly be
wrong, or the gdb configure is supposed to do all the same checks and
arrive at the same results as the BFD configure.  But, the latter seems
like a pretty bad idea...

I tried a quick fix of renaming BFD's config.h to bfd_config.h, but that
breaks alloca-conf.h, which assumes that every project has a config.h.

I guess one idea would be to make BFD create *both* config.h and
bfd_config.h, and have it use bfd_config.h everywhere internally.

Or maybe this same treatment has to be applied to libiberty/config.h, so
alloca-config.h can work -- but at this point I figured that there must
just be something I'm missing.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: recent change broke gdb build
  2012-05-16 18:30 ` Tom Tromey
@ 2012-05-16 19:30   ` Pedro Alves
  2012-05-16 19:37     ` Tom Tromey
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Pedro Alves @ 2012-05-16 19:30 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Binutils Development

On 05/16/2012 06:47 PM, Tom Tromey wrote:

> Tom> I tried a quick fix of renaming BFD's config.h to bfd_config.h, but that
> Tom> breaks alloca-conf.h, which assumes that every project has a config.h.
> 
> Here's a patch that works for me.
> 
> This is a bit of a frankenstein patch since I did a bit in a gdb git
> repo and another in the binutils git repo.
> 
> I haven't checked the GCC tree for uses of alloca-conf.h.
> 
> A couple of other minor hacks:
> 
> BFD now exports the _ define via sysdeps.h.  


The issue is that bfd/mach-o.h now includes sysdeps.h, and GDB wants
to include mach-o.h.  (It's not bfd.h that includes sysdeps.h.)

I think bfd should not include sysdeps.h (of config.h) in headers
that might be used outside bfd.  Instead, the inclusion should be moved
to bfd's own .c files.  Looking at all the bfd files that include
macho.h, they're all already including sysdep.h:

mach-o.c-
mach-o.c-#include "sysdep.h"
mach-o.c:#include "mach-o.h"
mach-o.c-#include "bfd.h"
mach-o.c-#include "libbfd.h"
--
mach-o-i386.c-
mach-o-i386.c-#include "sysdep.h"
mach-o-i386.c:#include "mach-o.h"
mach-o-i386.c-#include "bfd.h"
mach-o-i386.c-#include "libbfd.h"
--
mach-o-x86-64.c-
mach-o-x86-64.c-#include "sysdep.h"
mach-o-x86-64.c:#include "mach-o.h"
mach-o-x86-64.c-#include "bfd.h"
mach-o-x86-64.c-#include "libbfd.h"

So reverting the sysdep.h inclusion from mach-o.h is enough to
fix this.  Patch below.

> I changed gdb/defs.h to follow BFD's logic for including fopen-*.h.
> I don't think it is too good to depend on some other package's configury
> like this.


The usual way to do that is to share an .m4 file.


2012-05-16  Pedro Alves  <palves@redhat.com>

	* mach-o.h: Don't include sysdep.h.
---

 bfd/mach-o.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 67ee43d..7f54961 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -23,7 +23,6 @@
 #ifndef _BFD_MACH_O_H_
 #define _BFD_MACH_O_H_

-#include "sysdep.h"
 #include "bfd.h"
 #include "mach-o/loader.h"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: recent change broke gdb build
  2012-05-16 19:30   ` Pedro Alves
@ 2012-05-16 19:37     ` Tom Tromey
  2012-05-16 19:50     ` Pedro Alves
  2012-05-18 11:30     ` [ping] " Pedro Alves
  2 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2012-05-16 19:37 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Binutils Development

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> 2012-05-16  Pedro Alves  <palves@redhat.com>
Pedro> 	* mach-o.h: Don't include sysdep.h.

That's certainly simpler :)

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: recent change broke gdb build
  2012-05-16 19:30   ` Pedro Alves
  2012-05-16 19:37     ` Tom Tromey
@ 2012-05-16 19:50     ` Pedro Alves
  2012-05-18 11:30     ` [ping] " Pedro Alves
  2 siblings, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2012-05-16 19:50 UTC (permalink / raw)
  Cc: Tom Tromey, Binutils Development

On 05/16/2012 08:30 PM, Pedro Alves wrote:

>> > I changed gdb/defs.h to follow BFD's logic for including fopen-*.h.
>> > I don't think it is too good to depend on some other package's configury
>> > like this.
> 
> The usual way to do that is to share an .m4 file.


Something like this.  Not strictly necessary, as GDB works/builds fine
without this.

config/
2012-05-16  Pedro Alves  <palves@redhat.com>

	* binary-fopen.m4: New file.

bfd/
2012-05-16  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include ../config/binary-fopen.m4.
	(BFD_BINARY_FOPEN): Delete.
	* configure.in: Call ACX_BINARY_FOPEN instead of BFD_BINARY_FOPEN.

gdb/
2012-05-16  Pedro Alves  <palves@redhat.com>

	* configure.ac: Call ACX_BINARY_FOPEN.
	* defs.h: Include fopen-bin.h or fopen-same.h depending on
	USE_BINARY_FOPEN being defined instead of including fopen-bin.h
	depending on FOPEN_RB not being defined.
	* config.in: Regenerate.
	* configure: Regenerate.
---

 bfd/acinclude.m4 |   10 +---------
 bfd/configure.in |    2 +-
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/bfd/acinclude.m4 b/bfd/acinclude.m4
index d9813bd..98cf519 100644
--- a/bfd/acinclude.m4
+++ b/bfd/acinclude.m4
@@ -1,14 +1,6 @@
 sinclude([../config/zlib.m4])

-dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
-AC_DEFUN([BFD_BINARY_FOPEN],
-[AC_REQUIRE([AC_CANONICAL_TARGET])
-case "${host}" in
-changequote(,)dnl
-*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
-changequote([,])dnl
-  AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
-esac])dnl
+sinclude([../config/binary-fopen.m4])

 dnl Get a default for CC_FOR_BUILD to put into Makefile.
 AC_DEFUN([BFD_CC_FOR_BUILD],
diff --git a/bfd/configure.in b/bfd/configure.in
index 47631cc..e949d37 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -203,7 +203,7 @@ AC_CHECK_DECLS(ftello64)
 AC_CHECK_DECLS(fseeko)
 AC_CHECK_DECLS(fseeko64)

-BFD_BINARY_FOPEN
+ACX_BINARY_FOPEN

 AC_CHECK_DECLS(ffs)
 AC_CHECK_DECLS(free)
diff --git a/config/binary-fopen.m4 b/config/binary-fopen.m4
new file mode 100644
index 0000000..8a9336d
--- /dev/null
+++ b/config/binary-fopen.m4
@@ -0,0 +1,9 @@
+dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
+AC_DEFUN([ACX_BINARY_FOPEN],
+[AC_REQUIRE([AC_CANONICAL_TARGET])
+case "${host}" in
+changequote(,)dnl
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+changequote([,])dnl
+  AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
+esac])dnl
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 9d231e1..85c0267 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -36,6 +36,9 @@ sinclude([../config/codeset.m4])

 sinclude([../config/zlib.m4])

+dnl For ACX_BINARY_FOPEN.
+sinclude([../config/binary-fopen.m4])
+
 #
 # Sometimes the native compiler is a bogus stub for gcc or /usr/ucb/cc. This
 # makes configure think it's cross compiling. If --target wasn't used, then
diff --git a/gdb/config.in b/gdb/config.in
index a3bd8dd..ee1961a 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -713,6 +713,9 @@
 /* Define if <thread_db.h> has the TD_VERSION error code. */
 #undef THREAD_DB_HAS_TD_VERSION

+/* Use b modifier when opening binary files? */
+#undef USE_BINARY_FOPEN
+
 /* Define to 1 if the regex included in libiberty should be used. */
 #undef USE_INCLUDED_REGEX

diff --git a/gdb/configure b/gdb/configure
index ec0d30b..a5b8bab 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -4360,6 +4360,13 @@ case "x$am_cv_prog_cc_stdc" in
 esac


+case "${host}" in
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+
+$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
+ ;;
+esac
+
 ac_aux_dir=
 for ac_dir in .. "$srcdir"/..; do
   for ac_t in install-sh install.sh shtool; do
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 97cd6ee..aecf4b5 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -27,6 +27,7 @@ AC_PROG_CC
 AC_USE_SYSTEM_EXTENSIONS
 ACX_LARGEFILE
 AM_PROG_CC_STDC
+ACX_BINARY_FOPEN

 AC_CONFIG_AUX_DIR(..)
 AC_CANONICAL_SYSTEM
diff --git a/gdb/defs.h b/gdb/defs.h
index 004f335..eccc651 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -757,16 +757,10 @@ enum val_prettyprint
 #include "nm.h"
 #endif

-/* Assume that fopen accepts the letter "b" in the mode string.
-   It is demanded by ISO C9X, and should be supported on all
-   platforms that claim to have a standard-conforming C library.  On
-   true POSIX systems it will be ignored and have no effect.  There
-   may still be systems without a standard-conforming C library where
-   an ISO C9X compiler (GCC) is available.  Known examples are SunOS
-   4.x and 4.3BSD.  This assumption means these systems are no longer
-   supported.  */
-#ifndef FOPEN_RB
-# include "fopen-bin.h"
+#ifdef USE_BINARY_FOPEN
+#  include "fopen-bin.h"
+#else
+#  include "fopen-same.h"
 #endif

 /* Defaults for system-wide constants (if not defined by xm.h, we fake it).

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ping] Re: recent change broke gdb build
  2012-05-16 19:30   ` Pedro Alves
  2012-05-16 19:37     ` Tom Tromey
  2012-05-16 19:50     ` Pedro Alves
@ 2012-05-18 11:30     ` Pedro Alves
  2012-05-18 14:32       ` Alan Modra
  2 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2012-05-18 11:30 UTC (permalink / raw)
  Cc: Tom Tromey, Binutils Development

Ping, may I apply this?  GDB's --enable-targets=all build is still broken.

http://sourceware.org/ml/binutils/2012-05/msg00224.html

There are a handful of other internal bfd headers that include sysdeps.h, but
mach-o.h is the only one that gdb is including.

$ cd gdb
$ grep -h "^# *include" * | sed 's/h\".*/h\"/g' | grep bfd | sort -u
#include "bfd.h"
#include "bfd-in2.h"
#include "bfdlink.h"
#include "bfd/mach-o.h"
#include "bfd-target.h"
#include "elf-bfd.h"
#include "libbfd.h"

-- 
Pedro Alves

On 05/16/2012 08:30 PM, Pedro Alves wrote:

> On 05/16/2012 06:47 PM, Tom Tromey wrote:
> 
>> Tom> I tried a quick fix of renaming BFD's config.h to bfd_config.h, but that
>> Tom> breaks alloca-conf.h, which assumes that every project has a config.h.
>>
>> Here's a patch that works for me.
>>
>> This is a bit of a frankenstein patch since I did a bit in a gdb git
>> repo and another in the binutils git repo.
>>
>> I haven't checked the GCC tree for uses of alloca-conf.h.
>>
>> A couple of other minor hacks:
>>
>> BFD now exports the _ define via sysdeps.h.  
> 
> 
> The issue is that bfd/mach-o.h now includes sysdeps.h, and GDB wants
> to include mach-o.h.  (It's not bfd.h that includes sysdeps.h.)
> 
> I think bfd should not include sysdeps.h (of config.h) in headers
> that might be used outside bfd.  Instead, the inclusion should be moved
> to bfd's own .c files.  Looking at all the bfd files that include
> macho.h, they're all already including sysdep.h:
> 
> mach-o.c-
> mach-o.c-#include "sysdep.h"
> mach-o.c:#include "mach-o.h"
> mach-o.c-#include "bfd.h"
> mach-o.c-#include "libbfd.h"
> --
> mach-o-i386.c-
> mach-o-i386.c-#include "sysdep.h"
> mach-o-i386.c:#include "mach-o.h"
> mach-o-i386.c-#include "bfd.h"
> mach-o-i386.c-#include "libbfd.h"
> --
> mach-o-x86-64.c-
> mach-o-x86-64.c-#include "sysdep.h"
> mach-o-x86-64.c:#include "mach-o.h"
> mach-o-x86-64.c-#include "bfd.h"
> mach-o-x86-64.c-#include "libbfd.h"
> 
> So reverting the sysdep.h inclusion from mach-o.h is enough to
> fix this.  Patch below.
> 
>> I changed gdb/defs.h to follow BFD's logic for including fopen-*.h.
>> I don't think it is too good to depend on some other package's configury
>> like this.
> 
> 
> The usual way to do that is to share an .m4 file.
> 
> 
> 2012-05-16  Pedro Alves  <palves@redhat.com>
> 
> 	* mach-o.h: Don't include sysdep.h.
> ---
> 
>  bfd/mach-o.h |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/bfd/mach-o.h b/bfd/mach-o.h
> index 67ee43d..7f54961 100644
> --- a/bfd/mach-o.h
> +++ b/bfd/mach-o.h
> @@ -23,7 +23,6 @@
>  #ifndef _BFD_MACH_O_H_
>  #define _BFD_MACH_O_H_
> 
> -#include "sysdep.h"
>  #include "bfd.h"
>  #include "mach-o/loader.h"
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ping] Re: recent change broke gdb build
  2012-05-18 11:30     ` [ping] " Pedro Alves
@ 2012-05-18 14:32       ` Alan Modra
  0 siblings, 0 replies; 7+ messages in thread
From: Alan Modra @ 2012-05-18 14:32 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, Binutils Development

On Fri, May 18, 2012 at 12:29:54PM +0100, Pedro Alves wrote:
> Ping, may I apply this?  GDB's --enable-targets=all build is still broken.
> > 	* mach-o.h: Don't include sysdep.h.

OK.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-05-18 14:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-16 18:36 recent change broke gdb build Tom Tromey
2012-05-16 18:30 ` Tom Tromey
2012-05-16 19:30   ` Pedro Alves
2012-05-16 19:37     ` Tom Tromey
2012-05-16 19:50     ` Pedro Alves
2012-05-18 11:30     ` [ping] " Pedro Alves
2012-05-18 14:32       ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).