[OE-core] TARGET_CFLAGS for non-target builds

Mark Hatle mark.hatle at windriver.com
Tue Feb 9 00:01:17 UTC 2016


On 2/8/16 5:43 PM, Andre McCurdy wrote:
> On Mon, Feb 8, 2016 at 3:00 PM, Burton, Ross <ross.burton at intel.com> wrote:
>>
>> On 8 February 2016 at 20:03, Andre McCurdy <armccurdy at gmail.com> wrote:
>>>
>>> Can you give an example? Looking at native.bbclass it seems to replace
>>> TARGET_CFLAGS with BUILD_CFLAGS, not manipulate it.
>>
>> Sure, so in doing a native build TARGET_CFLAGS is used.  But as
>> security_flags.inc was using TARGET_CFLAGS_append, the end result was
>> BUILD_CFLAGS appended with the security flags.
> 
> Yes, for native, TARGET_CFLAGS will end up being "${BUILD_CFLAGS}
> ${SECURITY_CFLAGS}".
> 
> However it shouldn't matter - native.bbclass sets CFLAGS to
> BUILD_CFLAGS, not TARGET_CFLAGS.
> 
> Do you have an example where host gcc can legitimately be invoked with
> TARGET_CFLAGS?

You have to remember the order of the operators.  _append says to make the
append, AFTER everything else has been evaluated (and before _remove).  This
includes override behaviors.

So if you do:

TARGET_CFLAGS = "-deadbeef"
BUILD_CFLAGS = "-badc0ffee"
TARGET_CFLAGS_append = " -foobar"
TARGET_CFLAGS = "${BUILD_CFLAGS}"

The final value of TARGET_CFLAGS is "-badc0ffee -foobar"

Thus by changing the append to:

TARGET_CFLAGS_append_class-target = " -foobar"
TARGET_CFLAGS_class-native = "${BUILD_CFLAGS}"

In the case where the 'class-target' is the override you will get:

TARGET_CFLAGS = "-deadbeef -foobar"

In the case where the 'class-native' is the override you will get:

TARGET_CFLAGS = "-badc0ffee"

--Mark



More information about the Openembedded-core mailing list