Patchwork gcc-4.6: Let G++ relocate gxx-include-dir when using --sysroot option

login
register
mail settings
Submitter Khem Raj
Date Dec. 14, 2011, 8:28 a.m.
Message ID <1323851280-6342-1-git-send-email-raj.khem@gmail.com>
Download mbox | patch
Permalink /patch/16907/
State Superseded
Headers show

Comments

Khem Raj - Dec. 14, 2011, 8:28 a.m.
Currently we have a problem in our cross compiler since we use
/usr/include/c++ to be default gxx-include-dir and then expect
the patch we did to do the relocation w.r.t. sysroot however it
does not quite work so and we end up gxx-include-dirs not respecting
sysroot. A small test case would be

tst-unique4.cc

and it would fails like

tst-unique4.cc:1:18: fatal error: cstdio: No such file or directory
compilation terminated.

weather we use --sysroot or not it does not matter

arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
--sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm

failed in same way.

so we redo the GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch based on upstream
submitted patch which tries to relocate the gxx-include-dir and to
achieve the relocation it has to be specified w.r.t to --with-sysroot
directory. e.g.

--with-sysroot=${SYSROOT}
--with-gxx-include-dir=${SYSROOT}/usr/include/c++

if we configure gcc like above then it becomes relocatable when
we run the compiler and specify --sysroot=<blah> then g++ will search
for gxx-headers under <blah>/usr/include/c++

if sysroot is not defined then it will use the default sysroot
and gxx-include-dir will be w.r.t. default sysroot.

Tested on qemuarm

/arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
--sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
-v
...
 /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++
 /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/arm-oe-linux-gnueabi
 /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/backward
...

and if I now change --sysroot to something else

/arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
--sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4
-v
...

ignoring nonexistent directory
"/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++"
ignoring nonexistent directory
"/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/arm-oe-linux-gnueabi"
ignoring nonexistent directory
"/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/backward"
...

See now its looking for them in 'qemuarm4' sysroot

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/gcc/gcc-4.6.inc              |    4 +-
 .../GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch       |  189 ++++++++++++++++++--
 meta/recipes-devtools/gcc/gcc-configure-cross.inc  |    2 +-
 .../recipes-devtools/gcc/gcc-configure-runtime.inc |    2 +-
 meta/recipes-devtools/gcc/gcc-configure-sdk.inc    |    2 +-
 5 files changed, 175 insertions(+), 24 deletions(-)
Richard Purdie - Dec. 14, 2011, 10:02 a.m.
Hi Khem,

What's puzzling me is that reading through this patch, we already do
what this patch is doing?

Where is the difference which this patch is fixing?

I appreciate that patch adds in the prefix to the --with-gxx-include-dir
option but it then removes it again during configure so this should be a
null op. Both versions of the patch set the "1" bit in gcc/cppdefault.c.

So where is the change this patch makes which fixes things?

Cheers,

Richard



On Wed, 2011-12-14 at 00:28 -0800, Khem Raj wrote:
> Currently we have a problem in our cross compiler since we use
> /usr/include/c++ to be default gxx-include-dir and then expect
> the patch we did to do the relocation w.r.t. sysroot however it
> does not quite work so and we end up gxx-include-dirs not respecting
> sysroot. A small test case would be
> 
> tst-unique4.cc
> 
> and it would fails like
> 
> tst-unique4.cc:1:18: fatal error: cstdio: No such file or directory
> compilation terminated.
> 
> weather we use --sysroot or not it does not matter
> 
> arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
> 
> failed in same way.
> 
> so we redo the GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch based on upstream
> submitted patch which tries to relocate the gxx-include-dir and to
> achieve the relocation it has to be specified w.r.t to --with-sysroot
> directory. e.g.
> 
> --with-sysroot=${SYSROOT}
> --with-gxx-include-dir=${SYSROOT}/usr/include/c++
> 
> if we configure gcc like above then it becomes relocatable when
> we run the compiler and specify --sysroot=<blah> then g++ will search
> for gxx-headers under <blah>/usr/include/c++
> 
> if sysroot is not defined then it will use the default sysroot
> and gxx-include-dir will be w.r.t. default sysroot.
> 
> Tested on qemuarm
> 
> /arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
> -v
> ...
>  /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++
>  /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/arm-oe-linux-gnueabi
>  /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/backward
> ...
> 
> and if I now change --sysroot to something else
> 
> /arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4
> -v
> ...
> 
> ignoring nonexistent directory
> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++"
> ignoring nonexistent directory
> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/arm-oe-linux-gnueabi"
> ignoring nonexistent directory
> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/backward"
> ...
> 
> See now its looking for them in 'qemuarm4' sysroot
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  meta/recipes-devtools/gcc/gcc-4.6.inc              |    4 +-
>  .../GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch       |  189 ++++++++++++++++++--
>  meta/recipes-devtools/gcc/gcc-configure-cross.inc  |    2 +-
>  .../recipes-devtools/gcc/gcc-configure-runtime.inc |    2 +-
>  meta/recipes-devtools/gcc/gcc-configure-sdk.inc    |    2 +-
>  5 files changed, 175 insertions(+), 24 deletions(-)
> 
> diff --git a/meta/recipes-devtools/gcc/gcc-4.6.inc b/meta/recipes-devtools/gcc/gcc-4.6.inc
> index 18e0536..4bbb2d2 100644
> --- a/meta/recipes-devtools/gcc/gcc-4.6.inc
> +++ b/meta/recipes-devtools/gcc/gcc-4.6.inc
> @@ -1,6 +1,6 @@
>  require gcc-common.inc
>  
> -PR = "r19"
> +PR = "r20"
>  
>  # Third digit in PV should be incremented after a minor release
>  # happens from this branch on gcc e.g. currently its 4.6.0
> @@ -62,7 +62,6 @@ SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \
>  	   file://64bithack.patch \
>  	   file://optional_libstdc.patch \
>  	   file://disable_relax_pic_calls_flag.patch \
> -	   file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \
>  	   file://COLLECT_GCC_OPTIONS.patch \
>             file://volatile_access_backport.patch \
>             file://use-defaults.h-and-t-oe-in-B.patch \
> @@ -73,6 +72,7 @@ SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \
>  	   file://pr32219.patch \
>  	   file://pr47551.patch \
>  	   file://gcc-arm-set-cost.patch \
> +	   file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \
>  	  "
>  
>  SRC_URI_append_sh3  = " file://sh3-installfix-fixheaders.patch "
> diff --git a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
> index 05b2fa9..6ccbeea 100644
> --- a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
> +++ b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
> @@ -1,35 +1,186 @@
> -Upstream-Status: Pending
> -
> -# by default c++ include directories are not relative to "--sysroot"
> -# which brings one trouble when using the toolchain in an environment
> -# where the build directory generating that toolchain doesn't exist,
> -# e.g. in sstate, machine specific sysroot and relocatable SDK
> -# toolchain. This patch now enables c++ include paths under sysroot.
> -# This way it's enough as long as "--sysroot" is correctly enabled
> -# in the new environment.
> -#
> -# Signed-off-by Kevin Tian <kevin.tian@intel.com>, 2010-12-30
> -
> -Index: gcc-4.6.0/gcc/cppdefault.c
> +source: http://patchwork.ozlabs.org/patch/129800/
> +Upstream-Status: Submitted
> +
> +ChangeLog
> +        * Makefile.in (gcc_gxx_include_dir_add_sysroot): New.
> +          (PREPROCESSOR_DEFINES): Define GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT.
> +
> +        * cppdefault.c (cpp_include_defaults): replace hard coded "1" with
> +          GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT for "add_sysroot" field.
> +
> +        * configure.ac (AC_SUBST): Add gcc_gxx_include_dir_add_sysroot to
> +          control whether sysroot should be prepended to gxx include dir.
> +
> +        * configure: Regenerate.
> +
> +Hi, this is a follow up for issue "http://codereview.appspot.com/4641076".
> +
> +The rationale for the patch copied from previous thread:
> +=======================================
> +The setup:
> +
> +Configuring a toolchain targeting x86-64 GNU Linux (Ubuntu Lucid), as a
> +cross-compiler.  Using a sysroot to provide the Lucid headers+libraries,
> +with the sysroot path being within the GCC install tree.  Want to use the
> +Lucid system libstdc++ and headers, which means that I'm not
> +building/installing libstdc++-v3.
> +
> +So, configuring with:
> +  --with-sysroot="$SYSROOT"
> +  --disable-libstdc++-v3 \
> +  --with-gxx-include-dir="$SYSROOT/usr/include/c++/4.4" \
> +(among other options).
> +
> +Hoping to support two usage models with this configuration, w.r.t. use of
> +the sysroot:
> +
> +(1) somebody installs the sysroot in the normal location relative to the
> +GCC install, and relocates the whole bundle (sysroot+GCC).  This works
> +great AFAICT, GCC finds its includes (including the C++ includes) thanks
> +to the add_standard_paths iprefix handling.
> +
> +(2) somebody installs the sysroot in a non-standard location, and uses
> +--sysroot to try to access it.  This works fine for the C headers, but
> +doesn't work.
> +
> +For the C headers, add_standard_paths prepends the sysroot location to
> +the /usr/include path (since that's what's specified in cppdefault.c for
> +that path).  It doesn't do the same for the C++ include path, though
> +(again, as specified in cppdefault.c).
> +
> +add_standard_paths doesn't attempt to relocate built-in include paths that
> +start with the compiled-in sysroot location (e.g., the g++ include dir, in
> +this case).  This isn't surprising really: normally you either prepend the
> +sysroot location or you don't (as specified by cppdefault.c); none of the
> +built-in paths normally *start* with the sysroot location and need to be
> +relocated.  However, in this odd-ball case of trying to use the C++ headers
> +from the sysroot, one of the paths *does* need to be relocated in this way.
> +===========================
> +Index: gcc-4_6-branch/gcc/Makefile.in
> +===================================================================
> +--- gcc-4_6-branch.orig/gcc/Makefile.in	2011-12-13 22:52:15.000000000 -0800
> ++++ gcc-4_6-branch/gcc/Makefile.in	2011-12-13 22:52:21.933635767 -0800
> +@@ -587,6 +587,7 @@
> + build_tooldir = $(exec_prefix)/$(target_noncanonical)
> + # Directory in which the compiler finds target-independent g++ includes.
> + gcc_gxx_include_dir = @gcc_gxx_include_dir@
> ++gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@
> + # Directory to search for site-specific includes.
> + local_includedir = $(local_prefix)/include
> + includedir = $(prefix)/include
> +@@ -3964,6 +3965,7 @@
> +   -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
> +   -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
> +   -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
> ++  -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
> +   -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
> +   -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
> +   -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
> +Index: gcc-4_6-branch/gcc/configure.ac
>  ===================================================================
> ---- gcc-4.6.0.orig/gcc/cppdefault.c
> -+++ gcc-4.6.0/gcc/cppdefault.c
> -@@ -48,15 +48,15 @@ const struct default_include cpp_include
> +--- gcc-4_6-branch.orig/gcc/configure.ac	2011-12-13 22:52:15.000000000 -0800
> ++++ gcc-4_6-branch/gcc/configure.ac	2011-12-13 22:52:21.937635526 -0800
> +@@ -144,6 +144,15 @@
> +   fi
> + fi
> + 
> ++gcc_gxx_include_dir_add_sysroot=0
> ++if test "${with_sysroot+set}" = set; then :
> ++  gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
> ++  if test "${gcc_gxx_without_sysroot}"; then :
> ++    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
> ++    gcc_gxx_include_dir_add_sysroot=1
> ++  fi
> ++fi
> ++
> + AC_ARG_WITH(cpp_install_dir,
> + [  --with-cpp-install-dir=DIR
> +                           install the user visible C preprocessor in DIR
> +@@ -4737,6 +4746,7 @@
> + AC_SUBST(float_h_file)
> + AC_SUBST(gcc_config_arguments)
> + AC_SUBST(gcc_gxx_include_dir)
> ++AC_SUBST(gcc_gxx_include_dir_add_sysroot)
> + AC_SUBST(host_exeext)
> + AC_SUBST(host_xm_file_list)
> + AC_SUBST(host_xm_include_list)
> +Index: gcc-4_6-branch/gcc/cppdefault.c
> +===================================================================
> +--- gcc-4_6-branch.orig/gcc/cppdefault.c	2011-12-13 22:51:28.000000000 -0800
> ++++ gcc-4_6-branch/gcc/cppdefault.c	2011-12-13 22:52:21.937635526 -0800
> +@@ -48,15 +48,18 @@
>   = {
>   #ifdef GPLUSPLUS_INCLUDE_DIR
>       /* Pick up GNU C++ generic include files.  */
>  -    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
> -+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 },
> ++    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
>   #endif
>   #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
>       /* Pick up GNU C++ target-dependent include files.  */
>  -    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 1 },
> -+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 1, 1 },
> ++    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
>   #endif
>   #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
>       /* Pick up GNU C++ backward and deprecated include files.  */
>  -    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
> -+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 1, 0 },
> ++    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
>   #endif
>   #ifdef GCC_INCLUDE_DIR
>       /* This is the dir for gcc's private headers.  */
> +Index: gcc-4_6-branch/gcc/configure
> +===================================================================
> +--- gcc-4_6-branch.orig/gcc/configure	2011-12-13 22:52:15.000000000 -0800
> ++++ gcc-4_6-branch/gcc/configure	2011-12-13 22:52:33.185690436 -0800
> +@@ -636,6 +636,7 @@
> + host_xm_include_list
> + host_xm_file_list
> + host_exeext
> ++gcc_gxx_include_dir_add_sysroot
> + gcc_gxx_include_dir
> + gcc_config_arguments
> + float_h_file
> +@@ -3313,6 +3314,15 @@
> +   fi
> + fi
> + 
> ++gcc_gxx_include_dir_add_sysroot=0
> ++if test "${with_sysroot+set}" = set; then :
> ++  gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
> ++  if test "${gcc_gxx_without_sysroot}"; then :
> ++    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
> ++    gcc_gxx_include_dir_add_sysroot=1
> ++  fi
> ++fi
> ++
> + 
> + # Check whether --with-cpp_install_dir was given.
> + if test "${with_cpp_install_dir+set}" = set; then :
> +@@ -17514,7 +17524,7 @@
> +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> +   lt_status=$lt_dlunknown
> +   cat > conftest.$ac_ext <<_LT_EOF
> +-#line 17517 "configure"
> ++#line 17527 "configure"
> + #include "confdefs.h"
> + 
> + #if HAVE_DLFCN_H
> +@@ -17620,7 +17630,7 @@
> +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> +   lt_status=$lt_dlunknown
> +   cat > conftest.$ac_ext <<_LT_EOF
> +-#line 17623 "configure"
> ++#line 17633 "configure"
> + #include "confdefs.h"
> + 
> + #if HAVE_DLFCN_H
> +@@ -26151,6 +26161,7 @@
> + 
> + 
> + 
> ++
> + 
> + 
> + 
> diff --git a/meta/recipes-devtools/gcc/gcc-configure-cross.inc b/meta/recipes-devtools/gcc/gcc-configure-cross.inc
> index d2d9081..5816768 100644
> --- a/meta/recipes-devtools/gcc/gcc-configure-cross.inc
> +++ b/meta/recipes-devtools/gcc/gcc-configure-cross.inc
> @@ -10,7 +10,7 @@ EXTRA_OECONF += " --enable-poison-system-directories \
>  INHIBIT_DEFAULT_DEPS = "1"
>  
>  EXTRA_OECONF_PATHS = "--with-local-prefix=${STAGING_DIR_TARGET}${target_exec_prefix} \
> -		      --with-gxx-include-dir=${target_includedir}/c++ \
> +		      --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++ \
>                        --with-sysroot=${STAGING_DIR_TARGET} \
>                        --with-build-sysroot=${STAGING_DIR_TARGET}"
>  
> diff --git a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
> index 34bfaeb..3b440ff 100644
> --- a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
> +++ b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
> @@ -4,7 +4,7 @@ CXXFLAGS := "${@oe_filter_out('-fvisibility-inlines-hidden', '${CXXFLAGS}', d)}"
>  
>  EXTRA_OECONF_PATHS = " \
>      --with-local-prefix=${STAGING_DIR_TARGET}${prefix} \
> -    --with-gxx-include-dir=${includedir}/c++/ \
> +    --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++/ \
>      --with-sysroot=${STAGING_DIR_TARGET} \
>      --with-build-sysroot=${STAGING_DIR_TARGET}"
>  
> diff --git a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
> index f130b47..eb6757c 100644
> --- a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
> +++ b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
> @@ -5,7 +5,7 @@ USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibc", "no", "", d )}'
>  USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibceabi", "no", "", d )}'
>  
>  EXTRA_OECONF_PATHS = "--with-local-prefix=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_exec_prefix} \
> -                      --with-gxx-include-dir=${target_includedir}/c++ \
> +                      --with-gxx-include-dir=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_includedir}/c++ \
>                        --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
>                        --with-sysroot=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS} \
>                        --with-build-sysroot=${STAGING_DIR_TARGET}"
Khem Raj - Dec. 14, 2011, 3:49 p.m.
On Wed, Dec 14, 2011 at 2:02 AM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> Hi Khem,
>
> What's puzzling me is that reading through this patch, we already do
> what this patch is doing?
>
> Where is the difference which this patch is fixing?
>

this does essentially what we were doing earlier but this one is going
to go upstream

> I appreciate that patch adds in the prefix to the --with-gxx-include-dir
> option but it then removes it again during configure so this should be a
> null op. Both versions of the patch set the "1" bit in gcc/cppdefault.c.
>
> So where is the change this patch makes which fixes things?

changing --with-gxx-include-dir to be within sysroot triggers the
relocation code.

>
> Cheers,
>
> Richard
>
>
>
> On Wed, 2011-12-14 at 00:28 -0800, Khem Raj wrote:
>> Currently we have a problem in our cross compiler since we use
>> /usr/include/c++ to be default gxx-include-dir and then expect
>> the patch we did to do the relocation w.r.t. sysroot however it
>> does not quite work so and we end up gxx-include-dirs not respecting
>> sysroot. A small test case would be
>>
>> tst-unique4.cc
>>
>> and it would fails like
>>
>> tst-unique4.cc:1:18: fatal error: cstdio: No such file or directory
>> compilation terminated.
>>
>> weather we use --sysroot or not it does not matter
>>
>> arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
>> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
>>
>> failed in same way.
>>
>> so we redo the GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch based on upstream
>> submitted patch which tries to relocate the gxx-include-dir and to
>> achieve the relocation it has to be specified w.r.t to --with-sysroot
>> directory. e.g.
>>
>> --with-sysroot=${SYSROOT}
>> --with-gxx-include-dir=${SYSROOT}/usr/include/c++
>>
>> if we configure gcc like above then it becomes relocatable when
>> we run the compiler and specify --sysroot=<blah> then g++ will search
>> for gxx-headers under <blah>/usr/include/c++
>>
>> if sysroot is not defined then it will use the default sysroot
>> and gxx-include-dir will be w.r.t. default sysroot.
>>
>> Tested on qemuarm
>>
>> /arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
>> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
>> -v
>> ...
>>  /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++
>>  /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/arm-oe-linux-gnueabi
>>  /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/backward
>> ...
>>
>> and if I now change --sysroot to something else
>>
>> /arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
>> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4
>> -v
>> ...
>>
>> ignoring nonexistent directory
>> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++"
>> ignoring nonexistent directory
>> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/arm-oe-linux-gnueabi"
>> ignoring nonexistent directory
>> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/backward"
>> ...
>>
>> See now its looking for them in 'qemuarm4' sysroot
>>
>> Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> ---
>>  meta/recipes-devtools/gcc/gcc-4.6.inc              |    4 +-
>>  .../GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch       |  189 ++++++++++++++++++--
>>  meta/recipes-devtools/gcc/gcc-configure-cross.inc  |    2 +-
>>  .../recipes-devtools/gcc/gcc-configure-runtime.inc |    2 +-
>>  meta/recipes-devtools/gcc/gcc-configure-sdk.inc    |    2 +-
>>  5 files changed, 175 insertions(+), 24 deletions(-)
>>
>> diff --git a/meta/recipes-devtools/gcc/gcc-4.6.inc b/meta/recipes-devtools/gcc/gcc-4.6.inc
>> index 18e0536..4bbb2d2 100644
>> --- a/meta/recipes-devtools/gcc/gcc-4.6.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-4.6.inc
>> @@ -1,6 +1,6 @@
>>  require gcc-common.inc
>>
>> -PR = "r19"
>> +PR = "r20"
>>
>>  # Third digit in PV should be incremented after a minor release
>>  # happens from this branch on gcc e.g. currently its 4.6.0
>> @@ -62,7 +62,6 @@ SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \
>>          file://64bithack.patch \
>>          file://optional_libstdc.patch \
>>          file://disable_relax_pic_calls_flag.patch \
>> -        file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \
>>          file://COLLECT_GCC_OPTIONS.patch \
>>             file://volatile_access_backport.patch \
>>             file://use-defaults.h-and-t-oe-in-B.patch \
>> @@ -73,6 +72,7 @@ SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \
>>          file://pr32219.patch \
>>          file://pr47551.patch \
>>          file://gcc-arm-set-cost.patch \
>> +        file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \
>>         "
>>
>>  SRC_URI_append_sh3  = " file://sh3-installfix-fixheaders.patch "
>> diff --git a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
>> index 05b2fa9..6ccbeea 100644
>> --- a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
>> +++ b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
>> @@ -1,35 +1,186 @@
>> -Upstream-Status: Pending
>> -
>> -# by default c++ include directories are not relative to "--sysroot"
>> -# which brings one trouble when using the toolchain in an environment
>> -# where the build directory generating that toolchain doesn't exist,
>> -# e.g. in sstate, machine specific sysroot and relocatable SDK
>> -# toolchain. This patch now enables c++ include paths under sysroot.
>> -# This way it's enough as long as "--sysroot" is correctly enabled
>> -# in the new environment.
>> -#
>> -# Signed-off-by Kevin Tian <kevin.tian@intel.com>, 2010-12-30
>> -
>> -Index: gcc-4.6.0/gcc/cppdefault.c
>> +source: http://patchwork.ozlabs.org/patch/129800/
>> +Upstream-Status: Submitted
>> +
>> +ChangeLog
>> +        * Makefile.in (gcc_gxx_include_dir_add_sysroot): New.
>> +          (PREPROCESSOR_DEFINES): Define GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT.
>> +
>> +        * cppdefault.c (cpp_include_defaults): replace hard coded "1" with
>> +          GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT for "add_sysroot" field.
>> +
>> +        * configure.ac (AC_SUBST): Add gcc_gxx_include_dir_add_sysroot to
>> +          control whether sysroot should be prepended to gxx include dir.
>> +
>> +        * configure: Regenerate.
>> +
>> +Hi, this is a follow up for issue "http://codereview.appspot.com/4641076".
>> +
>> +The rationale for the patch copied from previous thread:
>> +=======================================
>> +The setup:
>> +
>> +Configuring a toolchain targeting x86-64 GNU Linux (Ubuntu Lucid), as a
>> +cross-compiler.  Using a sysroot to provide the Lucid headers+libraries,
>> +with the sysroot path being within the GCC install tree.  Want to use the
>> +Lucid system libstdc++ and headers, which means that I'm not
>> +building/installing libstdc++-v3.
>> +
>> +So, configuring with:
>> +  --with-sysroot="$SYSROOT"
>> +  --disable-libstdc++-v3 \
>> +  --with-gxx-include-dir="$SYSROOT/usr/include/c++/4.4" \
>> +(among other options).
>> +
>> +Hoping to support two usage models with this configuration, w.r.t. use of
>> +the sysroot:
>> +
>> +(1) somebody installs the sysroot in the normal location relative to the
>> +GCC install, and relocates the whole bundle (sysroot+GCC).  This works
>> +great AFAICT, GCC finds its includes (including the C++ includes) thanks
>> +to the add_standard_paths iprefix handling.
>> +
>> +(2) somebody installs the sysroot in a non-standard location, and uses
>> +--sysroot to try to access it.  This works fine for the C headers, but
>> +doesn't work.
>> +
>> +For the C headers, add_standard_paths prepends the sysroot location to
>> +the /usr/include path (since that's what's specified in cppdefault.c for
>> +that path).  It doesn't do the same for the C++ include path, though
>> +(again, as specified in cppdefault.c).
>> +
>> +add_standard_paths doesn't attempt to relocate built-in include paths that
>> +start with the compiled-in sysroot location (e.g., the g++ include dir, in
>> +this case).  This isn't surprising really: normally you either prepend the
>> +sysroot location or you don't (as specified by cppdefault.c); none of the
>> +built-in paths normally *start* with the sysroot location and need to be
>> +relocated.  However, in this odd-ball case of trying to use the C++ headers
>> +from the sysroot, one of the paths *does* need to be relocated in this way.
>> +===========================
>> +Index: gcc-4_6-branch/gcc/Makefile.in
>> +===================================================================
>> +--- gcc-4_6-branch.orig/gcc/Makefile.in      2011-12-13 22:52:15.000000000 -0800
>> ++++ gcc-4_6-branch/gcc/Makefile.in   2011-12-13 22:52:21.933635767 -0800
>> +@@ -587,6 +587,7 @@
>> + build_tooldir = $(exec_prefix)/$(target_noncanonical)
>> + # Directory in which the compiler finds target-independent g++ includes.
>> + gcc_gxx_include_dir = @gcc_gxx_include_dir@
>> ++gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@
>> + # Directory to search for site-specific includes.
>> + local_includedir = $(local_prefix)/include
>> + includedir = $(prefix)/include
>> +@@ -3964,6 +3965,7 @@
>> +   -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
>> +   -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
>> +   -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
>> ++  -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
>> +   -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
>> +   -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
>> +   -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
>> +Index: gcc-4_6-branch/gcc/configure.ac
>>  ===================================================================
>> ---- gcc-4.6.0.orig/gcc/cppdefault.c
>> -+++ gcc-4.6.0/gcc/cppdefault.c
>> -@@ -48,15 +48,15 @@ const struct default_include cpp_include
>> +--- gcc-4_6-branch.orig/gcc/configure.ac     2011-12-13 22:52:15.000000000 -0800
>> ++++ gcc-4_6-branch/gcc/configure.ac  2011-12-13 22:52:21.937635526 -0800
>> +@@ -144,6 +144,15 @@
>> +   fi
>> + fi
>> +
>> ++gcc_gxx_include_dir_add_sysroot=0
>> ++if test "${with_sysroot+set}" = set; then :
>> ++  gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
>> ++  if test "${gcc_gxx_without_sysroot}"; then :
>> ++    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
>> ++    gcc_gxx_include_dir_add_sysroot=1
>> ++  fi
>> ++fi
>> ++
>> + AC_ARG_WITH(cpp_install_dir,
>> + [  --with-cpp-install-dir=DIR
>> +                           install the user visible C preprocessor in DIR
>> +@@ -4737,6 +4746,7 @@
>> + AC_SUBST(float_h_file)
>> + AC_SUBST(gcc_config_arguments)
>> + AC_SUBST(gcc_gxx_include_dir)
>> ++AC_SUBST(gcc_gxx_include_dir_add_sysroot)
>> + AC_SUBST(host_exeext)
>> + AC_SUBST(host_xm_file_list)
>> + AC_SUBST(host_xm_include_list)
>> +Index: gcc-4_6-branch/gcc/cppdefault.c
>> +===================================================================
>> +--- gcc-4_6-branch.orig/gcc/cppdefault.c     2011-12-13 22:51:28.000000000 -0800
>> ++++ gcc-4_6-branch/gcc/cppdefault.c  2011-12-13 22:52:21.937635526 -0800
>> +@@ -48,15 +48,18 @@
>>   = {
>>   #ifdef GPLUSPLUS_INCLUDE_DIR
>>       /* Pick up GNU C++ generic include files.  */
>>  -    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
>> -+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 },
>> ++    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
>> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
>>   #endif
>>   #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
>>       /* Pick up GNU C++ target-dependent include files.  */
>>  -    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 1 },
>> -+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 1, 1 },
>> ++    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
>> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
>>   #endif
>>   #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
>>       /* Pick up GNU C++ backward and deprecated include files.  */
>>  -    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
>> -+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 1, 0 },
>> ++    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
>> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
>>   #endif
>>   #ifdef GCC_INCLUDE_DIR
>>       /* This is the dir for gcc's private headers.  */
>> +Index: gcc-4_6-branch/gcc/configure
>> +===================================================================
>> +--- gcc-4_6-branch.orig/gcc/configure        2011-12-13 22:52:15.000000000 -0800
>> ++++ gcc-4_6-branch/gcc/configure     2011-12-13 22:52:33.185690436 -0800
>> +@@ -636,6 +636,7 @@
>> + host_xm_include_list
>> + host_xm_file_list
>> + host_exeext
>> ++gcc_gxx_include_dir_add_sysroot
>> + gcc_gxx_include_dir
>> + gcc_config_arguments
>> + float_h_file
>> +@@ -3313,6 +3314,15 @@
>> +   fi
>> + fi
>> +
>> ++gcc_gxx_include_dir_add_sysroot=0
>> ++if test "${with_sysroot+set}" = set; then :
>> ++  gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
>> ++  if test "${gcc_gxx_without_sysroot}"; then :
>> ++    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
>> ++    gcc_gxx_include_dir_add_sysroot=1
>> ++  fi
>> ++fi
>> ++
>> +
>> + # Check whether --with-cpp_install_dir was given.
>> + if test "${with_cpp_install_dir+set}" = set; then :
>> +@@ -17514,7 +17524,7 @@
>> +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>> +   lt_status=$lt_dlunknown
>> +   cat > conftest.$ac_ext <<_LT_EOF
>> +-#line 17517 "configure"
>> ++#line 17527 "configure"
>> + #include "confdefs.h"
>> +
>> + #if HAVE_DLFCN_H
>> +@@ -17620,7 +17630,7 @@
>> +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>> +   lt_status=$lt_dlunknown
>> +   cat > conftest.$ac_ext <<_LT_EOF
>> +-#line 17623 "configure"
>> ++#line 17633 "configure"
>> + #include "confdefs.h"
>> +
>> + #if HAVE_DLFCN_H
>> +@@ -26151,6 +26161,7 @@
>> +
>> +
>> +
>> ++
>> +
>> +
>> +
>> diff --git a/meta/recipes-devtools/gcc/gcc-configure-cross.inc b/meta/recipes-devtools/gcc/gcc-configure-cross.inc
>> index d2d9081..5816768 100644
>> --- a/meta/recipes-devtools/gcc/gcc-configure-cross.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-configure-cross.inc
>> @@ -10,7 +10,7 @@ EXTRA_OECONF += " --enable-poison-system-directories \
>>  INHIBIT_DEFAULT_DEPS = "1"
>>
>>  EXTRA_OECONF_PATHS = "--with-local-prefix=${STAGING_DIR_TARGET}${target_exec_prefix} \
>> -                   --with-gxx-include-dir=${target_includedir}/c++ \
>> +                   --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++ \
>>                        --with-sysroot=${STAGING_DIR_TARGET} \
>>                        --with-build-sysroot=${STAGING_DIR_TARGET}"
>>
>> diff --git a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
>> index 34bfaeb..3b440ff 100644
>> --- a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
>> @@ -4,7 +4,7 @@ CXXFLAGS := "${@oe_filter_out('-fvisibility-inlines-hidden', '${CXXFLAGS}', d)}"
>>
>>  EXTRA_OECONF_PATHS = " \
>>      --with-local-prefix=${STAGING_DIR_TARGET}${prefix} \
>> -    --with-gxx-include-dir=${includedir}/c++/ \
>> +    --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++/ \
>>      --with-sysroot=${STAGING_DIR_TARGET} \
>>      --with-build-sysroot=${STAGING_DIR_TARGET}"
>>
>> diff --git a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
>> index f130b47..eb6757c 100644
>> --- a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
>> @@ -5,7 +5,7 @@ USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibc", "no", "", d )}'
>>  USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibceabi", "no", "", d )}'
>>
>>  EXTRA_OECONF_PATHS = "--with-local-prefix=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_exec_prefix} \
>> -                      --with-gxx-include-dir=${target_includedir}/c++ \
>> +                      --with-gxx-include-dir=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_includedir}/c++ \
>>                        --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
>>                        --with-sysroot=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS} \
>>                        --with-build-sysroot=${STAGING_DIR_TARGET}"
>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Ulf Samuelsson - Dec. 14, 2011, 6:08 p.m.
On 2011-12-14 11:02, Richard Purdie wrote:
> Hi Khem,
>
> What's puzzling me is that reading through this patch, we already do
> what this patch is doing?
>
> Where is the difference which this patch is fixing?
>
> I appreciate that patch adds in the prefix to the --with-gxx-include-dir
> option but it then removes it again during configure so this should be a
> null op. Both versions of the patch set the "1" bit in gcc/cppdefault.c.
>
> So where is the change this patch makes which fixes things?
>
> Cheers,
>
> Richard
>
Not familiar with gcc internals, but just want to reiterate the point
that the problem occured (the one I saw) only when I had
BB_NUMBER_THREADS at a high value, so WHEN things
are done seems to be important.

BR
Ulf


> On Wed, 2011-12-14 at 00:28 -0800, Khem Raj wrote:
>> Currently we have a problem in our cross compiler since we use
>> /usr/include/c++ to be default gxx-include-dir and then expect
>> the patch we did to do the relocation w.r.t. sysroot however it
>> does not quite work so and we end up gxx-include-dirs not respecting
>> sysroot. A small test case would be
>>
>> tst-unique4.cc
>>
>> and it would fails like
>>
>> tst-unique4.cc:1:18: fatal error: cstdio: No such file or directory
>> compilation terminated.
>>
>> weather we use --sysroot or not it does not matter
>>
>> arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
>> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
>>
>> failed in same way.
>>
>> so we redo the GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch based on upstream
>> submitted patch which tries to relocate the gxx-include-dir and to
>> achieve the relocation it has to be specified w.r.t to --with-sysroot
>> directory. e.g.
>>
>> --with-sysroot=${SYSROOT}
>> --with-gxx-include-dir=${SYSROOT}/usr/include/c++
>>
>> if we configure gcc like above then it becomes relocatable when
>> we run the compiler and specify --sysroot=<blah>  then g++ will search
>> for gxx-headers under<blah>/usr/include/c++
>>
>> if sysroot is not defined then it will use the default sysroot
>> and gxx-include-dir will be w.r.t. default sysroot.
>>
>> Tested on qemuarm
>>
>> /arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
>> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
>> -v
>> ...
>>   /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++
>>   /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/arm-oe-linux-gnueabi
>>   /home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/backward
>> ...
>>
>> and if I now change --sysroot to something else
>>
>> /arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
>> --sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4
>> -v
>> ...
>>
>> ignoring nonexistent directory
>> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++"
>> ignoring nonexistent directory
>> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/arm-oe-linux-gnueabi"
>> ignoring nonexistent directory
>> "/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/backward"
>> ...
>>
>> See now its looking for them in 'qemuarm4' sysroot
>>
>> Signed-off-by: Khem Raj<raj.khem@gmail.com>
>> ---
>>   meta/recipes-devtools/gcc/gcc-4.6.inc              |    4 +-
>>   .../GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch       |  189 ++++++++++++++++++--
>>   meta/recipes-devtools/gcc/gcc-configure-cross.inc  |    2 +-
>>   .../recipes-devtools/gcc/gcc-configure-runtime.inc |    2 +-
>>   meta/recipes-devtools/gcc/gcc-configure-sdk.inc    |    2 +-
>>   5 files changed, 175 insertions(+), 24 deletions(-)
>>
>> diff --git a/meta/recipes-devtools/gcc/gcc-4.6.inc b/meta/recipes-devtools/gcc/gcc-4.6.inc
>> index 18e0536..4bbb2d2 100644
>> --- a/meta/recipes-devtools/gcc/gcc-4.6.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-4.6.inc
>> @@ -1,6 +1,6 @@
>>   require gcc-common.inc
>>
>> -PR = "r19"
>> +PR = "r20"
>>
>>   # Third digit in PV should be incremented after a minor release
>>   # happens from this branch on gcc e.g. currently its 4.6.0
>> @@ -62,7 +62,6 @@ SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \
>>   	   file://64bithack.patch \
>>   	   file://optional_libstdc.patch \
>>   	   file://disable_relax_pic_calls_flag.patch \
>> -	   file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \
>>   	   file://COLLECT_GCC_OPTIONS.patch \
>>              file://volatile_access_backport.patch \
>>              file://use-defaults.h-and-t-oe-in-B.patch \
>> @@ -73,6 +72,7 @@ SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \
>>   	   file://pr32219.patch \
>>   	   file://pr47551.patch \
>>   	   file://gcc-arm-set-cost.patch \
>> +	   file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \
>>   	  "
>>
>>   SRC_URI_append_sh3  = " file://sh3-installfix-fixheaders.patch "
>> diff --git a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
>> index 05b2fa9..6ccbeea 100644
>> --- a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
>> +++ b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
>> @@ -1,35 +1,186 @@
>> -Upstream-Status: Pending
>> -
>> -# by default c++ include directories are not relative to "--sysroot"
>> -# which brings one trouble when using the toolchain in an environment
>> -# where the build directory generating that toolchain doesn't exist,
>> -# e.g. in sstate, machine specific sysroot and relocatable SDK
>> -# toolchain. This patch now enables c++ include paths under sysroot.
>> -# This way it's enough as long as "--sysroot" is correctly enabled
>> -# in the new environment.
>> -#
>> -# Signed-off-by Kevin Tian<kevin.tian@intel.com>, 2010-12-30
>> -
>> -Index: gcc-4.6.0/gcc/cppdefault.c
>> +source: http://patchwork.ozlabs.org/patch/129800/
>> +Upstream-Status: Submitted
>> +
>> +ChangeLog
>> +        * Makefile.in (gcc_gxx_include_dir_add_sysroot): New.
>> +          (PREPROCESSOR_DEFINES): Define GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT.
>> +
>> +        * cppdefault.c (cpp_include_defaults): replace hard coded "1" with
>> +          GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT for "add_sysroot" field.
>> +
>> +        * configure.ac (AC_SUBST): Add gcc_gxx_include_dir_add_sysroot to
>> +          control whether sysroot should be prepended to gxx include dir.
>> +
>> +        * configure: Regenerate.
>> +
>> +Hi, this is a follow up for issue "http://codereview.appspot.com/4641076".
>> +
>> +The rationale for the patch copied from previous thread:
>> +=======================================
>> +The setup:
>> +
>> +Configuring a toolchain targeting x86-64 GNU Linux (Ubuntu Lucid), as a
>> +cross-compiler.  Using a sysroot to provide the Lucid headers+libraries,
>> +with the sysroot path being within the GCC install tree.  Want to use the
>> +Lucid system libstdc++ and headers, which means that I'm not
>> +building/installing libstdc++-v3.
>> +
>> +So, configuring with:
>> +  --with-sysroot="$SYSROOT"
>> +  --disable-libstdc++-v3 \
>> +  --with-gxx-include-dir="$SYSROOT/usr/include/c++/4.4" \
>> +(among other options).
>> +
>> +Hoping to support two usage models with this configuration, w.r.t. use of
>> +the sysroot:
>> +
>> +(1) somebody installs the sysroot in the normal location relative to the
>> +GCC install, and relocates the whole bundle (sysroot+GCC).  This works
>> +great AFAICT, GCC finds its includes (including the C++ includes) thanks
>> +to the add_standard_paths iprefix handling.
>> +
>> +(2) somebody installs the sysroot in a non-standard location, and uses
>> +--sysroot to try to access it.  This works fine for the C headers, but
>> +doesn't work.
>> +
>> +For the C headers, add_standard_paths prepends the sysroot location to
>> +the /usr/include path (since that's what's specified in cppdefault.c for
>> +that path).  It doesn't do the same for the C++ include path, though
>> +(again, as specified in cppdefault.c).
>> +
>> +add_standard_paths doesn't attempt to relocate built-in include paths that
>> +start with the compiled-in sysroot location (e.g., the g++ include dir, in
>> +this case).  This isn't surprising really: normally you either prepend the
>> +sysroot location or you don't (as specified by cppdefault.c); none of the
>> +built-in paths normally *start* with the sysroot location and need to be
>> +relocated.  However, in this odd-ball case of trying to use the C++ headers
>> +from the sysroot, one of the paths *does* need to be relocated in this way.
>> +===========================
>> +Index: gcc-4_6-branch/gcc/Makefile.in
>> +===================================================================
>> +--- gcc-4_6-branch.orig/gcc/Makefile.in	2011-12-13 22:52:15.000000000 -0800
>> ++++ gcc-4_6-branch/gcc/Makefile.in	2011-12-13 22:52:21.933635767 -0800
>> +@@ -587,6 +587,7 @@
>> + build_tooldir = $(exec_prefix)/$(target_noncanonical)
>> + # Directory in which the compiler finds target-independent g++ includes.
>> + gcc_gxx_include_dir = @gcc_gxx_include_dir@
>> ++gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@
>> + # Directory to search for site-specific includes.
>> + local_includedir = $(local_prefix)/include
>> + includedir = $(prefix)/include
>> +@@ -3964,6 +3965,7 @@
>> +   -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
>> +   -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
>> +   -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
>> ++  -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
>> +   -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
>> +   -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
>> +   -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
>> +Index: gcc-4_6-branch/gcc/configure.ac
>>   ===================================================================
>> ---- gcc-4.6.0.orig/gcc/cppdefault.c
>> -+++ gcc-4.6.0/gcc/cppdefault.c
>> -@@ -48,15 +48,15 @@ const struct default_include cpp_include
>> +--- gcc-4_6-branch.orig/gcc/configure.ac	2011-12-13 22:52:15.000000000 -0800
>> ++++ gcc-4_6-branch/gcc/configure.ac	2011-12-13 22:52:21.937635526 -0800
>> +@@ -144,6 +144,15 @@
>> +   fi
>> + fi
>> +
>> ++gcc_gxx_include_dir_add_sysroot=0
>> ++if test "${with_sysroot+set}" = set; then :
>> ++  gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
>> ++  if test "${gcc_gxx_without_sysroot}"; then :
>> ++    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
>> ++    gcc_gxx_include_dir_add_sysroot=1
>> ++  fi
>> ++fi
>> ++
>> + AC_ARG_WITH(cpp_install_dir,
>> + [  --with-cpp-install-dir=DIR
>> +                           install the user visible C preprocessor in DIR
>> +@@ -4737,6 +4746,7 @@
>> + AC_SUBST(float_h_file)
>> + AC_SUBST(gcc_config_arguments)
>> + AC_SUBST(gcc_gxx_include_dir)
>> ++AC_SUBST(gcc_gxx_include_dir_add_sysroot)
>> + AC_SUBST(host_exeext)
>> + AC_SUBST(host_xm_file_list)
>> + AC_SUBST(host_xm_include_list)
>> +Index: gcc-4_6-branch/gcc/cppdefault.c
>> +===================================================================
>> +--- gcc-4_6-branch.orig/gcc/cppdefault.c	2011-12-13 22:51:28.000000000 -0800
>> ++++ gcc-4_6-branch/gcc/cppdefault.c	2011-12-13 22:52:21.937635526 -0800
>> +@@ -48,15 +48,18 @@
>>    = {
>>    #ifdef GPLUSPLUS_INCLUDE_DIR
>>        /* Pick up GNU C++ generic include files.  */
>>   -    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
>> -+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 },
>> ++    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
>> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
>>    #endif
>>    #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
>>        /* Pick up GNU C++ target-dependent include files.  */
>>   -    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 1 },
>> -+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 1, 1 },
>> ++    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
>> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
>>    #endif
>>    #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
>>        /* Pick up GNU C++ backward and deprecated include files.  */
>>   -    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
>> -+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 1, 0 },
>> ++    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
>> ++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
>>    #endif
>>    #ifdef GCC_INCLUDE_DIR
>>        /* This is the dir for gcc's private headers.  */
>> +Index: gcc-4_6-branch/gcc/configure
>> +===================================================================
>> +--- gcc-4_6-branch.orig/gcc/configure	2011-12-13 22:52:15.000000000 -0800
>> ++++ gcc-4_6-branch/gcc/configure	2011-12-13 22:52:33.185690436 -0800
>> +@@ -636,6 +636,7 @@
>> + host_xm_include_list
>> + host_xm_file_list
>> + host_exeext
>> ++gcc_gxx_include_dir_add_sysroot
>> + gcc_gxx_include_dir
>> + gcc_config_arguments
>> + float_h_file
>> +@@ -3313,6 +3314,15 @@
>> +   fi
>> + fi
>> +
>> ++gcc_gxx_include_dir_add_sysroot=0
>> ++if test "${with_sysroot+set}" = set; then :
>> ++  gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
>> ++  if test "${gcc_gxx_without_sysroot}"; then :
>> ++    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
>> ++    gcc_gxx_include_dir_add_sysroot=1
>> ++  fi
>> ++fi
>> ++
>> +
>> + # Check whether --with-cpp_install_dir was given.
>> + if test "${with_cpp_install_dir+set}" = set; then :
>> +@@ -17514,7 +17524,7 @@
>> +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>> +   lt_status=$lt_dlunknown
>> +   cat>  conftest.$ac_ext<<_LT_EOF
>> +-#line 17517 "configure"
>> ++#line 17527 "configure"
>> + #include "confdefs.h"
>> +
>> + #if HAVE_DLFCN_H
>> +@@ -17620,7 +17630,7 @@
>> +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>> +   lt_status=$lt_dlunknown
>> +   cat>  conftest.$ac_ext<<_LT_EOF
>> +-#line 17623 "configure"
>> ++#line 17633 "configure"
>> + #include "confdefs.h"
>> +
>> + #if HAVE_DLFCN_H
>> +@@ -26151,6 +26161,7 @@
>> +
>> +
>> +
>> ++
>> +
>> +
>> +
>> diff --git a/meta/recipes-devtools/gcc/gcc-configure-cross.inc b/meta/recipes-devtools/gcc/gcc-configure-cross.inc
>> index d2d9081..5816768 100644
>> --- a/meta/recipes-devtools/gcc/gcc-configure-cross.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-configure-cross.inc
>> @@ -10,7 +10,7 @@ EXTRA_OECONF += " --enable-poison-system-directories \
>>   INHIBIT_DEFAULT_DEPS = "1"
>>
>>   EXTRA_OECONF_PATHS = "--with-local-prefix=${STAGING_DIR_TARGET}${target_exec_prefix} \
>> -		      --with-gxx-include-dir=${target_includedir}/c++ \
>> +		      --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++ \
>>                         --with-sysroot=${STAGING_DIR_TARGET} \
>>                         --with-build-sysroot=${STAGING_DIR_TARGET}"
>>
>> diff --git a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
>> index 34bfaeb..3b440ff 100644
>> --- a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
>> @@ -4,7 +4,7 @@ CXXFLAGS := "${@oe_filter_out('-fvisibility-inlines-hidden', '${CXXFLAGS}', d)}"
>>
>>   EXTRA_OECONF_PATHS = " \
>>       --with-local-prefix=${STAGING_DIR_TARGET}${prefix} \
>> -    --with-gxx-include-dir=${includedir}/c++/ \
>> +    --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++/ \
>>       --with-sysroot=${STAGING_DIR_TARGET} \
>>       --with-build-sysroot=${STAGING_DIR_TARGET}"
>>
>> diff --git a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
>> index f130b47..eb6757c 100644
>> --- a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
>> @@ -5,7 +5,7 @@ USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibc", "no", "", d )}'
>>   USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibceabi", "no", "", d )}'
>>
>>   EXTRA_OECONF_PATHS = "--with-local-prefix=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_exec_prefix} \
>> -                      --with-gxx-include-dir=${target_includedir}/c++ \
>> +                      --with-gxx-include-dir=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_includedir}/c++ \
>>                         --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
>>                         --with-sysroot=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS} \
>>                         --with-build-sysroot=${STAGING_DIR_TARGET}"
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Khem Raj - Dec. 14, 2011, 6:38 p.m.
On Wed, Dec 14, 2011 at 10:08 AM, Ulf Samuelsson
<openembedded-core@emagii.com> wrote:
>>
>>
> Not familiar with gcc internals, but just want to reiterate the point
> that the problem occured (the one I saw) only when I had
> BB_NUMBER_THREADS at a high value, so WHEN things
> are done seems to be important.

could you test out this patch in your configuration and see if you
still see the problem ?
Richard Purdie - Dec. 15, 2011, 12:16 p.m.
On Wed, 2011-12-14 at 07:49 -0800, Khem Raj wrote:
> On Wed, Dec 14, 2011 at 2:02 AM, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > Hi Khem,
> >
> > What's puzzling me is that reading through this patch, we already do
> > what this patch is doing?
> >
> > Where is the difference which this patch is fixing?
> >
> 
> this does essentially what we were doing earlier but this one is going
> to go upstream

Yes, that is good and I'm fine with the patch for that reason.

> 
> > I appreciate that patch adds in the prefix to the --with-gxx-include-dir
> > option but it then removes it again during configure so this should be a
> > null op. Both versions of the patch set the "1" bit in gcc/cppdefault.c.
> >
> > So where is the change this patch makes which fixes things?
> 
> changing --with-gxx-include-dir to be within sysroot triggers the
> relocation code.

But we were already triggering the relocation code?

I can't see *any* functionality difference between these, they should
both just give the same result as far as I can tell...

Claiming it fixes things is therefore concerning me.

Cheers,

Richard
Khem Raj - Dec. 16, 2011, 9:24 p.m.
On (15/12/11 12:16), Richard Purdie wrote:
> On Wed, 2011-12-14 at 07:49 -0800, Khem Raj wrote:
> > On Wed, Dec 14, 2011 at 2:02 AM, Richard Purdie
> > <richard.purdie@linuxfoundation.org> wrote:
> > > Hi Khem,
> > >
> > > What's puzzling me is that reading through this patch, we already do
> > > what this patch is doing?
> > >
> > > Where is the difference which this patch is fixing?
> > >
> > 
> > this does essentially what we were doing earlier but this one is going
> > to go upstream
> 
> Yes, that is good and I'm fine with the patch for that reason.

there is additional detail that this patch does which is that in order
to make gxx-includes to be sysroot relative --with-cxx-include option to
be also specified relative to initials sysroot during configure time

e.g. --with-sysroot=SYSROOT --with-gxx-include-dir=SYSROOT/usr/include/c++

since the original behavior of --with-gxx-include-dir is to specify an
absolute path that is preserved whereas the patch we have in OE relocates
gxx-include-dir regardless.Therefore in order to adopt this patch we have
to use the above syntax which was original syntax before the above patch
and would make up forward compatible provided this patch makes into gcc
upstream.

> 
> > 
> > > I appreciate that patch adds in the prefix to the --with-gxx-include-dir
> > > option but it then removes it again during configure so this should be a
> > > null op. Both versions of the patch set the "1" bit in gcc/cppdefault.c.
> > >
> > > So where is the change this patch makes which fixes things?
> > 
> > changing --with-gxx-include-dir to be within sysroot triggers the
> > relocation code.
> 
> But we were already triggering the relocation code?
> 
> I can't see *any* functionality difference between these, they should
> both just give the same result as far as I can tell...
> 
same functionality but with a different usage see above

> Claiming it fixes things is therefore concerning me.

correct it does not fix anything actually that I know was broken before
Thinking out loud given that with-gxx-include-dir is absolute in nature it could be
the original patch we have, does not work in some weird case since the
absolute path we use is still /usr/include/c++ during configure time.
although I would expect that the include poisoning warning will report it if that
happened

-Khem
Eric BENARD - Dec. 20, 2011, 6:36 a.m.
Hi, Khem,

Le 14/12/2011 19:38, Khem Raj a écrit :
> On Wed, Dec 14, 2011 at 10:08 AM, Ulf Samuelsson
> <openembedded-core@emagii.com>  wrote:
>>>
>>>
>> Not familiar with gcc internals, but just want to reiterate the point
>> that the problem occured (the one I saw) only when I had
>> BB_NUMBER_THREADS at a high value, so WHEN things are done seems to be
>> important.
>
Seems more complicated than this. A customeer reproduced it with BB_THREAD=2
and PARALLEL=j3 ... (I never reproduced in with BB_THREAD < 5)

> could you test out this patch in your configuration and see if you still
> see the problem ?
>
I reproduced the problem with this patch and BB_THREAD=8 so this patch doesn't
improve the current behaviour.

Eric
Martin Jansa - Dec. 20, 2011, 9:07 a.m.
On Fri, Dec 16, 2011 at 01:24:24PM -0800, Khem Raj wrote:
> On (15/12/11 12:16), Richard Purdie wrote:
> > On Wed, 2011-12-14 at 07:49 -0800, Khem Raj wrote:
> > > On Wed, Dec 14, 2011 at 2:02 AM, Richard Purdie
> > > <richard.purdie@linuxfoundation.org> wrote:
> > > > Hi Khem,
> > > >
> > > > What's puzzling me is that reading through this patch, we already do
> > > > what this patch is doing?
> > > >
> > > > Where is the difference which this patch is fixing?
> > > >
> > > 
> > > this does essentially what we were doing earlier but this one is going
> > > to go upstream
> > 
> > Yes, that is good and I'm fine with the patch for that reason.
> 
> there is additional detail that this patch does which is that in order
> to make gxx-includes to be sysroot relative --with-cxx-include option to
> be also specified relative to initials sysroot during configure time
> 
> e.g. --with-sysroot=SYSROOT --with-gxx-include-dir=SYSROOT/usr/include/c++
> 
> since the original behavior of --with-gxx-include-dir is to specify an
> absolute path that is preserved whereas the patch we have in OE relocates
> gxx-include-dir regardless.Therefore in order to adopt this patch we have
> to use the above syntax which was original syntax before the above patch
> and would make up forward compatible provided this patch makes into gcc
> upstream.
> 
> > 
> > > 
> > > > I appreciate that patch adds in the prefix to the --with-gxx-include-dir
> > > > option but it then removes it again during configure so this should be a
> > > > null op. Both versions of the patch set the "1" bit in gcc/cppdefault.c.
> > > >
> > > > So where is the change this patch makes which fixes things?
> > > 
> > > changing --with-gxx-include-dir to be within sysroot triggers the
> > > relocation code.
> > 
> > But we were already triggering the relocation code?
> > 
> > I can't see *any* functionality difference between these, they should
> > both just give the same result as far as I can tell...
> > 
> same functionality but with a different usage see above
> 
> > Claiming it fixes things is therefore concerning me.
> 
> correct it does not fix anything actually that I know was broken before
> Thinking out loud given that with-gxx-include-dir is absolute in nature it could be
> the original patch we have, does not work in some weird case since the
> absolute path we use is still /usr/include/c++ during configure time.
> although I would expect that the include poisoning warning will report it if that
> happened
> 
> -Khem

Is there some pending patch for meta-oe/gcc?

I have some issues while rebuilding toolchain from scratch after this
patchset:

armv7a:
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/rtl.h:2163:12: note: expected 'enum machine_mode' but argument is of type 'int'
| gcc -c   -isystem/OE/shr-core/tmp-eglibc/sysroots/x86_64-linux/usr/include -O2 -pipe -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -I. -I. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../include -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libcpp/include  -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber/dpd -I../libdecnumber    /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c -o calls.o
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c: In function 'initialize_argument_information':
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c:1089:9: error: 'STACK_CHECK_MAX_VAR_SIZE' undeclared (first use in this function)
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c:1089:9: note: each undeclared identifier is reported only once for each function it appears in
| make[2]: *** [calls.o] Error 1

armv4t:
| gcc -c   -isystem/OE/shr-core/tmp-eglibc/sysroots/x86_64-linux/usr/include -O2 -pipe -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -I. -I. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../include -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libcpp/include  -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber/dpd -I../libdecnumber    insn-output.c -o insn-output.o
| In file included from insn-emit.c:23:0:
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/constraints.md: In function 'satisfies_constraint_Uu':
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/constraints.md:353:6: warning: implicit declaration of function 'thumb1_legitimate_address_p' [-Wimplicit-function-declaration]
| insn-opinit.c: In function 'init_all_optabs':
| insn-opinit.c:25:5: warning: implicit declaration of function 'set_widening_optab_handler' [-Wimplicit-function-declaration]
| insn-opinit.c:30:7: error: 'TARGET_IDIV' undeclared (first use in this function)
| insn-opinit.c:30:7: note: each undeclared identifier is reported only once for each function it appears in
| insn-opinit.c:813:32: error: 'vec_load_lanes_optab' undeclared (first use in this function)
| insn-opinit.c:833:32: error: 'vec_store_lanes_optab' undeclared (first use in this function)
| insn-opinit.c:1009:24: error: 'vec_widen_sshiftl_lo_optab' undeclared (first use in this function)
| insn-opinit.c:1011:24: error: 'vec_widen_ushiftl_lo_optab' undeclared (first use in this function)
| insn-opinit.c:1021:24: error: 'vec_widen_sshiftl_hi_optab' undeclared (first use in this function)
| insn-opinit.c:1023:24: error: 'vec_widen_ushiftl_hi_optab' undeclared (first use in this function)
| make[2]: *** [insn-opinit.o] Error 1
| make[2]: *** Waiting for unfinished jobs....

Cheers,
Martin Jansa - Dec. 20, 2011, 9:37 a.m.
On Tue, Dec 20, 2011 at 10:07:56AM +0100, Martin Jansa wrote:
> On Fri, Dec 16, 2011 at 01:24:24PM -0800, Khem Raj wrote:
> > On (15/12/11 12:16), Richard Purdie wrote:
> > > On Wed, 2011-12-14 at 07:49 -0800, Khem Raj wrote:
> > > > On Wed, Dec 14, 2011 at 2:02 AM, Richard Purdie
> > > > <richard.purdie@linuxfoundation.org> wrote:
> > > > > Hi Khem,
> > > > >
> > > > > What's puzzling me is that reading through this patch, we already do
> > > > > what this patch is doing?
> > > > >
> > > > > Where is the difference which this patch is fixing?
> > > > >
> > > > 
> > > > this does essentially what we were doing earlier but this one is going
> > > > to go upstream
> > > 
> > > Yes, that is good and I'm fine with the patch for that reason.
> > 
> > there is additional detail that this patch does which is that in order
> > to make gxx-includes to be sysroot relative --with-cxx-include option to
> > be also specified relative to initials sysroot during configure time
> > 
> > e.g. --with-sysroot=SYSROOT --with-gxx-include-dir=SYSROOT/usr/include/c++
> > 
> > since the original behavior of --with-gxx-include-dir is to specify an
> > absolute path that is preserved whereas the patch we have in OE relocates
> > gxx-include-dir regardless.Therefore in order to adopt this patch we have
> > to use the above syntax which was original syntax before the above patch
> > and would make up forward compatible provided this patch makes into gcc
> > upstream.
> > 
> > > 
> > > > 
> > > > > I appreciate that patch adds in the prefix to the --with-gxx-include-dir
> > > > > option but it then removes it again during configure so this should be a
> > > > > null op. Both versions of the patch set the "1" bit in gcc/cppdefault.c.
> > > > >
> > > > > So where is the change this patch makes which fixes things?
> > > > 
> > > > changing --with-gxx-include-dir to be within sysroot triggers the
> > > > relocation code.
> > > 
> > > But we were already triggering the relocation code?
> > > 
> > > I can't see *any* functionality difference between these, they should
> > > both just give the same result as far as I can tell...
> > > 
> > same functionality but with a different usage see above
> > 
> > > Claiming it fixes things is therefore concerning me.
> > 
> > correct it does not fix anything actually that I know was broken before
> > Thinking out loud given that with-gxx-include-dir is absolute in nature it could be
> > the original patch we have, does not work in some weird case since the
> > absolute path we use is still /usr/include/c++ during configure time.
> > although I would expect that the include poisoning warning will report it if that
> > happened
> > 
> > -Khem
> 
> Is there some pending patch for meta-oe/gcc?
> 
> I have some issues while rebuilding toolchain from scratch after this
> patchset:
> 
> armv7a:
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/rtl.h:2163:12: note: expected 'enum machine_mode' but argument is of type 'int'
> | gcc -c   -isystem/OE/shr-core/tmp-eglibc/sysroots/x86_64-linux/usr/include -O2 -pipe -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -I. -I. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../include -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libcpp/include  -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber/dpd -I../libdecnumber    /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c -o calls.o
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c: In function 'initialize_argument_information':
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c:1089:9: error: 'STACK_CHECK_MAX_VAR_SIZE' undeclared (first use in this function)
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c:1089:9: note: each undeclared identifier is reported only once for each function it appears in
> | make[2]: *** [calls.o] Error 1
> 
> armv4t:
> | gcc -c   -isystem/OE/shr-core/tmp-eglibc/sysroots/x86_64-linux/usr/include -O2 -pipe -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -I. -I. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../include -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libcpp/include  -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber/dpd -I../libdecnumber    insn-output.c -o insn-output.o
> | In file included from insn-emit.c:23:0:
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/constraints.md: In function 'satisfies_constraint_Uu':
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/constraints.md:353:6: warning: implicit declaration of function 'thumb1_legitimate_address_p' [-Wimplicit-function-declaration]
> | insn-opinit.c: In function 'init_all_optabs':
> | insn-opinit.c:25:5: warning: implicit declaration of function 'set_widening_optab_handler' [-Wimplicit-function-declaration]
> | insn-opinit.c:30:7: error: 'TARGET_IDIV' undeclared (first use in this function)
> | insn-opinit.c:30:7: note: each undeclared identifier is reported only once for each function it appears in
> | insn-opinit.c:813:32: error: 'vec_load_lanes_optab' undeclared (first use in this function)
> | insn-opinit.c:833:32: error: 'vec_store_lanes_optab' undeclared (first use in this function)
> | insn-opinit.c:1009:24: error: 'vec_widen_sshiftl_lo_optab' undeclared (first use in this function)
> | insn-opinit.c:1011:24: error: 'vec_widen_ushiftl_lo_optab' undeclared (first use in this function)
> | insn-opinit.c:1021:24: error: 'vec_widen_sshiftl_hi_optab' undeclared (first use in this function)
> | insn-opinit.c:1023:24: error: 'vec_widen_ushiftl_hi_optab' undeclared (first use in this function)
> | make[2]: *** [insn-opinit.o] Error 1
> | make[2]: *** Waiting for unfinished jobs....

and different one for armv5te too:
| GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -I. -I. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../include -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libcpp/include  -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber/dpd -I../libdecnumber    /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/cgraphbuild.c -o cgraphbuild.o
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c: In function 'bounds_check':
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:9204:5: warning: format not a string literal and no format arguments [-Wformat-security]
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c: In function 'arm_print_operand':
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:16786:4: warning: format not a string literal and no format arguments [-Wformat-security]
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c: In function 'arm_init_neon_builtins':
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:19270:4: error: 'neon_struct_operand' undeclared (first use in this function)
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:19270:4: note: each undeclared identifier is reported only once for each function it appears in
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c: At top level:
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:6753:1: warning: 'arm_legitimate_constant_p' defined but not used [-Wunused-function]
| /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:22697:1: warning: 'arm_array_mode_supported_p' defined but not used [-Wunused-function]
| make[2]: *** [arm.o] Error 1
| make[2]: *** Waiting for unfinished jobs....
| rm gcov.pod cpp.pod gfdl.pod gcc.pod fsf-funding.pod
| make[2]: Leaving directory `/OE/shr-core/tmp-eglibc/work/armv5te-oe-linux-gnueabi/gcc-cross-initial/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi/gcc'
| make[1]: *** [all-gcc] Error 2
| make[1]: Leaving directory `/OE/shr-core/tmp-eglibc/work/armv5te-oe-linux-gnueabi/gcc-cross-initial/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi'
| make: *** [all] Error 2

Cheers,
Martin Jansa - Dec. 20, 2011, 4:15 p.m.
On Tue, Dec 20, 2011 at 10:37:34AM +0100, Martin Jansa wrote:
> On Tue, Dec 20, 2011 at 10:07:56AM +0100, Martin Jansa wrote:
> > On Fri, Dec 16, 2011 at 01:24:24PM -0800, Khem Raj wrote:
> > > On (15/12/11 12:16), Richard Purdie wrote:
> > > > On Wed, 2011-12-14 at 07:49 -0800, Khem Raj wrote:
> > > > > On Wed, Dec 14, 2011 at 2:02 AM, Richard Purdie
> > > > > <richard.purdie@linuxfoundation.org> wrote:
> > > > > > Hi Khem,
> > > > > >
> > > > > > What's puzzling me is that reading through this patch, we already do
> > > > > > what this patch is doing?
> > > > > >
> > > > > > Where is the difference which this patch is fixing?
> > > > > >
> > > > > 
> > > > > this does essentially what we were doing earlier but this one is going
> > > > > to go upstream
> > > > 
> > > > Yes, that is good and I'm fine with the patch for that reason.
> > > 
> > > there is additional detail that this patch does which is that in order
> > > to make gxx-includes to be sysroot relative --with-cxx-include option to
> > > be also specified relative to initials sysroot during configure time
> > > 
> > > e.g. --with-sysroot=SYSROOT --with-gxx-include-dir=SYSROOT/usr/include/c++
> > > 
> > > since the original behavior of --with-gxx-include-dir is to specify an
> > > absolute path that is preserved whereas the patch we have in OE relocates
> > > gxx-include-dir regardless.Therefore in order to adopt this patch we have
> > > to use the above syntax which was original syntax before the above patch
> > > and would make up forward compatible provided this patch makes into gcc
> > > upstream.
> > > 
> > > > 
> > > > > 
> > > > > > I appreciate that patch adds in the prefix to the --with-gxx-include-dir
> > > > > > option but it then removes it again during configure so this should be a
> > > > > > null op. Both versions of the patch set the "1" bit in gcc/cppdefault.c.
> > > > > >
> > > > > > So where is the change this patch makes which fixes things?
> > > > > 
> > > > > changing --with-gxx-include-dir to be within sysroot triggers the
> > > > > relocation code.
> > > > 
> > > > But we were already triggering the relocation code?
> > > > 
> > > > I can't see *any* functionality difference between these, they should
> > > > both just give the same result as far as I can tell...
> > > > 
> > > same functionality but with a different usage see above
> > > 
> > > > Claiming it fixes things is therefore concerning me.
> > > 
> > > correct it does not fix anything actually that I know was broken before
> > > Thinking out loud given that with-gxx-include-dir is absolute in nature it could be
> > > the original patch we have, does not work in some weird case since the
> > > absolute path we use is still /usr/include/c++ during configure time.
> > > although I would expect that the include poisoning warning will report it if that
> > > happened
> > > 
> > > -Khem
> > 
> > Is there some pending patch for meta-oe/gcc?
> > 
> > I have some issues while rebuilding toolchain from scratch after this
> > patchset:
> > 
> > armv7a:
> > | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/rtl.h:2163:12: note: expected 'enum machine_mode' but argument is of type 'int'
> > | gcc -c   -isystem/OE/shr-core/tmp-eglibc/sysroots/x86_64-linux/usr/include -O2 -pipe -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -I. -I. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../include -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libcpp/include  -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber/dpd -I../libdecnumber    /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c -o calls.o
> > | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c: In function 'initialize_argument_information':
> > | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c:1089:9: error: 'STACK_CHECK_MAX_VAR_SIZE' undeclared (first use in this function)
> > | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/calls.c:1089:9: note: each undeclared identifier is reported only once for each function it appears in
> > | make[2]: *** [calls.o] Error 1
> > 
> > armv4t:
> > | gcc -c   -isystem/OE/shr-core/tmp-eglibc/sysroots/x86_64-linux/usr/include -O2 -pipe -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -I. -I. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../include -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libcpp/include  -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber/dpd -I../libdecnumber    insn-output.c -o insn-output.o
> > | In file included from insn-emit.c:23:0:
> > | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/constraints.md: In function 'satisfies_constraint_Uu':
> > | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/constraints.md:353:6: warning: implicit declaration of function 'thumb1_legitimate_address_p' [-Wimplicit-function-declaration]
> > | insn-opinit.c: In function 'init_all_optabs':
> > | insn-opinit.c:25:5: warning: implicit declaration of function 'set_widening_optab_handler' [-Wimplicit-function-declaration]
> > | insn-opinit.c:30:7: error: 'TARGET_IDIV' undeclared (first use in this function)
> > | insn-opinit.c:30:7: note: each undeclared identifier is reported only once for each function it appears in
> > | insn-opinit.c:813:32: error: 'vec_load_lanes_optab' undeclared (first use in this function)
> > | insn-opinit.c:833:32: error: 'vec_store_lanes_optab' undeclared (first use in this function)
> > | insn-opinit.c:1009:24: error: 'vec_widen_sshiftl_lo_optab' undeclared (first use in this function)
> > | insn-opinit.c:1011:24: error: 'vec_widen_ushiftl_lo_optab' undeclared (first use in this function)
> > | insn-opinit.c:1021:24: error: 'vec_widen_sshiftl_hi_optab' undeclared (first use in this function)
> > | insn-opinit.c:1023:24: error: 'vec_widen_ushiftl_hi_optab' undeclared (first use in this function)
> > | make[2]: *** [insn-opinit.o] Error 1
> > | make[2]: *** Waiting for unfinished jobs....
> 
> and different one for armv5te too:
> | GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -I. -I. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/. -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../include -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libcpp/include  -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber -I/OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/../libdecnumber/dpd -I../libdecnumber    /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/cgraphbuild.c -o cgraphbuild.o
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c: In function 'bounds_check':
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:9204:5: warning: format not a string literal and no format arguments [-Wformat-security]
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c: In function 'arm_print_operand':
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:16786:4: warning: format not a string literal and no format arguments [-Wformat-security]
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c: In function 'arm_init_neon_builtins':
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:19270:4: error: 'neon_struct_operand' undeclared (first use in this function)
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:19270:4: note: each undeclared identifier is reported only once for each function it appears in
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c: At top level:
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:6753:1: warning: 'arm_legitimate_constant_p' defined but not used [-Wunused-function]
> | /OE/shr-core/tmp-eglibc/work-shared/gcc-4.6.2+svnr181430-r23/gcc-4_6-branch/gcc/config/arm/arm.c:22697:1: warning: 'arm_array_mode_supported_p' defined but not used [-Wunused-function]
> | make[2]: *** [arm.o] Error 1
> | make[2]: *** Waiting for unfinished jobs....
> | rm gcov.pod cpp.pod gfdl.pod gcc.pod fsf-funding.pod
> | make[2]: Leaving directory `/OE/shr-core/tmp-eglibc/work/armv5te-oe-linux-gnueabi/gcc-cross-initial/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi/gcc'
> | make[1]: *** [all-gcc] Error 2
> | make[1]: Leaving directory `/OE/shr-core/tmp-eglibc/work/armv5te-oe-linux-gnueabi/gcc-cross-initial/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi'
> | make: *** [all] Error 2

without
PARALLEL_MAKE="-j4"
BB_NUMBER_THREADS = "2"
I've managed to build toolchain for one arch, but after switching MACHINE it fails again:

| Checking multilib configuration for libgcc...
| Configuring in arm-oe-linux-gnueabi/libgcc
| configure: loading cache ./config.cache
| configure: error: `CC' has changed since the previous run:
| configure:   former value:  ` /OE/shr-core/tmp/work/armv7a-vfp-neon-oe-linux-gnueabi/gcc-cross/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi/./gcc/xgcc -B/OE/shr-core/tmp/work/armv7a-vfp-neon-oe-linux-gnueabi/gcc-cross/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi/./gcc/ -march=armv7-a -fno-tree-vectorize      -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -isystem/OE/shr-core/tmp/sysroots/nokia900/usr/include -B/OE/shr-core/tmp/sysroots/x86_64-linux/usr/arm-oe-linux-gnueabi/bin/ -B/OE/shr-core/tmp/sysroots/x86_64-linux/usr/arm-oe-linux-gnueabi/lib/ -isystem /OE/shr-core/tmp/sysroots/x86_64-linux/usr/arm-oe-linux-gnueabi/include -isystem /OE/shr-core/tmp/sysroots/x86_64-linux/usr/arm-oe-linux-gnueabi/sys-include --sysroot=/OE/shr-core/tmp/sysroots/nokia900  '
| configure:   current value: ` /OE/shr-core/tmp/work/armv7a-vfp-neon-oe-linux-gnueabi/gcc-cross/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi/./gcc/xgcc -B/OE/shr-core/tmp/work/armv7a-vfp-neon-oe-linux-gnueabi/gcc-cross/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi/./gcc/ -march=armv7-a -fno-tree-vectorize      -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -isystem/OE/shr-core/tmp/sysroots/palmpre/usr/include -B/OE/shr-core/tmp/sysroots/x86_64-linux/usr/arm-oeERROR: Function 'do_compile' failed (see /OE/shr-core/tmp/work/armv7a-vfp-neon-oe-linux-gnueabi/gcc-cross/4.6.2+svnr181430-r23/temp/log.do_compile.13936 for further information)
| -linux-gnueabi/bin/ -B/OE/shr-core/tmp/sysroots/x86_64-linux/usr/arm-oe-linux-gnueabi/lib/ -isystem /OE/shr-core/tmp/sysroots/x86_64-linux/usr/arm-oe-linux-gnueabi/include -isystem /OE/shr-core/tmp/sysroots/x86_64-linux/usr/arm-oe-linux-gnueabi/sys-include --sysroot=/OE/shr-core/tmp/sysroots/palmpre  '
| configure: error: in `/OE/shr-core/tmp/work/armv7a-vfp-neon-oe-linux-gnueabi/gcc-cross/4.6.2+svnr181430-r23/gcc-4_6-branch/build.x86_64-linux.arm-oe-linux-gnueabi/arm-oe-linux-gnueabi/libgcc':
| configure: error: changes in the environment can compromise the build
| configure: error: run `make distclean' and/or `rm ./config.cache' and start over
| make: *** [configure-target-libgcc] Error 1
| + die 'oe_runmake failed'
| + bbfatal 'oe_runmake failed'
| + echo 'ERROR: oe_runmake failed'
| ERROR: oe_runmake failed
| + exit 1
NOTE: package gcc-cross-4.6.2+svnr181430-r23: task do_compile: Failed
ERROR: Task 131 (/OE/shr-core/openembedded-core/meta/recipes-devtools/gcc/gcc-cross_4.6.bb, do_compile) failed with exit code '1'

maybe it's because something was reused from work-shared?

Regards,
Khem Raj - Dec. 20, 2011, 5:45 p.m.
On Tue, Dec 20, 2011 at 8:15 AM, Martin Jansa <martin.jansa@gmail.com> wrote:
>
> maybe it's because something was reused from work-shared?

its because --sysroot value changed. I think its getting it from sstate-cache
probably we should ignore --sysroot from the sstate-cache
Khem Raj - Dec. 20, 2011, 7:59 p.m.
On Mon, Dec 19, 2011 at 10:36 PM, Eric Bénard <eric@eukrea.com> wrote:
> Hi, Khem,
>
> Le 14/12/2011 19:38, Khem Raj a écrit :
>
>> On Wed, Dec 14, 2011 at 10:08 AM, Ulf Samuelsson
>> <openembedded-core@emagii.com>  wrote:
>>>>
>>>>
>>>>
>>> Not familiar with gcc internals, but just want to reiterate the point
>>> that the problem occured (the one I saw) only when I had
>>> BB_NUMBER_THREADS at a high value, so WHEN things are done seems to be
>>> important.
>>
>>
> Seems more complicated than this. A customeer reproduced it with BB_THREAD=2
> and PARALLEL=j3 ... (I never reproduced in with BB_THREAD < 5)
>

Can you see when gcc-runtime was finished building and staging w.r.t
to the failing app

>
>> could you test out this patch in your configuration and see if you still
>> see the problem ?
>>
> I reproduced the problem with this patch and BB_THREAD=8 so this patch
> doesn't
> improve the current behaviour.

thats was my original expectation

>
> Eric
Eric BENARD - Dec. 21, 2011, 2:23 p.m.
Hi Khem,

Le 20/12/2011 20:59, Khem Raj a écrit :
> On Mon, Dec 19, 2011 at 10:36 PM, Eric Bénard<eric@eukrea.com>  wrote:
>> Hi, Khem,
>>
>> Le 14/12/2011 19:38, Khem Raj a écrit :
>>
>>> On Wed, Dec 14, 2011 at 10:08 AM, Ulf Samuelsson
>>> <openembedded-core@emagii.com>    wrote:
>>>>>
>>>>>
>>>>>
>>>> Not familiar with gcc internals, but just want to reiterate the
>>>> point that the problem occured (the one I saw) only when I had
>>>> BB_NUMBER_THREADS at a high value, so WHEN things are done seems to
>>>> be important.
>>>
>>>
>> Seems more complicated than this. A customeer reproduced it with
>> BB_THREAD=2 and PARALLEL=j3 ... (I never reproduced in with BB_THREAD<
>> 5)
>>
>
> Can you see when gcc-runtime was finished building and staging w.r.t to the
> failing app
>
rm_work on gcc-runtime was done far before do_configure on the failing app
(mysql in the present case).

Eric

Patch

diff --git a/meta/recipes-devtools/gcc/gcc-4.6.inc b/meta/recipes-devtools/gcc/gcc-4.6.inc
index 18e0536..4bbb2d2 100644
--- a/meta/recipes-devtools/gcc/gcc-4.6.inc
+++ b/meta/recipes-devtools/gcc/gcc-4.6.inc
@@ -1,6 +1,6 @@ 
 require gcc-common.inc
 
-PR = "r19"
+PR = "r20"
 
 # Third digit in PV should be incremented after a minor release
 # happens from this branch on gcc e.g. currently its 4.6.0
@@ -62,7 +62,6 @@  SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \
 	   file://64bithack.patch \
 	   file://optional_libstdc.patch \
 	   file://disable_relax_pic_calls_flag.patch \
-	   file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \
 	   file://COLLECT_GCC_OPTIONS.patch \
            file://volatile_access_backport.patch \
            file://use-defaults.h-and-t-oe-in-B.patch \
@@ -73,6 +72,7 @@  SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \
 	   file://pr32219.patch \
 	   file://pr47551.patch \
 	   file://gcc-arm-set-cost.patch \
+	   file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \
 	  "
 
 SRC_URI_append_sh3  = " file://sh3-installfix-fixheaders.patch "
diff --git a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
index 05b2fa9..6ccbeea 100644
--- a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
+++ b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch
@@ -1,35 +1,186 @@ 
-Upstream-Status: Pending
-
-# by default c++ include directories are not relative to "--sysroot"
-# which brings one trouble when using the toolchain in an environment
-# where the build directory generating that toolchain doesn't exist,
-# e.g. in sstate, machine specific sysroot and relocatable SDK
-# toolchain. This patch now enables c++ include paths under sysroot.
-# This way it's enough as long as "--sysroot" is correctly enabled
-# in the new environment.
-#
-# Signed-off-by Kevin Tian <kevin.tian@intel.com>, 2010-12-30
-
-Index: gcc-4.6.0/gcc/cppdefault.c
+source: http://patchwork.ozlabs.org/patch/129800/
+Upstream-Status: Submitted
+
+ChangeLog
+        * Makefile.in (gcc_gxx_include_dir_add_sysroot): New.
+          (PREPROCESSOR_DEFINES): Define GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT.
+
+        * cppdefault.c (cpp_include_defaults): replace hard coded "1" with
+          GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT for "add_sysroot" field.
+
+        * configure.ac (AC_SUBST): Add gcc_gxx_include_dir_add_sysroot to
+          control whether sysroot should be prepended to gxx include dir.
+
+        * configure: Regenerate.
+
+Hi, this is a follow up for issue "http://codereview.appspot.com/4641076".
+
+The rationale for the patch copied from previous thread:
+=======================================
+The setup:
+
+Configuring a toolchain targeting x86-64 GNU Linux (Ubuntu Lucid), as a
+cross-compiler.  Using a sysroot to provide the Lucid headers+libraries,
+with the sysroot path being within the GCC install tree.  Want to use the
+Lucid system libstdc++ and headers, which means that I'm not
+building/installing libstdc++-v3.
+
+So, configuring with:
+  --with-sysroot="$SYSROOT"
+  --disable-libstdc++-v3 \
+  --with-gxx-include-dir="$SYSROOT/usr/include/c++/4.4" \
+(among other options).
+
+Hoping to support two usage models with this configuration, w.r.t. use of
+the sysroot:
+
+(1) somebody installs the sysroot in the normal location relative to the
+GCC install, and relocates the whole bundle (sysroot+GCC).  This works
+great AFAICT, GCC finds its includes (including the C++ includes) thanks
+to the add_standard_paths iprefix handling.
+
+(2) somebody installs the sysroot in a non-standard location, and uses
+--sysroot to try to access it.  This works fine for the C headers, but
+doesn't work.
+
+For the C headers, add_standard_paths prepends the sysroot location to
+the /usr/include path (since that's what's specified in cppdefault.c for
+that path).  It doesn't do the same for the C++ include path, though
+(again, as specified in cppdefault.c).
+
+add_standard_paths doesn't attempt to relocate built-in include paths that
+start with the compiled-in sysroot location (e.g., the g++ include dir, in
+this case).  This isn't surprising really: normally you either prepend the
+sysroot location or you don't (as specified by cppdefault.c); none of the
+built-in paths normally *start* with the sysroot location and need to be
+relocated.  However, in this odd-ball case of trying to use the C++ headers
+from the sysroot, one of the paths *does* need to be relocated in this way.
+===========================
+Index: gcc-4_6-branch/gcc/Makefile.in
+===================================================================
+--- gcc-4_6-branch.orig/gcc/Makefile.in	2011-12-13 22:52:15.000000000 -0800
++++ gcc-4_6-branch/gcc/Makefile.in	2011-12-13 22:52:21.933635767 -0800
+@@ -587,6 +587,7 @@
+ build_tooldir = $(exec_prefix)/$(target_noncanonical)
+ # Directory in which the compiler finds target-independent g++ includes.
+ gcc_gxx_include_dir = @gcc_gxx_include_dir@
++gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@
+ # Directory to search for site-specific includes.
+ local_includedir = $(local_prefix)/include
+ includedir = $(prefix)/include
+@@ -3964,6 +3965,7 @@
+   -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
+   -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
+   -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
++  -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
+   -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
+   -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
+   -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
+Index: gcc-4_6-branch/gcc/configure.ac
 ===================================================================
---- gcc-4.6.0.orig/gcc/cppdefault.c
-+++ gcc-4.6.0/gcc/cppdefault.c
-@@ -48,15 +48,15 @@ const struct default_include cpp_include
+--- gcc-4_6-branch.orig/gcc/configure.ac	2011-12-13 22:52:15.000000000 -0800
++++ gcc-4_6-branch/gcc/configure.ac	2011-12-13 22:52:21.937635526 -0800
+@@ -144,6 +144,15 @@
+   fi
+ fi
+ 
++gcc_gxx_include_dir_add_sysroot=0
++if test "${with_sysroot+set}" = set; then :
++  gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
++  if test "${gcc_gxx_without_sysroot}"; then :
++    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
++    gcc_gxx_include_dir_add_sysroot=1
++  fi
++fi
++
+ AC_ARG_WITH(cpp_install_dir,
+ [  --with-cpp-install-dir=DIR
+                           install the user visible C preprocessor in DIR
+@@ -4737,6 +4746,7 @@
+ AC_SUBST(float_h_file)
+ AC_SUBST(gcc_config_arguments)
+ AC_SUBST(gcc_gxx_include_dir)
++AC_SUBST(gcc_gxx_include_dir_add_sysroot)
+ AC_SUBST(host_exeext)
+ AC_SUBST(host_xm_file_list)
+ AC_SUBST(host_xm_include_list)
+Index: gcc-4_6-branch/gcc/cppdefault.c
+===================================================================
+--- gcc-4_6-branch.orig/gcc/cppdefault.c	2011-12-13 22:51:28.000000000 -0800
++++ gcc-4_6-branch/gcc/cppdefault.c	2011-12-13 22:52:21.937635526 -0800
+@@ -48,15 +48,18 @@
  = {
  #ifdef GPLUSPLUS_INCLUDE_DIR
      /* Pick up GNU C++ generic include files.  */
 -    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
-+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 },
++    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
  #endif
  #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
      /* Pick up GNU C++ target-dependent include files.  */
 -    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 1 },
-+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 1, 1 },
++    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
  #endif
  #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
      /* Pick up GNU C++ backward and deprecated include files.  */
 -    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
-+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 1, 0 },
++    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
++      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
  #endif
  #ifdef GCC_INCLUDE_DIR
      /* This is the dir for gcc's private headers.  */
+Index: gcc-4_6-branch/gcc/configure
+===================================================================
+--- gcc-4_6-branch.orig/gcc/configure	2011-12-13 22:52:15.000000000 -0800
++++ gcc-4_6-branch/gcc/configure	2011-12-13 22:52:33.185690436 -0800
+@@ -636,6 +636,7 @@
+ host_xm_include_list
+ host_xm_file_list
+ host_exeext
++gcc_gxx_include_dir_add_sysroot
+ gcc_gxx_include_dir
+ gcc_config_arguments
+ float_h_file
+@@ -3313,6 +3314,15 @@
+   fi
+ fi
+ 
++gcc_gxx_include_dir_add_sysroot=0
++if test "${with_sysroot+set}" = set; then :
++  gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
++  if test "${gcc_gxx_without_sysroot}"; then :
++    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
++    gcc_gxx_include_dir_add_sysroot=1
++  fi
++fi
++
+ 
+ # Check whether --with-cpp_install_dir was given.
+ if test "${with_cpp_install_dir+set}" = set; then :
+@@ -17514,7 +17524,7 @@
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 17517 "configure"
++#line 17527 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -17620,7 +17630,7 @@
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 17623 "configure"
++#line 17633 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -26151,6 +26161,7 @@
+ 
+ 
+ 
++
+ 
+ 
+ 
diff --git a/meta/recipes-devtools/gcc/gcc-configure-cross.inc b/meta/recipes-devtools/gcc/gcc-configure-cross.inc
index d2d9081..5816768 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-cross.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-cross.inc
@@ -10,7 +10,7 @@  EXTRA_OECONF += " --enable-poison-system-directories \
 INHIBIT_DEFAULT_DEPS = "1"
 
 EXTRA_OECONF_PATHS = "--with-local-prefix=${STAGING_DIR_TARGET}${target_exec_prefix} \
-		      --with-gxx-include-dir=${target_includedir}/c++ \
+		      --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++ \
                       --with-sysroot=${STAGING_DIR_TARGET} \
                       --with-build-sysroot=${STAGING_DIR_TARGET}"
 
diff --git a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
index 34bfaeb..3b440ff 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-runtime.inc
@@ -4,7 +4,7 @@  CXXFLAGS := "${@oe_filter_out('-fvisibility-inlines-hidden', '${CXXFLAGS}', d)}"
 
 EXTRA_OECONF_PATHS = " \
     --with-local-prefix=${STAGING_DIR_TARGET}${prefix} \
-    --with-gxx-include-dir=${includedir}/c++/ \
+    --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++/ \
     --with-sysroot=${STAGING_DIR_TARGET} \
     --with-build-sysroot=${STAGING_DIR_TARGET}"
 
diff --git a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
index f130b47..eb6757c 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc
@@ -5,7 +5,7 @@  USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibc", "no", "", d )}'
 USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibceabi", "no", "", d )}'
 
 EXTRA_OECONF_PATHS = "--with-local-prefix=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_exec_prefix} \
-                      --with-gxx-include-dir=${target_includedir}/c++ \
+                      --with-gxx-include-dir=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_includedir}/c++ \
                       --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
                       --with-sysroot=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS} \
                       --with-build-sysroot=${STAGING_DIR_TARGET}"