All of lore.kernel.org
 help / color / mirror / Atom feed
* --with-gxx-include-dir and sysroot
@ 2010-12-24  7:34 Tian, Kevin
  2010-12-24 14:37 ` Richard Purdie
  0 siblings, 1 reply; 13+ messages in thread
From: Tian, Kevin @ 2010-12-24  7:34 UTC (permalink / raw)
  To: poky

I got a confusion about the relationship between "--with-gxx-include-dir" and sysroot, 
and consequently would like to discuss one issue it causes.

GCC installation manual is not very clear about how c++ header files are searched when
there's no "--with-gxx-include-dir" but with "--sysroot":

--with-gxx-include-dir=dirname
    Specify the installation directory for G++ header files. The default depends on 
other configuration options, and differs between cross and native configurations.

My assumption is that ${sysroot}/usr/include/c++ will be searched which is why sysroot
option is there.

However currently Poky always specifies "--with-gxx-include-dir" explicitly:

gcc-configure-cross.inc:                     
 --with-gxx-include-dir=${STAGING_DIR_TARGET}/${target_includedir}/c++ \
--with-sysroot=${STAGING_DIR_TARGET} \

gcc-configure-runtime.inc:    
--with-gxx-include-dir=${includedir}/c++/ \
--with-sysroot=${STAGING_DIR_TARGET} \

gcc-configure-sdk.inc:                      
--with-gxx-include-dir=${SDKPATH}/sysroots/${TARGET_SYS}${target_includedir}/c++ \
--with-sysroot=${SDKPATH}/sysroots/${TARGET_SYS} \

gcc-configure-target.inc:    
--with-gxx-include-dir=${includedir}/c++/"

for cross/sdk, there's no difference from not using option if my assumption is correct.
The only meaningful one is perhaps runtime. 

I checked OE side, they don't have gcc-runtime (why???), and only add the option for
the target gcc (--with-gxx-include-dir=${includedir}/c++/{BINV}) which makes sense
since using BINV is different from normal convention.

So my question is whether it's necessary to explicitly set this option in Poky, upon which
we can then talk about the issue I'm seeing and the solution.

The major problem with hardcoded "with-gxx-include-dir" is that it makes the toolchain
problematic when using in a separate build environment, because that hard code path
may be missing in the new environment. It's not relocatable.

Previous SDK multi-sysroot support is one example.

So does sstate, when you need to build some new C++ packages in the 2nd build dir
while using toolchain built from another dir. I observed this when reusing a set of
sstate packages of a minimal image, and then started building a sato image and then
encountered libproxy error due to failing to find cstdio.

Machine specific sysroot also has this problem, because we end up to use the toolchain
built for the 1st machine to build recipes for the 2nd machine. It will be generally
worked around because both sysroots exist and can be both accessed, but it's still
a potential issue.

The workaround in my sstate case is a bit ugly. I have to use "-I" in CXXFLAGS in
bitbake.conf:

-I${STAGING_DIR_TARGET}/${target_includedir}/c++ 
-I${STAGING_DIR_TARGET}/${target_includedir}/c++/backward 
-I${STAGING_DIR_TARGET}/${target_includedir}/c++/${TARGET_SYS}

If "with-gxx-include-dir" can be removed, we don't need do anything here. Or else
above simple workaround is not enough since "with-gxx-include-dir" is set differently
for gcc variances like sdk/cross, and we need differentiate them at right place 
instead of punching global CXXFLAGS.

comments?

Thanks
Kevin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-24  7:34 --with-gxx-include-dir and sysroot Tian, Kevin
@ 2010-12-24 14:37 ` Richard Purdie
  2010-12-28  3:24   ` Tian, Kevin
  2010-12-31 10:01   ` Khem Raj
  0 siblings, 2 replies; 13+ messages in thread
From: Richard Purdie @ 2010-12-24 14:37 UTC (permalink / raw)
  To: Tian, Kevin; +Cc: poky

On Fri, 2010-12-24 at 15:34 +0800, Tian, Kevin wrote:
> I got a confusion about the relationship between "--with-gxx-include-dir" and sysroot, 
> and consequently would like to discuss one issue it causes.
> 
> GCC installation manual is not very clear about how c++ header files are searched when
> there's no "--with-gxx-include-dir" but with "--sysroot":
> 
> --with-gxx-include-dir=dirname
>     Specify the installation directory for G++ header files. The default depends on 
> other configuration options, and differs between cross and native configurations.
> 
> My assumption is that ${sysroot}/usr/include/c++ will be searched which is why sysroot
> option is there.

This is a bad assumption I'm afraid. I had to go and take a look at the
code to determine this though.

> However currently Poky always specifies "--with-gxx-include-dir" explicitly:
> 
> gcc-configure-cross.inc:                     
>  --with-gxx-include-dir=${STAGING_DIR_TARGET}/${target_includedir}/c++ \
> --with-sysroot=${STAGING_DIR_TARGET} \
> 
> gcc-configure-runtime.inc:    
> --with-gxx-include-dir=${includedir}/c++/ \
> --with-sysroot=${STAGING_DIR_TARGET} \
> 
> gcc-configure-sdk.inc:                      
> --with-gxx-include-dir=${SDKPATH}/sysroots/${TARGET_SYS}${target_includedir}/c++ \
> --with-sysroot=${SDKPATH}/sysroots/${TARGET_SYS} \
> 
> gcc-configure-target.inc:    
> --with-gxx-include-dir=${includedir}/c++/"
> 
> for cross/sdk, there's no difference from not using option if my assumption is correct.
> The only meaningful one is perhaps runtime. 
> 
> I checked OE side, they don't have gcc-runtime (why???), and only add the option for
> the target gcc (--with-gxx-include-dir=${includedir}/c++/{BINV}) which makes sense
> since using BINV is different from normal convention.

Whilst OE doesn't use this, if you read the configure code for this
option you'll see that it gets set to a default anyway so not specifying
it doesn't change much. In poky we dropped the BINV part of the path
which I believe is part of the default.

> So my question is whether it's necessary to explicitly set this option in Poky, upon which
> we can then talk about the issue I'm seeing and the solution.

Looking at the code I don't think it will actually make any difference
whether we set it or not.

> The major problem with hardcoded "with-gxx-include-dir" is that it makes the toolchain
> problematic when using in a separate build environment, because that hard code path
> may be missing in the new environment. It's not relocatable.
> 
> Previous SDK multi-sysroot support is one example.
> 
> So does sstate, when you need to build some new C++ packages in the 2nd build dir
> while using toolchain built from another dir. I observed this when reusing a set of
> sstate packages of a minimal image, and then started building a sato image and then
> encountered libproxy error due to failing to find cstdio.
> 
> Machine specific sysroot also has this problem, because we end up to use the toolchain
> built for the 1st machine to build recipes for the 2nd machine. It will be generally
> worked around because both sysroots exist and can be both accessed, but it's still
> a potential issue.
> 
> The workaround in my sstate case is a bit ugly. I have to use "-I" in CXXFLAGS in
> bitbake.conf:
> 
> -I${STAGING_DIR_TARGET}/${target_includedir}/c++ 
> -I${STAGING_DIR_TARGET}/${target_includedir}/c++/backward 
> -I${STAGING_DIR_TARGET}/${target_includedir}/c++/${TARGET_SYS}
> 
> If "with-gxx-include-dir" can be removed, we don't need do anything here. 

I really don't think its this simple.

Looking at the gcc code, I propose we patch cppdefault.c so instead of

GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0

is says

GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0

and then we only ever specify:

--with-gxx-include-dir=${includedir}/c++/ to build the compiler.

Since we set always set --sysroot for the compiler correctly, this
should then fix all the problems in a clean and simple way.

Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to behave
sanely.

I don't like patching gcc like this but in this case I believe the
standard settings are just plain wrong and with that simple change,
things will just work as they should...

Of course I've not tested this so I'd appreciate feedback but I think it
will solve the problem in the simplest way :)

Cheers,

Richard




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-24 14:37 ` Richard Purdie
@ 2010-12-28  3:24   ` Tian, Kevin
  2010-12-30  9:05     ` Tian, Kevin
  2010-12-31 10:01   ` Khem Raj
  1 sibling, 1 reply; 13+ messages in thread
From: Tian, Kevin @ 2010-12-28  3:24 UTC (permalink / raw)
  To: Richard Purdie; +Cc: poky

>From: Richard Purdie [mailto:richard.purdie@linuxfoundation.org]
>Sent: Friday, December 24, 2010 10:38 PM
>
>On Fri, 2010-12-24 at 15:34 +0800, Tian, Kevin wrote:
>> I got a confusion about the relationship between "--with-gxx-include-dir" and sysroot,
>> and consequently would like to discuss one issue it causes.
>>
>> GCC installation manual is not very clear about how c++ header files are searched when
>> there's no "--with-gxx-include-dir" but with "--sysroot":
>>
>> --with-gxx-include-dir=dirname
>>     Specify the installation directory for G++ header files. The default depends on
>> other configuration options, and differs between cross and native configurations.
>>
>> My assumption is that ${sysroot}/usr/include/c++ will be searched which is why sysroot
>> option is there.
>
>This is a bad assumption I'm afraid. I had to go and take a look at the
>code to determine this though.

that's why I'm sending this mail to make it clear. :-)

>
>> However currently Poky always specifies "--with-gxx-include-dir" explicitly:
>>
>> gcc-configure-cross.inc:
>>  --with-gxx-include-dir=${STAGING_DIR_TARGET}/${target_includedir}/c++ \
>> --with-sysroot=${STAGING_DIR_TARGET} \
>>
>> gcc-configure-runtime.inc:
>> --with-gxx-include-dir=${includedir}/c++/ \
>> --with-sysroot=${STAGING_DIR_TARGET} \
>>
>> gcc-configure-sdk.inc:
>>
>--with-gxx-include-dir=${SDKPATH}/sysroots/${TARGET_SYS}${target_includedir}/c++
>\
>> --with-sysroot=${SDKPATH}/sysroots/${TARGET_SYS} \
>>
>> gcc-configure-target.inc:
>> --with-gxx-include-dir=${includedir}/c++/"
>>
>> for cross/sdk, there's no difference from not using option if my assumption is correct.
>> The only meaningful one is perhaps runtime.
>>
>> I checked OE side, they don't have gcc-runtime (why???), and only add the option for
>> the target gcc (--with-gxx-include-dir=${includedir}/c++/{BINV}) which makes sense
>> since using BINV is different from normal convention.
>
>Whilst OE doesn't use this, if you read the configure code for this
>option you'll see that it gets set to a default anyway so not specifying
>it doesn't change much. In poky we dropped the BINV part of the path
>which I believe is part of the default.

yes, so far that default has nothing to do with the sysroot option. I made an experiment
just now. The default path ends up pointing to: 

${STAGING_DIR_NATIVE}/usr/${TARGET_SYS}/include/c++/${BINV}

which is based on ${libdir}. 

So as you said, this doesn't change anything in this point.

BTW is there any other impact of this difference between OE and Poky? I mean installing
to native/sdk sysroot(OE) and to target sysroot (poky)...

>
>> So my question is whether it's necessary to explicitly set this option in Poky, upon which
>> we can then talk about the issue I'm seeing and the solution.
>
>Looking at the code I don't think it will actually make any difference
>whether we set it or not.

Yep

>
>> The major problem with hardcoded "with-gxx-include-dir" is that it makes the toolchain
>> problematic when using in a separate build environment, because that hard code path
>> may be missing in the new environment. It's not relocatable.
>>
>> Previous SDK multi-sysroot support is one example.
>>
>> So does sstate, when you need to build some new C++ packages in the 2nd build dir
>> while using toolchain built from another dir. I observed this when reusing a set of
>> sstate packages of a minimal image, and then started building a sato image and then
>> encountered libproxy error due to failing to find cstdio.
>>
>> Machine specific sysroot also has this problem, because we end up to use the toolchain
>> built for the 1st machine to build recipes for the 2nd machine. It will be generally
>> worked around because both sysroots exist and can be both accessed, but it's still
>> a potential issue.
>>
>> The workaround in my sstate case is a bit ugly. I have to use "-I" in CXXFLAGS in
>> bitbake.conf:
>>
>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++
>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++/backward
>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++/${TARGET_SYS}
>>
>> If "with-gxx-include-dir" can be removed, we don't need do anything here.
>
>I really don't think its this simple.
>
>Looking at the gcc code, I propose we patch cppdefault.c so instead of
>
>GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>
>is says
>
>GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>
>and then we only ever specify:
>
>--with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>
>Since we set always set --sysroot for the compiler correctly, this
>should then fix all the problems in a clean and simple way.
>
>Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to behave
>sanely.
>
>I don't like patching gcc like this but in this case I believe the
>standard settings are just plain wrong and with that simple change,
>things will just work as they should...
>
>Of course I've not tested this so I'd appreciate feedback but I think it
>will solve the problem in the simplest way :)
>

That's a good and simple idea! I'll try it, but the test may take time... :-)

Thanks
Kevin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-28  3:24   ` Tian, Kevin
@ 2010-12-30  9:05     ` Tian, Kevin
  2010-12-30  9:42       ` Lu, Lianhao
  0 siblings, 1 reply; 13+ messages in thread
From: Tian, Kevin @ 2010-12-30  9:05 UTC (permalink / raw)
  To: Tian, Kevin, Richard Purdie; +Cc: poky

>From: Tian, Kevin
>Sent: Tuesday, December 28, 2010 11:25 AM
>
>>From: Richard Purdie [mailto:richard.purdie@linuxfoundation.org]
>>Sent: Friday, December 24, 2010 10:38 PM
>>
>>On Fri, 2010-12-24 at 15:34 +0800, Tian, Kevin wrote:
>>> I got a confusion about the relationship between "--with-gxx-include-dir" and sysroot,
>>> and consequently would like to discuss one issue it causes.
>>>
>>> GCC installation manual is not very clear about how c++ header files are searched when
>>> there's no "--with-gxx-include-dir" but with "--sysroot":
>>>
>>> --with-gxx-include-dir=dirname
>>>     Specify the installation directory for G++ header files. The default depends on
>>> other configuration options, and differs between cross and native configurations.
>>>
>>> My assumption is that ${sysroot}/usr/include/c++ will be searched which is why
>sysroot
>>> option is there.
>>
>>This is a bad assumption I'm afraid. I had to go and take a look at the
>>code to determine this though.
>
>that's why I'm sending this mail to make it clear. :-)
>
>>
>>> However currently Poky always specifies "--with-gxx-include-dir" explicitly:
>>>
>>> gcc-configure-cross.inc:
>>>  --with-gxx-include-dir=${STAGING_DIR_TARGET}/${target_includedir}/c++ \
>>> --with-sysroot=${STAGING_DIR_TARGET} \
>>>
>>> gcc-configure-runtime.inc:
>>> --with-gxx-include-dir=${includedir}/c++/ \
>>> --with-sysroot=${STAGING_DIR_TARGET} \
>>>
>>> gcc-configure-sdk.inc:
>>>
>>--with-gxx-include-dir=${SDKPATH}/sysroots/${TARGET_SYS}${target_includedir}/c+
>+
>>\
>>> --with-sysroot=${SDKPATH}/sysroots/${TARGET_SYS} \
>>>
>>> gcc-configure-target.inc:
>>> --with-gxx-include-dir=${includedir}/c++/"
>>>
>>> for cross/sdk, there's no difference from not using option if my assumption is correct.
>>> The only meaningful one is perhaps runtime.
>>>
>>> I checked OE side, they don't have gcc-runtime (why???), and only add the option for
>>> the target gcc (--with-gxx-include-dir=${includedir}/c++/{BINV}) which makes sense
>>> since using BINV is different from normal convention.
>>
>>Whilst OE doesn't use this, if you read the configure code for this
>>option you'll see that it gets set to a default anyway so not specifying
>>it doesn't change much. In poky we dropped the BINV part of the path
>>which I believe is part of the default.
>
>yes, so far that default has nothing to do with the sysroot option. I made an experiment
>just now. The default path ends up pointing to:
>
>${STAGING_DIR_NATIVE}/usr/${TARGET_SYS}/include/c++/${BINV}
>
>which is based on ${libdir}.
>
>So as you said, this doesn't change anything in this point.
>
>BTW is there any other impact of this difference between OE and Poky? I mean installing
>to native/sdk sysroot(OE) and to target sysroot (poky)...
>
>>
>>> So my question is whether it's necessary to explicitly set this option in Poky, upon which
>>> we can then talk about the issue I'm seeing and the solution.
>>
>>Looking at the code I don't think it will actually make any difference
>>whether we set it or not.
>
>Yep
>
>>
>>> The major problem with hardcoded "with-gxx-include-dir" is that it makes the toolchain
>>> problematic when using in a separate build environment, because that hard code path
>>> may be missing in the new environment. It's not relocatable.
>>>
>>> Previous SDK multi-sysroot support is one example.
>>>
>>> So does sstate, when you need to build some new C++ packages in the 2nd build dir
>>> while using toolchain built from another dir. I observed this when reusing a set of
>>> sstate packages of a minimal image, and then started building a sato image and then
>>> encountered libproxy error due to failing to find cstdio.
>>>
>>> Machine specific sysroot also has this problem, because we end up to use the toolchain
>>> built for the 1st machine to build recipes for the 2nd machine. It will be generally
>>> worked around because both sysroots exist and can be both accessed, but it's still
>>> a potential issue.
>>>
>>> The workaround in my sstate case is a bit ugly. I have to use "-I" in CXXFLAGS in
>>> bitbake.conf:
>>>
>>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++
>>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++/backward
>>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++/${TARGET_SYS}
>>>
>>> If "with-gxx-include-dir" can be removed, we don't need do anything here.
>>
>>I really don't think its this simple.
>>
>>Looking at the gcc code, I propose we patch cppdefault.c so instead of
>>
>>GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>>
>>is says
>>
>>GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>>
>>and then we only ever specify:
>>
>>--with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>>
>>Since we set always set --sysroot for the compiler correctly, this
>>should then fix all the problems in a clean and simple way.
>>
>>Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>>GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to behave
>>sanely.
>>
>>I don't like patching gcc like this but in this case I believe the
>>standard settings are just plain wrong and with that simple change,
>>things will just work as they should...
>>
>>Of course I've not tested this so I'd appreciate feedback but I think it
>>will solve the problem in the simplest way :)
>>
>
>That's a good and simple idea! I'll try it, but the test may take time... :-)
>

I've at least verified this change working in one of my sstate build, where c++
include dir could be searched successfully relative to sysroot. 

Lianhao is helping me test SDK multiple sysroot scenario, and I'm testing more
archs to ensure it not breaking normal build.

http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/log/?h=tk/cplusplus

Thanks
Kevin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-30  9:05     ` Tian, Kevin
@ 2010-12-30  9:42       ` Lu, Lianhao
  2010-12-30 11:23         ` Tian, Kevin
  0 siblings, 1 reply; 13+ messages in thread
From: Lu, Lianhao @ 2010-12-30  9:42 UTC (permalink / raw)
  To: Tian, Kevin, Tian, Kevin, Richard Purdie; +Cc: poky


Tian, Kevin wrote on 2010-12-30:
>> From: Tian, Kevin
>> Sent: Tuesday, December 28, 2010 11:25 AM
>> 
>>> From: Richard Purdie [mailto:richard.purdie@linuxfoundation.org]
>>> Sent: Friday, December 24, 2010 10:38 PM
>>> 
>>> On Fri, 2010-12-24 at 15:34 +0800, Tian, Kevin wrote:
>>>> I got a confusion about the relationship between
>>>> "--with-gxx-include-dir" and sysroot, and consequently would like to
>>>> discuss one issue it causes.
>>>> 
>>>> GCC installation manual is not very clear about how c++ header
>>>> files are searched when there's no "--with-gxx-include-dir" but with "--sysroot":
>>>> 
>>>> --with-gxx-include-dir=dirname
>>>>     Specify the installation directory for G++ header files. The
>>>> default depends on other configuration options, and differs between
>>>> cross and native configurations.
>>>> 
>>>> My assumption is that ${sysroot}/usr/include/c++ will be searched
>>>> which is why sysroot option is there.
>>> 
>>> This is a bad assumption I'm afraid. I had to go and take a look at
>>> the code to determine this though.
>> 
>> that's why I'm sending this mail to make it clear. :-)
>> 
>>> 
>>>> However currently Poky always specifies "--with-gxx-include-dir" explicitly:
>>>> 
>>>> gcc-configure-cross.inc:
>>>> 
>>>> --with-gxx-include-dir=${STAGING_DIR_TARGET}/${target_includedir}/
>>>> c+
>>>> + \ --with-sysroot=${STAGING_DIR_TARGET} \
>>>> 
>>>> gcc-configure-runtime.inc:
>>>> --with-gxx-include-dir=${includedir}/c++/ \
>>>> --with-sysroot=${STAGING_DIR_TARGET} \
>>>> 
>>>> gcc-configure-sdk.inc:
>>>> 
>>> --with-gxx-include-dir=${SDKPATH}/sysroots/${TARGET_SYS}${target_inc
>>> lu dedir}/c+ + \
>>>> --with-sysroot=${SDKPATH}/sysroots/${TARGET_SYS} \
>>>> 
>>>> gcc-configure-target.inc:
>>>> --with-gxx-include-dir=${includedir}/c++/"
>>>> 
>>>> for cross/sdk, there's no difference from not using option if my
>>>> assumption is correct. The only meaningful one is perhaps runtime.
>>>> 
>>>> I checked OE side, they don't have gcc-runtime (why???), and only
>>>> add the option for the target gcc
>>>> (--with-gxx-include-dir=${includedir}/c++/{BINV}) which makes
>>>> sense since
> using BINV is different from normal convention.
>>> 
>>> Whilst OE doesn't use this, if you read the configure code for this
>>> option you'll see that it gets set to a default anyway so not
>>> specifying it doesn't change much. In poky we dropped the BINV part
>>> of the path which I believe is part of the default.
>> 
>> yes, so far that default has nothing to do with the sysroot option. I
>> made an experiment just now. The default path ends up pointing to:
>> 
>> ${STAGING_DIR_NATIVE}/usr/${TARGET_SYS}/include/c++/${BINV}
>> 
>> which is based on ${libdir}.
>> 
>> So as you said, this doesn't change anything in this point.
>> 
>> BTW is there any other impact of this difference between OE and Poky?
>> I mean installing to native/sdk sysroot(OE) and to target sysroot (poky)...
>> 
>>> 
>>>> So my question is whether it's necessary to explicitly set this
>>>> option in Poky, upon which we can then talk about the issue I'm
>>>> seeing and
> the solution.
>>> 
>>> Looking at the code I don't think it will actually make any
>>> difference whether we set it or not.
>> 
>> Yep
>> 
>>> 
>>>> The major problem with hardcoded "with-gxx-include-dir" is that it
>>>> makes the toolchain problematic when using in a separate build
>>>> environment, because that hard code path may be missing in the new
>>>> environment. It's not relocatable.
>>>> 
>>>> Previous SDK multi-sysroot support is one example.
>>>> 
>>>> So does sstate, when you need to build some new C++ packages in the
>>>> 2nd build dir while using toolchain built from another dir. I
>>>> observed this when reusing a set of sstate packages of a minimal
>>>> image, and then started building a sato image and then encountered
>>>> libproxy error due to failing to find cstdio.
>>>> 
>>>> Machine specific sysroot also has this problem, because we end up
>>>> to use the toolchain built for the 1st machine to build recipes
>>>> for the 2nd machine. It will be generally worked around because
>>>> both sysroots exist and can be both accessed, but it's still a potential issue.
>>>> 
>>>> The workaround in my sstate case is a bit ugly. I have to use "-I"
>>>> in CXXFLAGS in
>>>> bitbake.conf:
>>>> 
>>>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++
>>>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++/backward
>>>> -I${STAGING_DIR_TARGET}/${target_includedir}/c++/${TARGET_SYS}
>>>> 
>>>> If "with-gxx-include-dir" can be removed, we don't need do anything here.
>>> 
>>> I really don't think its this simple.
>>> 
>>> Looking at the gcc code, I propose we patch cppdefault.c so instead
>>> of
>>> 
>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>>> 
>>> is says
>>> 
>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>>> 
>>> and then we only ever specify:
>>> 
>>> --with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>>> 
>>> Since we set always set --sysroot for the compiler correctly, this
>>> should then fix all the problems in a clean and simple way.
>>> 
>>> Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>>> GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to
>>> behave sanely.
>>> 
>>> I don't like patching gcc like this but in this case I believe the
>>> standard settings are just plain wrong and with that simple change,
>>> things will just work as they should...
>>> 
>>> Of course I've not tested this so I'd appreciate feedback but I
>>> think it will solve the problem in the simplest way :)
>>> 
>> 
>> That's a good and simple idea! I'll try it, but the test may take
>> time... :-)
>> 
> 
> I've at least verified this change working in one of my sstate build,
> where c++ include dir could be searched successfully relative to sysroot.
> 
> Lianhao is helping me test SDK multiple sysroot scenario, and I'm
> testing more archs to ensure it not breaking normal build.

The simple helloworld CPP can be built successfully by Kevin's new cross-candian-gcc now. But another complex CPP project Sudoku still have the building problems, complaining about not finding c++ header "#include <algorithm>". The strace output shows that the failure is caused by not finding the algorithm.gch on the target.

> http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/log/?h=tk/cplusplu s
> 

Best Regards,
Lianhao




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-30  9:42       ` Lu, Lianhao
@ 2010-12-30 11:23         ` Tian, Kevin
  2010-12-31  8:52           ` Tian, Kevin
  0 siblings, 1 reply; 13+ messages in thread
From: Tian, Kevin @ 2010-12-30 11:23 UTC (permalink / raw)
  To: Lu, Lianhao, Richard Purdie; +Cc: poky

>From: Lu, Lianhao
>Sent: Thursday, December 30, 2010 5:43 PM
>>>>
>>>> I really don't think its this simple.
>>>>
>>>> Looking at the gcc code, I propose we patch cppdefault.c so instead
>>>> of
>>>>
>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>>>>
>>>> is says
>>>>
>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>>>>
>>>> and then we only ever specify:
>>>>
>>>> --with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>>>>
>>>> Since we set always set --sysroot for the compiler correctly, this
>>>> should then fix all the problems in a clean and simple way.
>>>>
>>>> Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>>>> GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to
>>>> behave sanely.
>>>>
>>>> I don't like patching gcc like this but in this case I believe the
>>>> standard settings are just plain wrong and with that simple change,
>>>> things will just work as they should...
>>>>
>>>> Of course I've not tested this so I'd appreciate feedback but I
>>>> think it will solve the problem in the simplest way :)
>>>>
>>>
>>> That's a good and simple idea! I'll try it, but the test may take
>>> time... :-)
>>>
>>
>> I've at least verified this change working in one of my sstate build,
>> where c++ include dir could be searched successfully relative to sysroot.
>>
>> Lianhao is helping me test SDK multiple sysroot scenario, and I'm
>> testing more archs to ensure it not breaking normal build.
>
>The simple helloworld CPP can be built successfully by Kevin's new cross-candian-gcc now.
>But another complex CPP project Sudoku still have the building problems, complaining about
>not finding c++ header "#include <algorithm>". The strace output shows that the failure
>is caused by not finding the algorithm.gch on the target.
>
>> http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/log/?h=tk/cplusplu s
>>
>

where is that algorithm.gch supposed to stay? I searched my standard c++ include
dir (usr/include/c++) with below finding:

usr/include/c++/ext/algorithm
usr/include/c++/algorithm

is above "algorithm" the one you mentioned as "algorithm.gch"?

Thanks
Kevin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-30 11:23         ` Tian, Kevin
@ 2010-12-31  8:52           ` Tian, Kevin
  2010-12-31  9:26             ` Khem Raj
  0 siblings, 1 reply; 13+ messages in thread
From: Tian, Kevin @ 2010-12-31  8:52 UTC (permalink / raw)
  To: Tian, Kevin, Lu, Lianhao, Richard Purdie; +Cc: poky

>From: Tian, Kevin
>Sent: Thursday, December 30, 2010 7:23 PM
>>From: Lu, Lianhao
>>Sent: Thursday, December 30, 2010 5:43 PM
>>>>>
>>>>> I really don't think its this simple.
>>>>>
>>>>> Looking at the gcc code, I propose we patch cppdefault.c so instead
>>>>> of
>>>>>
>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>>>>>
>>>>> is says
>>>>>
>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>>>>>
>>>>> and then we only ever specify:
>>>>>
>>>>> --with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>>>>>
>>>>> Since we set always set --sysroot for the compiler correctly, this
>>>>> should then fix all the problems in a clean and simple way.
>>>>>
>>>>> Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>>>>> GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to
>>>>> behave sanely.
>>>>>
>>>>> I don't like patching gcc like this but in this case I believe the
>>>>> standard settings are just plain wrong and with that simple change,
>>>>> things will just work as they should...
>>>>>
>>>>> Of course I've not tested this so I'd appreciate feedback but I
>>>>> think it will solve the problem in the simplest way :)
>>>>>
>>>>
>>>> That's a good and simple idea! I'll try it, but the test may take
>>>> time... :-)
>>>>
>>>
>>> I've at least verified this change working in one of my sstate build,
>>> where c++ include dir could be searched successfully relative to sysroot.
>>>
>>> Lianhao is helping me test SDK multiple sysroot scenario, and I'm
>>> testing more archs to ensure it not breaking normal build.
>>
>>The simple helloworld CPP can be built successfully by Kevin's new cross-candian-gcc now.
>>But another complex CPP project Sudoku still have the building problems, complaining
>about
>>not finding c++ header "#include <algorithm>". The strace output shows that the failure
>>is caused by not finding the algorithm.gch on the target.
>>
>>> http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/log/?h=tk/cplusplu s
>>>
>>
>
>where is that algorithm.gch supposed to stay? I searched my standard c++ include
>dir (usr/include/c++) with below finding:
>
>usr/include/c++/ext/algorithm
>usr/include/c++/algorithm
>
>is above "algorithm" the one you mentioned as "algorithm.gch"?
>

This turns out related to collect2. Actually the compilation already reached the last step,
where all generated .o are linked together as one executable. This step collect2 is invoked
implicitly to handle constructor functions. Not sure the reason yet, I saw that collect2 
wants to recompile workset.o for whatever reasons. Unfortunately this recompilation is
invoked w/o "--sysroot" option, and thus no c++ header files could be located.

I'm still investigating why this recompilation is triggered, and how collect2 constructs
the build flags implicitly...

Thanks
Kevin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-31  8:52           ` Tian, Kevin
@ 2010-12-31  9:26             ` Khem Raj
  2010-12-31  9:43               ` Tian, Kevin
  0 siblings, 1 reply; 13+ messages in thread
From: Khem Raj @ 2010-12-31  9:26 UTC (permalink / raw)
  To: Tian, Kevin; +Cc: poky

On Fri, Dec 31, 2010 at 12:52 AM, Tian, Kevin <kevin.tian@intel.com> wrote:
>>From: Tian, Kevin
>>Sent: Thursday, December 30, 2010 7:23 PM
>>>From: Lu, Lianhao
>>>Sent: Thursday, December 30, 2010 5:43 PM
>>>>>>
>>>>>> I really don't think its this simple.
>>>>>>
>>>>>> Looking at the gcc code, I propose we patch cppdefault.c so instead
>>>>>> of
>>>>>>
>>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>>>>>>
>>>>>> is says
>>>>>>
>>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>>>>>>
>>>>>> and then we only ever specify:
>>>>>>
>>>>>> --with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>>>>>>
>>>>>> Since we set always set --sysroot for the compiler correctly, this
>>>>>> should then fix all the problems in a clean and simple way.
>>>>>>
>>>>>> Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>>>>>> GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to
>>>>>> behave sanely.
>>>>>>
>>>>>> I don't like patching gcc like this but in this case I believe the
>>>>>> standard settings are just plain wrong and with that simple change,
>>>>>> things will just work as they should...
>>>>>>
>>>>>> Of course I've not tested this so I'd appreciate feedback but I
>>>>>> think it will solve the problem in the simplest way :)
>>>>>>
>>>>>
>>>>> That's a good and simple idea! I'll try it, but the test may take
>>>>> time... :-)
>>>>>
>>>>
>>>> I've at least verified this change working in one of my sstate build,
>>>> where c++ include dir could be searched successfully relative to sysroot.
>>>>
>>>> Lianhao is helping me test SDK multiple sysroot scenario, and I'm
>>>> testing more archs to ensure it not breaking normal build.
>>>
>>>The simple helloworld CPP can be built successfully by Kevin's new cross-candian-gcc now.
>>>But another complex CPP project Sudoku still have the building problems, complaining
>>about
>>>not finding c++ header "#include <algorithm>". The strace output shows that the failure
>>>is caused by not finding the algorithm.gch on the target.
>>>
>>>> http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/log/?h=tk/cplusplu s
>>>>
>>>
>>
>>where is that algorithm.gch supposed to stay? I searched my standard c++ include
>>dir (usr/include/c++) with below finding:
>>
>>usr/include/c++/ext/algorithm
>>usr/include/c++/algorithm
>>
>>is above "algorithm" the one you mentioned as "algorithm.gch"?
>>
>
> This turns out related to collect2. Actually the compilation already reached the last step,
> where all generated .o are linked together as one executable. This step collect2 is invoked
> implicitly to handle constructor functions. Not sure the reason yet, I saw that collect2
> wants to recompile workset.o for whatever reasons. Unfortunately this recompilation is
> invoked w/o "--sysroot" option, and thus no c++ header files could be located.
>
> I'm still investigating why this recompilation is triggered, and how collect2 constructs
> the build flags implicitly...

the project is using precompiled headers and the build system
of the package should regenerate them if they are not found. Its
nothing that gcc can do about. You can either fix the build system
of package in question or stop generating precompiled headers.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-31  9:26             ` Khem Raj
@ 2010-12-31  9:43               ` Tian, Kevin
  2010-12-31  9:49                 ` Tian, Kevin
  0 siblings, 1 reply; 13+ messages in thread
From: Tian, Kevin @ 2010-12-31  9:43 UTC (permalink / raw)
  To: Khem Raj; +Cc: poky

>From: Khem Raj [mailto:raj.khem@gmail.com]
>Sent: Friday, December 31, 2010 5:26 PM
>
>On Fri, Dec 31, 2010 at 12:52 AM, Tian, Kevin <kevin.tian@intel.com> wrote:
>>>From: Tian, Kevin
>>>Sent: Thursday, December 30, 2010 7:23 PM
>>>>From: Lu, Lianhao
>>>>Sent: Thursday, December 30, 2010 5:43 PM
>>>>>>>
>>>>>>> I really don't think its this simple.
>>>>>>>
>>>>>>> Looking at the gcc code, I propose we patch cppdefault.c so instead
>>>>>>> of
>>>>>>>
>>>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>>>>>>>
>>>>>>> is says
>>>>>>>
>>>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>>>>>>>
>>>>>>> and then we only ever specify:
>>>>>>>
>>>>>>> --with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>>>>>>>
>>>>>>> Since we set always set --sysroot for the compiler correctly, this
>>>>>>> should then fix all the problems in a clean and simple way.
>>>>>>>
>>>>>>> Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>>>>>>> GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to
>>>>>>> behave sanely.
>>>>>>>
>>>>>>> I don't like patching gcc like this but in this case I believe the
>>>>>>> standard settings are just plain wrong and with that simple change,
>>>>>>> things will just work as they should...
>>>>>>>
>>>>>>> Of course I've not tested this so I'd appreciate feedback but I
>>>>>>> think it will solve the problem in the simplest way :)
>>>>>>>
>>>>>>
>>>>>> That's a good and simple idea! I'll try it, but the test may take
>>>>>> time... :-)
>>>>>>
>>>>>
>>>>> I've at least verified this change working in one of my sstate build,
>>>>> where c++ include dir could be searched successfully relative to sysroot.
>>>>>
>>>>> Lianhao is helping me test SDK multiple sysroot scenario, and I'm
>>>>> testing more archs to ensure it not breaking normal build.
>>>>
>>>>The simple helloworld CPP can be built successfully by Kevin's new cross-candian-gcc
>now.
>>>>But another complex CPP project Sudoku still have the building problems, complaining
>>>about
>>>>not finding c++ header "#include <algorithm>". The strace output shows that the
>failure
>>>>is caused by not finding the algorithm.gch on the target.
>>>>
>>>>> http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/log/?h=tk/cplusplu s
>>>>>
>>>>
>>>
>>>where is that algorithm.gch supposed to stay? I searched my standard c++ include
>>>dir (usr/include/c++) with below finding:
>>>
>>>usr/include/c++/ext/algorithm
>>>usr/include/c++/algorithm
>>>
>>>is above "algorithm" the one you mentioned as "algorithm.gch"?
>>>
>>
>> This turns out related to collect2. Actually the compilation already reached the last step,
>> where all generated .o are linked together as one executable. This step collect2 is invoked
>> implicitly to handle constructor functions. Not sure the reason yet, I saw that collect2
>> wants to recompile workset.o for whatever reasons. Unfortunately this recompilation is
>> invoked w/o "--sysroot" option, and thus no c++ header files could be located.
>>
>> I'm still investigating why this recompilation is triggered, and how collect2 constructs
>> the build flags implicitly...
>
>the project is using precompiled headers and the build system
>of the package should regenerate them if they are not found. Its
>nothing that gcc can do about. You can either fix the build system
>of package in question or stop generating precompiled headers.

what do you mean by "precompiled headers"? I think the missing <iostream> or
<algorithm> here is the standard header. Actually same workset.cpp has been
compiled successfully before the link stage. The question is how collect2 misses
the --sysroot option when triggering the recompilation...

Thanks
Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-31  9:43               ` Tian, Kevin
@ 2010-12-31  9:49                 ` Tian, Kevin
  2011-01-11  7:36                   ` Tian, Kevin
  0 siblings, 1 reply; 13+ messages in thread
From: Tian, Kevin @ 2010-12-31  9:49 UTC (permalink / raw)
  To: Tian, Kevin, Khem Raj; +Cc: poky

>From: Tian, Kevin
>Sent: Friday, December 31, 2010 5:44 PM
>
>>From: Khem Raj [mailto:raj.khem@gmail.com]
>>Sent: Friday, December 31, 2010 5:26 PM
>>
>>On Fri, Dec 31, 2010 at 12:52 AM, Tian, Kevin <kevin.tian@intel.com> wrote:
>>>>From: Tian, Kevin
>>>>Sent: Thursday, December 30, 2010 7:23 PM
>>>>>From: Lu, Lianhao
>>>>>Sent: Thursday, December 30, 2010 5:43 PM
>>>>>>>>
>>>>>>>> I really don't think its this simple.
>>>>>>>>
>>>>>>>> Looking at the gcc code, I propose we patch cppdefault.c so instead
>>>>>>>> of
>>>>>>>>
>>>>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>>>>>>>>
>>>>>>>> is says
>>>>>>>>
>>>>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>>>>>>>>
>>>>>>>> and then we only ever specify:
>>>>>>>>
>>>>>>>> --with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>>>>>>>>
>>>>>>>> Since we set always set --sysroot for the compiler correctly, this
>>>>>>>> should then fix all the problems in a clean and simple way.
>>>>>>>>
>>>>>>>> Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>>>>>>>> GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to
>>>>>>>> behave sanely.
>>>>>>>>
>>>>>>>> I don't like patching gcc like this but in this case I believe the
>>>>>>>> standard settings are just plain wrong and with that simple change,
>>>>>>>> things will just work as they should...
>>>>>>>>
>>>>>>>> Of course I've not tested this so I'd appreciate feedback but I
>>>>>>>> think it will solve the problem in the simplest way :)
>>>>>>>>
>>>>>>>
>>>>>>> That's a good and simple idea! I'll try it, but the test may take
>>>>>>> time... :-)
>>>>>>>
>>>>>>
>>>>>> I've at least verified this change working in one of my sstate build,
>>>>>> where c++ include dir could be searched successfully relative to sysroot.
>>>>>>
>>>>>> Lianhao is helping me test SDK multiple sysroot scenario, and I'm
>>>>>> testing more archs to ensure it not breaking normal build.
>>>>>
>>>>>The simple helloworld CPP can be built successfully by Kevin's new cross-candian-gcc
>>now.
>>>>>But another complex CPP project Sudoku still have the building problems, complaining
>>>>about
>>>>>not finding c++ header "#include <algorithm>". The strace output shows that the
>>failure
>>>>>is caused by not finding the algorithm.gch on the target.
>>>>>
>>>>>> http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/log/?h=tk/cplusplu s
>>>>>>
>>>>>
>>>>
>>>>where is that algorithm.gch supposed to stay? I searched my standard c++ include
>>>>dir (usr/include/c++) with below finding:
>>>>
>>>>usr/include/c++/ext/algorithm
>>>>usr/include/c++/algorithm
>>>>
>>>>is above "algorithm" the one you mentioned as "algorithm.gch"?
>>>>
>>>
>>> This turns out related to collect2. Actually the compilation already reached the last step,
>>> where all generated .o are linked together as one executable. This step collect2 is
>invoked
>>> implicitly to handle constructor functions. Not sure the reason yet, I saw that collect2
>>> wants to recompile workset.o for whatever reasons. Unfortunately this recompilation
>is
>>> invoked w/o "--sysroot" option, and thus no c++ header files could be located.
>>>
>>> I'm still investigating why this recompilation is triggered, and how collect2 constructs
>>> the build flags implicitly...
>>
>>the project is using precompiled headers and the build system
>>of the package should regenerate them if they are not found. Its
>>nothing that gcc can do about. You can either fix the build system
>>of package in question or stop generating precompiled headers.
>
>what do you mean by "precompiled headers"? I think the missing <iostream> or
><algorithm> here is the standard header. Actually same workset.cpp has been
>compiled successfully before the link stage. The question is how collect2 misses
>the --sysroot option when triggering the recompilation...
>

well, it looks that the compile options come from workset.rpo, which I need figure out
how it's generated. If it's the project's own build logic to generate that file by missing
sysroot option, then as you said this problem is specific to this project. If the .rpo is
some standard temp files generated by g++, then it'd be related to gcc imo...

Thanks
Kevin


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-24 14:37 ` Richard Purdie
  2010-12-28  3:24   ` Tian, Kevin
@ 2010-12-31 10:01   ` Khem Raj
  2011-01-01  1:12     ` Richard Purdie
  1 sibling, 1 reply; 13+ messages in thread
From: Khem Raj @ 2010-12-31 10:01 UTC (permalink / raw)
  To: Richard Purdie; +Cc: poky

> I really don't think its this simple.
>
> Looking at the gcc code, I propose we patch cppdefault.c so instead of
>
> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>
> is says
>
> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0

This looks ok fix if you take care of doing it only for case
when sysroot is set and its cross compiling.Although I wonder
if this will also alter the install location of the headers


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-31 10:01   ` Khem Raj
@ 2011-01-01  1:12     ` Richard Purdie
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Purdie @ 2011-01-01  1:12 UTC (permalink / raw)
  To: Khem Raj; +Cc: poky

On Fri, 2010-12-31 at 02:01 -0800, Khem Raj wrote:
> > I really don't think its this simple.
> >
> > Looking at the gcc code, I propose we patch cppdefault.c so instead of
> >
> > GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
> >
> > is says
> >
> > GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
> 
> This looks ok fix if you take care of doing it only for case
> when sysroot is set and its cross compiling.Although I wonder
> if this will also alter the install location of the headers

In Poky the sysroot option is always set since the sstate packages
including the -cross ones can relocate. It shouldn't matter that we set
this even in the native case since there isn't a sysroot set there.

I wonder how receptive upstream would be to fixing this there...

Cheers,

Richard



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: --with-gxx-include-dir and sysroot
  2010-12-31  9:49                 ` Tian, Kevin
@ 2011-01-11  7:36                   ` Tian, Kevin
  0 siblings, 0 replies; 13+ messages in thread
From: Tian, Kevin @ 2011-01-11  7:36 UTC (permalink / raw)
  To: Khem Raj; +Cc: poky

The Sudoku problem ends up to be a gcc bug. Sudoku uses templates and "-frepo"
to enabled automatic template generation. Collect2 may trigger some recompilations
based on template usages at link time. The compile flags of collect2 comes from
COLLECT_GCC_OPTIONS, which contain most flags passed from gcc switches. However
"--sysroot" doesn't fall into saved switches which are simply ignored. It's also not
solved in the trunk yet.

I've filed a gcc bug for it:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47256

Thanks
Kevin

>From: Tian, Kevin
>Sent: Friday, December 31, 2010 5:50 PM
>
>>From: Tian, Kevin
>>Sent: Friday, December 31, 2010 5:44 PM
>>
>>>From: Khem Raj [mailto:raj.khem@gmail.com]
>>>Sent: Friday, December 31, 2010 5:26 PM
>>>
>>>On Fri, Dec 31, 2010 at 12:52 AM, Tian, Kevin <kevin.tian@intel.com> wrote:
>>>>>From: Tian, Kevin
>>>>>Sent: Thursday, December 30, 2010 7:23 PM
>>>>>>From: Lu, Lianhao
>>>>>>Sent: Thursday, December 30, 2010 5:43 PM
>>>>>>>>>
>>>>>>>>> I really don't think its this simple.
>>>>>>>>>
>>>>>>>>> Looking at the gcc code, I propose we patch cppdefault.c so instead
>>>>>>>>> of
>>>>>>>>>
>>>>>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 0, 0
>>>>>>>>>
>>>>>>>>> is says
>>>>>>>>>
>>>>>>>>> GPLUSPLUS_INCLUDE_DIR "G++", 1, 1, 1, 0
>>>>>>>>>
>>>>>>>>> and then we only ever specify:
>>>>>>>>>
>>>>>>>>> --with-gxx-include-dir=${includedir}/c++/ to build the compiler.
>>>>>>>>>
>>>>>>>>> Since we set always set --sysroot for the compiler correctly, this
>>>>>>>>> should then fix all the problems in a clean and simple way.
>>>>>>>>>
>>>>>>>>> Why? Changing the 0 -> 1 above will cause c++ to add the sysroot to
>>>>>>>>> GPLUSPLUS_INCLUDE_DIR and in turn this means it should start to
>>>>>>>>> behave sanely.
>>>>>>>>>
>>>>>>>>> I don't like patching gcc like this but in this case I believe the
>>>>>>>>> standard settings are just plain wrong and with that simple change,
>>>>>>>>> things will just work as they should...
>>>>>>>>>
>>>>>>>>> Of course I've not tested this so I'd appreciate feedback but I
>>>>>>>>> think it will solve the problem in the simplest way :)
>>>>>>>>>
>>>>>>>>
>>>>>>>> That's a good and simple idea! I'll try it, but the test may take
>>>>>>>> time... :-)
>>>>>>>>
>>>>>>>
>>>>>>> I've at least verified this change working in one of my sstate build,
>>>>>>> where c++ include dir could be searched successfully relative to sysroot.
>>>>>>>
>>>>>>> Lianhao is helping me test SDK multiple sysroot scenario, and I'm
>>>>>>> testing more archs to ensure it not breaking normal build.
>>>>>>
>>>>>>The simple helloworld CPP can be built successfully by Kevin's new
>cross-candian-gcc
>>>now.
>>>>>>But another complex CPP project Sudoku still have the building problems,
>complaining
>>>>>about
>>>>>>not finding c++ header "#include <algorithm>". The strace output shows that the
>>>failure
>>>>>>is caused by not finding the algorithm.gch on the target.
>>>>>>
>>>>>>> http://git.pokylinux.org/cgit/cgit.cgi/poky-contrib/log/?h=tk/cplusplu s
>>>>>>>
>>>>>>
>>>>>
>>>>>where is that algorithm.gch supposed to stay? I searched my standard c++ include
>>>>>dir (usr/include/c++) with below finding:
>>>>>
>>>>>usr/include/c++/ext/algorithm
>>>>>usr/include/c++/algorithm
>>>>>
>>>>>is above "algorithm" the one you mentioned as "algorithm.gch"?
>>>>>
>>>>
>>>> This turns out related to collect2. Actually the compilation already reached the last
>step,
>>>> where all generated .o are linked together as one executable. This step collect2 is
>>invoked
>>>> implicitly to handle constructor functions. Not sure the reason yet, I saw that collect2
>>>> wants to recompile workset.o for whatever reasons. Unfortunately this recompilation
>>is
>>>> invoked w/o "--sysroot" option, and thus no c++ header files could be located.
>>>>
>>>> I'm still investigating why this recompilation is triggered, and how collect2 constructs
>>>> the build flags implicitly...
>>>
>>>the project is using precompiled headers and the build system
>>>of the package should regenerate them if they are not found. Its
>>>nothing that gcc can do about. You can either fix the build system
>>>of package in question or stop generating precompiled headers.
>>
>>what do you mean by "precompiled headers"? I think the missing <iostream> or
>><algorithm> here is the standard header. Actually same workset.cpp has been
>>compiled successfully before the link stage. The question is how collect2 misses
>>the --sysroot option when triggering the recompilation...
>>
>
>well, it looks that the compile options come from workset.rpo, which I need figure out
>how it's generated. If it's the project's own build logic to generate that file by missing
>sysroot option, then as you said this problem is specific to this project. If the .rpo is
>some standard temp files generated by g++, then it'd be related to gcc imo...
>
>Thanks
>Kevin


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-01-11  7:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-24  7:34 --with-gxx-include-dir and sysroot Tian, Kevin
2010-12-24 14:37 ` Richard Purdie
2010-12-28  3:24   ` Tian, Kevin
2010-12-30  9:05     ` Tian, Kevin
2010-12-30  9:42       ` Lu, Lianhao
2010-12-30 11:23         ` Tian, Kevin
2010-12-31  8:52           ` Tian, Kevin
2010-12-31  9:26             ` Khem Raj
2010-12-31  9:43               ` Tian, Kevin
2010-12-31  9:49                 ` Tian, Kevin
2011-01-11  7:36                   ` Tian, Kevin
2010-12-31 10:01   ` Khem Raj
2011-01-01  1:12     ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.