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

Khem Raj raj.khem at gmail.com
Fri Jul 9 17:26:54 UTC 2010


On Fri, Jul 9, 2010 at 4:57 AM, Frans Meulenbroeks
<fransmeulenbroeks at gmail.com> wrote:
> 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

The approach is ok. however it has to be applied to other libraries too
and also the crt so its not limited to libgcc only.

> - 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 :-( )

We need to patch all used gcc versions 4.5 and 4.4 and 4.3

>
> 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
>
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel at lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
>




More information about the Openembedded-devel mailing list