Skip to contentSkip to conversation

I am confused by the combination of using "?=" and an override

DISCUSSION Robert P. J. Day 2 participants 3 messages May 21

lore
Share & tools
lore
#0 lore raw

I may have totally misunderstood something basic all this time, but
this seems like something that needs a clearer explanation if it's not explained forcefully.

In a current build, I set a debugging variable thusly in my
local.conf:

ST_OPTEE_CORE_DEBUG = "y"

assuming that any ST-layer processing would honour the fact that I explicitly gave it a value. However, when I checked the eventual value:

$ bitbake-getvar -r optee-os-stm32mp ST_OPTEE_CORE_DEBUG
#
# $ST_OPTEE_CORE_DEBUG [3 operations]
#   set /home/rpjday/BOARDS/nexus/wrynose/build/conf/local.conf:14
#     "y"
#   set
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:37
#     [_defaultval] "y"
#   override[stm32mp15common]:set?
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:38
#     "n"
# pre-expansion value:
#   "n"
ST_OPTEE_CORE_DEBUG="n"

Huh? That output clearly shows that I set the value first, but it
was set back based on these two lines in that file:

ST_OPTEE_CORE_DEBUG ??= "y"
ST_OPTEE_CORE_DEBUG:stm32mp15common ?= "n"

Apparently, even though I set the variable myself, that override assignment was setting it back to "n" -- not what I expected even though that override was in effect.

On a hunch, I used this assignment instead:

ST_OPTEE_CORE_DEBUG:stm32mp15common = "y"

and it worked:

# $ST_OPTEE_CORE_DEBUG [3 operations]
# set
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:37
# [_defaultval] "y"
# override[stm32mp15common]:set
/home/rpjday/BOARDS/nexus/wrynose/build/conf/local.conf:13
# "y"
# override[stm32mp15common]:set?
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:38
# "n"

# pre-expansion value:
#   "y"
ST_OPTEE_CORE_DEBUG="y"

That is *not* what I expected -- I thought that once I assigned a value to that variable, no combination of "?=" or "??=" assignments could affect it, but apparently I was wrong.

Is this the expected behaviour? Because it caught me by surprise,
and if this is the way it works, it definitely needs to be documented.

rday

#1 lore raw
Quoted 30 lines · Robert P. J. Day

I may have totally misunderstood something basic all this time, but
this seems like something that needs a clearer explanation if it's not explained forcefully.

In a current build, I set a debugging variable thusly in my
local.conf:

ST_OPTEE_CORE_DEBUG = "y"

assuming that any ST-layer processing would honour the fact that I explicitly gave it a value. However, when I checked the eventual value:

$ bitbake-getvar -r optee-os-stm32mp ST_OPTEE_CORE_DEBUG
#
# $ST_OPTEE_CORE_DEBUG [3 operations]
#   set /home/rpjday/BOARDS/nexus/wrynose/build/conf/local.conf:14
#     "y"
#   set
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:37
#     [_defaultval] "y"
#   override[stm32mp15common]:set?
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:38
#     "n"
# pre-expansion value:
#   "n"
ST_OPTEE_CORE_DEBUG="n"
Quoted 5 lines

Huh? That output clearly shows that I set the value first, but it
was set back based on these two lines in that file:

ST_OPTEE_CORE_DEBUG ??= "y"
ST_OPTEE_CORE_DEBUG:stm32mp15common ?= "n"

The above is saying that the _override_ value:

ST_OPTEE_CORE_DEBUG:stm32mp15common is set to "n" if not otherwise set.

The override (stm32mp15common) is always processed separately after the override value itself is established.

Quoted 7 lines

Apparently, even though I set the variable myself, that override assignment was setting it back to "n" -- not what I expected even though that override was in effect.

On a hunch, I used this assignment instead:

ST_OPTEE_CORE_DEBUG:stm32mp15common = "y"

So if you do:

MY_VAR ?? = "y"
MY_VAR:MY_OVERRIDE ?= "n"

The system will process it as:

MY_VAR = "y"
MY_VAR:MY_OVERRIDE = "n"

<process overrides>

MY_VAR = "n"

So then if the user sets:

MY_VAR = "1"

same sort of behavior:

MY_VAR = "1"
MY_VAR:MY_OVERRIDE = "n"

<process overrides>

MY_VAR = "n"

So in order to affect the variable MY_VAR:MY_OVERRIDE, you need to specifically set that.

This is the reason your change above worked.

Quoted 12 lines

and it worked:

# $ST_OPTEE_CORE_DEBUG [3 operations]
# set
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:37
# [_defaultval] "y"
# override[stm32mp15common]:set
/home/rpjday/BOARDS/nexus/wrynose/build/conf/local.conf:13
# "y"
# override[stm32mp15common]:set?
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:38
# "n"

Quoted 8 lines
# pre-expansion value:
#   "y"
ST_OPTEE_CORE_DEBUG="y"

That is *not* what I expected -- I thought that once I assigned a value to that variable, no combination of "?=" or "??=" assignments could affect it, but apparently I was wrong.

You have to remember override variables are themselves variables. Overrides are processed _AFTER_ all of the values are established.

Quoted 2 lines

Is this the expected behaviour? Because it caught me by surprise,
and if this is the way it works, it definitely needs to be documented.

Yes, this is expected behavior.

Quoted 12 lines

rday

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9517): https://lists.yoctoproject.org/g/docs/message/9517
Mute This Topic: https://lists.yoctoproject.org/mt/119425911/3616948
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/docs/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 110 lines · Mark Hatle
Quoted 30 lines · Robert P. J. Day

I may have totally misunderstood something basic all this time, but
this seems like something that needs a clearer explanation if it's not explained forcefully.

In a current build, I set a debugging variable thusly in my
local.conf:

ST_OPTEE_CORE_DEBUG = "y"

assuming that any ST-layer processing would honour the fact that I explicitly gave it a value. However, when I checked the eventual value:

$ bitbake-getvar -r optee-os-stm32mp ST_OPTEE_CORE_DEBUG
#
# $ST_OPTEE_CORE_DEBUG [3 operations]
#   set /home/rpjday/BOARDS/nexus/wrynose/build/conf/local.conf:14
#     "y"
#   set
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:37
#     [_defaultval] "y"
#   override[stm32mp15common]:set?
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:38
#     "n"
# pre-expansion value:
#   "n"
ST_OPTEE_CORE_DEBUG="n"
Quoted 5 lines

Huh? That output clearly shows that I set the value first, but it
was set back based on these two lines in that file:

ST_OPTEE_CORE_DEBUG ??= "y"
ST_OPTEE_CORE_DEBUG:stm32mp15common ?= "n"

The above is saying that the _override_ value:

ST_OPTEE_CORE_DEBUG:stm32mp15common is set to "n" if not otherwise set.

The override (stm32mp15common) is always processed separately after the override value itself is established.

Quoted 7 lines

Apparently, even though I set the variable myself, that override assignment was setting it back to "n" -- not what I expected even though that override was in effect.

On a hunch, I used this assignment instead:

ST_OPTEE_CORE_DEBUG:stm32mp15common = "y"

So if you do:

MY_VAR ?? = "y"
MY_VAR:MY_OVERRIDE ?= "n"

The system will process it as:

MY_VAR = "y"
MY_VAR:MY_OVERRIDE = "n"

<process overrides>

MY_VAR = "n"

So then if the user sets:

MY_VAR = "1"

same sort of behavior:

MY_VAR = "1"
MY_VAR:MY_OVERRIDE = "n"

<process overrides>

MY_VAR = "n"

So in order to affect the variable MY_VAR:MY_OVERRIDE, you need to specifically set that.

This is the reason your change above worked.

Quoted 12 lines

and it worked:

# $ST_OPTEE_CORE_DEBUG [3 operations]
# set
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:37
# [_defaultval] "y"
# override[stm32mp15common]:set
/home/rpjday/BOARDS/nexus/wrynose/build/conf/local.conf:13
# "y"
# override[stm32mp15common]:set?
/home/rpjday/Layers/wrynose/st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp-common.inc:38
# "n"

Quoted 8 lines
# pre-expansion value:
#   "y"
ST_OPTEE_CORE_DEBUG="y"

That is *not* what I expected -- I thought that once I assigned a value to that variable, no combination of "?=" or "??=" assignments could affect it, but apparently I was wrong.

Quoted 7 lines

You have to remember override variables are themselves variables. Overrides are processed _AFTER_ all of the values are established.

Quoted 2 lines

Is this the expected behaviour? Because it caught me by surprise,
and if this is the way it works, it definitely needs to be documented.

Yes, this is expected behavior.

Thanks, I knew most of that, I just never ran into precisely
this situation. I will be far more careful about this in the future.

rday