From: Maynard J. <may...@us...> - 2012-06-26 14:35:59
|
On 06/15/2012 10:29 AM, Maynard Johnson wrote: > [PATCH] Add #include "config.h" before bfd.h If no one has any concerns with this patch, I'll commit it to the master branch in a day or so. -Maynard > > While building oprofile against a current CVS snapshot of binutils, > I received the following error: > > ----------------------------------------- > make[2]: Entering directory `/home/cseo/at5.0/at5.0-5/src/oprofile/libopagent' > /bin/sh ../libtool --tag=CC --mode=compile /opt/at5.0-5-rc1/bin/gcc -DHAVE_CONFIG_H -I. -I.. -I/home/cseo/at5.0/at5.0-5/src/oprofile/libopagent -fPIC -I /home/cseo/at5.0/at5.0-5/src/oprofile/libop -I /home/cseo/at5.0/at5.0-5/src/oprofile/libutil -g -MT libopagent_la-opagent.lo -MD -MP -MF .deps/libopagent_la-opagent.Tpo -c -o libopagent_la-opagent.lo `test -f 'opagent.c' || echo '/home/cseo/at5.0/at5.0-5/src/oprofile/libopagent/'`opagent.c > libtool: compile: /opt/at5.0-5-rc1/bin/gcc -DHAVE_CONFIG_H -I. -I.. -I/home/cseo/at5.0/at5.0-5/src/oprofile/libopagent -fPIC -I /home/cseo/at5.0/at5.0-5/src/oprofile/libop -I /home/cseo/at5.0/at5.0-5/src/oprofile/libutil -g -MT libopagent_la-opagent.lo -MD -MP -MF .deps/libopagent_la-opagent.Tpo -c opagent.c -fPIC -DPIC -o .libs/libopagent_la-opagent.o > In file included from opagent.c:63:0: > /opt/at5.0-5-rc1/include/bfd.h:37:2: error: #error config.h must be included before this header > ----------------------------------------- > > I opened a bug against binutils for this (see http://sourceware.org/bugzilla/show_bug.cgi?id=14243), > but the rationale for this error was explained to me thusly: > > "This is a correctness issue. bfd.h and the headers that bfd.h #include test at > least one HAVE_* macro. So you need to include the file that defines those > HAVE_* macros before bfd.h. [sic] It is a really good idea to always include > config.h (or sysdep.h or alloca-conf.h that include config.h) before any other > files, including system headers." > > This patch is a minimal patch that addresses the build failure with binutils, > ensuring that our config.h is #include'd before bfd.h > > Signed-off-by: Maynard Johnson <may...@us...> > --- > libopagent/opagent.c | 1 + > libpp/symbol.h | 1 + > opjitconv/debug_line.c | 1 + > opjitconv/opjitconv.h | 1 + > 4 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/libopagent/opagent.c b/libopagent/opagent.c > index 2db1477..860413f 100644 > --- a/libopagent/opagent.c > +++ b/libopagent/opagent.c > @@ -50,6 +50,7 @@ > * See libopagent/Makefile.am for more information. > *******************************************************************/ > > +#include "config.h" > #include <stdio.h> > #include <errno.h> > #include <string.h> > diff --git a/libpp/symbol.h b/libpp/symbol.h > index 8374318..0071324 100644 > --- a/libpp/symbol.h > +++ b/libpp/symbol.h > @@ -12,6 +12,7 @@ > #ifndef SYMBOL_H > #define SYMBOL_H > > +#include "config.h" > #include "name_storage.h" > #include "growable_vector.h" > #include "sparse_array.h" > diff --git a/opjitconv/debug_line.c b/opjitconv/debug_line.c > index d7db8ec..babb943 100644 > --- a/opjitconv/debug_line.c > +++ b/opjitconv/debug_line.c > @@ -8,6 +8,7 @@ > * @author Philippe Elie > */ > > +#include "config.h" > #include <stdint.h> > #include <stdlib.h> > #include <string.h> > diff --git a/opjitconv/opjitconv.h b/opjitconv/opjitconv.h > index 71c2c95..5a28ea9 100644 > --- a/opjitconv/opjitconv.h > +++ b/opjitconv/opjitconv.h > @@ -26,6 +26,7 @@ > #define OP_JIT_CONV_ALREADY_DONE 5 > #define OP_JIT_CONV_TMPDIR_NOT_REMOVED 6 > > +#include "config.h" > #include <bfd.h> > #include <stddef.h> > #include <sys/stat.h> |