[oe] [RFC] gcc patch to avoid host include when compiling gcc-cross

Frans Meulenbroeks fransmeulenbroeks at gmail.com
Fri Jul 9 11:57:06 UTC 2010


Since the introduction of linux-libc-headers-native my gcc-cross fails
to build (unless I avoid building linux-libc-headers-native by telling
that it is ASSUME_PROVIDED).

Reason is that linux-libc-headers-native installs the host
asm/unistd.h in sysroots/i686-linux/usr/include/asm/unistd.h
My architecture (nios2) has a different unistd.h.

Now gcc-cross compiles libgcc.a and adds among others $(GMPINC) to the
include path.
However this is a host path pointing to sysroots/i686-linux/usr/include.
This causes gcc-cross for nios2 to pick up the wrong unistd.h (causing
compilation of libgcc to fail).

libgcc does not need GMP (at least not to my knowledge) and having a
host include when compiling target code does not seem like a good idea
either.
In order to fix this I've made a small patch to Makefile.in
This one creates a new var TARGET_INCLUDES which contains all includes
minus GMPINC.
THen INCLUDES is defined to $(TARGET_INCLUDES) $(GMPINC.) (to get the
original includes back.
And lastly the build rule for libgcc.a is modified to use
$(TARGET_INCLUDES) instead of  $(INCLUDES)

Below is the patch I made. This is not yet a formal patch submission.
Instead this posting is made for a few reasons
- to create awareness and explain the issue
- to get some feedback on the patch
- if there are suggestion for improvements or for better solutions I'd
like to know
- and last but not least: assuming the patch is ok, how are we going
to get it in.
I've tested this for gcc 4.1.2 (but there are 20 other gcc versions around :-( )

Enjoy! Frans.

Index: gcc-4.1.2/gcc/Makefile.in
===================================================================
--- gcc-4.1.2.orig/gcc/Makefile.in
+++ gcc-4.1.2/gcc/Makefile.in
@@ -845,9 +845,13 @@ BUILD_VARRAY = build/varray.o
 # -I$(@D) and -I$(srcdir)/$(@D) cause the subdirectory of the file
 # currently being compiled, in both source trees, to be examined as well.
 # libintl.h will be found in ../intl if we are using the included libintl.
-INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
+#
+# TARGET_INCLUDES is added to avoid that GMPINC (which points to the host
+# include dir) is used for compiling libgcc.a
+TARGET_INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   -I$(srcdir)/../include @INCINTL@ \
-	   $(CPPINC) $(GMPINC)
+	   $(CPPINC)
+INCLUDES = $(TARGET_INCLUDES) $(GMPINC)

 .c.o:
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $< $(OUTPUT_OPTION)
@@ -1379,7 +1383,7 @@ libgcc.a: $(LIBGCC_DEPS)
 	$(MAKE) \
 	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
 	  CONFIG_H="$(TCONFIG_H)" TM_H="$(TM_H)" \
-	  INCLUDES="$(INCLUDES)" \
+	  INCLUDES="$(TARGET_INCLUDES)" \
 	  MAKEOVERRIDES= \
 	  -f libgcc.mk all




More information about the Openembedded-devel mailing list