This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Include sysdep.h before stdio.h in ldlex.c
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: binutils at sourceware dot org
- Cc: Franz Fehringer <fehrin at t-online dot de>, Tristan Gingold <gingold at adacore dot com>
- Date: Mon, 08 Feb 2010 19:39:50 +0000
- Subject: Include sysdep.h before stdio.h in ldlex.c
As Franz pointed out recently, binutils 2.20 and trunk fail to build
on AIX hosts because of an include-ordering bug in ldlex.c. The code
generated by flex includes stdio.h _before_ any of C code in ldlex.l,
which in our case means that it includes stdio.h before sysdep.h.
sysdep.h uses config.h to set macros like _LARGE_FILES to the values
we want, then includes the headers that depend on those macros.
So on AIX we end up including stdio.h twice, once asking for 32-bit
offsets and once asking for 64-bit offsets.
The attached patch is a bit ugly, but it does fix the problem.
Better suggestions welcome!
Tested on powerpc-ibm-aix5.3.0 and x86_64-linux-gnu. OK to apply
to trunk and branch?
Richard
ld/
* Makefile.am (ldlex.o): Depend on ldlex-wrapper.c too, and compile
that instead of ldlex.c.
* Makefile.in: Regenerate.
* ldlex.l (sysdep.h): Don't include here.
* ldlex-wrapper.c: New file.
Index: ld/Makefile.am
===================================================================
--- ld/Makefile.am 2010-01-12 20:30:19.000000000 +0000
+++ ld/Makefile.am 2010-02-08 19:21:35.000000000 +0000
@@ -480,16 +480,16 @@ endif
$(COMPILE) -c `test -f ldgram.c || echo $(srcdir)/`ldgram.c $(NO_WERROR)
endif
-ldlex.o: ldlex.c
+ldlex.o: ldlex-wrapper.c ldlex.c
if am__fastdepCC
- $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f ldlex.c || echo $(srcdir)/`ldlex.c $(NO_WERROR)
+ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(srcdir)/ldlex-wrapper.c $(NO_WERROR)
mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
else
if AMDEP
- source='ldlex.c' object='$@' libtool=no @AMDEPBACKSLASH@
+ source='ldlex-wrapper.c' object='$@' libtool=no @AMDEPBACKSLASH@
DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
endif
- $(COMPILE) -c `test -f ldlex.c || echo $(srcdir)/`ldlex.c $(NO_WERROR)
+ $(COMPILE) -c ldlex-wrapper.c $(NO_WERROR)
endif
deffilep.o: deffilep.c
Index: ld/ldlex.l
===================================================================
--- ld/ldlex.l 2010-01-12 20:30:21.000000000 +0000
+++ ld/ldlex.l 2010-02-08 19:21:35.000000000 +0000
@@ -24,7 +24,6 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-#include "sysdep.h"
#include "bfd.h"
#include "safe-ctype.h"
#include "bfdlink.h"
Index: ld/ldlex-wrapper.c
===================================================================
--- /dev/null 2010-02-08 19:11:56.502114510 +0000
+++ ld/ldlex-wrapper.c 2010-02-08 19:21:35.000000000 +0000
@@ -0,0 +1,2 @@
+#include "sysdep.h"
+#include "ldlex.c"