crossvars.bbclass: use d.appendVar instead of d.setVar for SDK_TOOLCHAIN variable

Message ID 20230522044117.1698718-1-srinuvasan_a@mentor.com
State Superseded, archived
Headers show
Series crossvars.bbclass: use d.appendVar instead of d.setVar for SDK_TOOLCHAIN variable | expand

Commit Message

Srinuvasan Arjunan May 22, 2023, 4:41 a.m. UTC
From: Srinuvasan A <srinuvasan.a@siemens.com>

In downstream layer we may override the sdk_toolchain, but this not works as
expected in latest ISAR, the reason behind this as they moved toolchain
selection into python Anonymous function.

Anonymous Python functions always run at the end of parsing, regardless of where they are defined
even when we do override in our recipe, always wins the Anonymous Python
functions variable settings, hence change to d.appendVar instead of
d.setVar in sdk toolchain selection, so downstream layer they can modify the
SDK_TOOLCHAIN list if needed (append/remove).

Signed-off-by: Srinuvasan A <srinuvasan.a@siemens.com>
---
 meta/classes/crossvars.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jan Kiszka May 22, 2023, 5:16 a.m. UTC | #1
On 22.05.23 06:41, Srinuvasan Arjunan wrote:
> From: Srinuvasan A <srinuvasan.a@siemens.com>
> 
> In downstream layer we may override the sdk_toolchain, but this not works as
> expected in latest ISAR, the reason behind this as they moved toolchain
> selection into python Anonymous function.

Dod you want to append or do you want to replac SDK_TOOLCHAIN in
downstream? In the latter case, we likely rather want to make our
assignment in isar weak, no?

if not d.getVar('SDK_TOOLCHAIN'):
    ...

Jan

> 
> Anonymous Python functions always run at the end of parsing, regardless of where they are defined
> even when we do override in our recipe, always wins the Anonymous Python
> functions variable settings, hence change to d.appendVar instead of
> d.setVar in sdk toolchain selection, so downstream layer they can modify the
> SDK_TOOLCHAIN list if needed (append/remove).
> 
> Signed-off-by: Srinuvasan A <srinuvasan.a@siemens.com>
> ---
>  meta/classes/crossvars.bbclass | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/crossvars.bbclass b/meta/classes/crossvars.bbclass
> index 201d460..5a3edc4 100644
> --- a/meta/classes/crossvars.bbclass
> +++ b/meta/classes/crossvars.bbclass
> @@ -17,7 +17,7 @@ python __anonymous() {
>          sbuild_dep = "sbuild-chroot-target:do_build"
>          buildchroot_dir = d.getVar('BUILDCHROOT_TARGET_DIR', False)
>          buildchroot_dep = "buildchroot-target:do_build"
> -        sdk_toolchain = "build-essential"
> +        sdk_toolchain = " build-essential"
>      else:
>          d.setVar('BUILD_HOST_ARCH', d.getVar('HOST_ARCH'))
>          schroot_dir = d.getVar('SCHROOT_HOST_DIR', False)
> @@ -31,5 +31,5 @@ python __anonymous() {
>      d.setVar('BUILDCHROOT_DEP', buildchroot_dep)
>      if isar_can_build_compat(d):
>          sdk_toolchain += " crossbuild-essential-" + d.getVar('COMPAT_DISTRO_ARCH')
> -    d.setVar('SDK_TOOLCHAIN', sdk_toolchain)
> +    d.appendVar('SDK_TOOLCHAIN', sdk_toolchain)
>  }
Jan Kiszka May 22, 2023, 5:54 a.m. UTC | #2
On 22.05.23 07:16, 'Jan Kiszka' via isar-users wrote:
> On 22.05.23 06:41, Srinuvasan Arjunan wrote:
>> From: Srinuvasan A <srinuvasan.a@siemens.com>
>>
>> In downstream layer we may override the sdk_toolchain, but this not works as
>> expected in latest ISAR, the reason behind this as they moved toolchain
>> selection into python Anonymous function.
> 
> Dod you want to append or do you want to replac SDK_TOOLCHAIN in
> downstream? In the latter case, we likely rather want to make our
> assignment in isar weak, no?
> 
> if not d.getVar('SDK_TOOLCHAIN'):
>     ...
> 

Also to answer: Why is SDK_PREINSTALL insufficient for your customization?

Jan
Srinuvasan Arjunan May 25, 2023, 4:53 a.m. UTC | #3
On Monday, May 22, 2023 at 11:24:53 AM UTC+5:30 Jan Kiszka wrote:

On 22.05.23 07:16, 'Jan Kiszka' via isar-users wrote: 
> On 22.05.23 06:41, Srinuvasan Arjunan wrote: 
>> From: Srinuvasan A <srinuv...@siemens.com> 
>> 
>> In downstream layer we may override the sdk_toolchain, but this not 
works as 
>> expected in latest ISAR, the reason behind this as they moved toolchain 
>> selection into python Anonymous function. 
> 
> Dod you want to append or do you want to replac SDK_TOOLCHAIN in 
> downstream? In the latter case, we likely rather want to make our 
> assignment in isar weak, no? 
> 
> if not d.getVar('SDK_TOOLCHAIN'): 
> ... 
> 

Also to answer: Why is SDK_PREINSTALL insufficient for your customization? 

Jan
Jan Kiszka May 25, 2023, 10:20 a.m. UTC | #4
On 25.05.23 06:53, Srinuvasan Arjunan wrote:
> 
> 
> On Monday, May 22, 2023 at 11:24:53 AM UTC+5:30 Jan Kiszka wrote:
> 
>     On 22.05.23 07:16, 'Jan Kiszka' via isar-users wrote:
>     > On 22.05.23 06:41, Srinuvasan Arjunan wrote:
>     >> From: Srinuvasan A <srinuv...@siemens.com>
>     >>
>     >> In downstream layer we may override the sdk_toolchain, but this
>     not works as
>     >> expected in latest ISAR, the reason behind this as they moved
>     toolchain
>     >> selection into python Anonymous function.
>     >
>     > Dod you want to append or do you want to replac SDK_TOOLCHAIN in
>     > downstream? In the latter case, we likely rather want to make our
>     > assignment in isar weak, no?
>     >
>     > if not d.getVar('SDK_TOOLCHAIN'):
>     > ...
>     >
> 
>     Also to answer: Why is SDK_PREINSTALL insufficient for your
>     customization?
> 
>     Jan
> 
>     -- 
>     Siemens AG, Technology
>     Competence Center Embedded Linux
> 
>  
> 
>     yes we can append our toolchain via SDK_PREINSTALL, but i need to
> replace with the "crossbuild-essential-${COMPAT_DISTRO_ARCH}" , this one
> comes via SDK_TOOLCHAIN variable, if i append " gcc-multilib
> g++-multilib" without removing the crossbuild-essential am facing broken
> package problem.
> Logs:
> 
>  Broken gcc-multilib:amd64 Conflicts on gcc-10-i686-linux-gnu:amd64 <
> none -> 10.2.1-6cross1 @un puN Ib >
>  |   Considering gcc-10-i686-linux-gnu:amd64 1 as a solution to
> gcc-multilib:amd64 10001
>  | Investigating (0) gcc-10-i686-linux-gnu:amd64 < none ->
> 10.2.1-6cross1 @un puN Ib >
> 
> Eventually I need to remove crossbuild-essential, but this one will do
> via SDK_TOOLCHAIN remove override , but this does not work in the
> downstream layer, because always ISAR's python anonymous function wins
> and set its value.

Ok, then we should actually implement a weak (?=) assignment in the
Python block, so that you can define your own SDK_TOOLCHAIN in such
scenarios.

Jan
Srinuvasan Arjunan May 26, 2023, 9:03 a.m. UTC | #5
On Thursday, May 25, 2023 at 3:50:49 PM UTC+5:30 Jan Kiszka wrote:

On 25.05.23 06:53, Srinuvasan Arjunan wrote: 
> 
> 
> On Monday, May 22, 2023 at 11:24:53 AM UTC+5:30 Jan Kiszka wrote: 
> 
> On 22.05.23 07:16, 'Jan Kiszka' via isar-users wrote: 
> > On 22.05.23 06:41, Srinuvasan Arjunan wrote: 
> >> From: Srinuvasan A <srinuv...@siemens.com> 
> >> 
> >> In downstream layer we may override the sdk_toolchain, but this 
> not works as 
> >> expected in latest ISAR, the reason behind this as they moved 
> toolchain 
> >> selection into python Anonymous function. 
> > 
> > Dod you want to append or do you want to replac SDK_TOOLCHAIN in 
> > downstream? In the latter case, we likely rather want to make our 
> > assignment in isar weak, no? 
> > 
> > if not d.getVar('SDK_TOOLCHAIN'): 
> > ... 
> > 
> 
> Also to answer: Why is SDK_PREINSTALL insufficient for your 
> customization? 
> 
> Jan 
> 
> -- 
> Siemens AG, Technology 
> Competence Center Embedded Linux 
> 
>   
> 
>     yes we can append our toolchain via SDK_PREINSTALL, but i need to 
> replace with the "crossbuild-essential-${COMPAT_DISTRO_ARCH}" , this one 
> comes via SDK_TOOLCHAIN variable, if i append " gcc-multilib 
> g++-multilib" without removing the crossbuild-essential am facing broken 
> package problem. 
> Logs: 
> 
>  Broken gcc-multilib:amd64 Conflicts on gcc-10-i686-linux-gnu:amd64 < 
> none -> 10.2.1-6cross1 @un puN Ib > 
>  |   Considering gcc-10-i686-linux-gnu:amd64 1 as a solution to 
> gcc-multilib:amd64 10001 
>  | Investigating (0) gcc-10-i686-linux-gnu:amd64 < none -> 
> 10.2.1-6cross1 @un puN Ib > 
> 
> Eventually I need to remove crossbuild-essential, but this one will do 
> via SDK_TOOLCHAIN remove override , but this does not work in the 
> downstream layer, because always ISAR's python anonymous function wins 
> and set its value. 

Ok, then we should actually implement a weak (?=) assignment in the 
Python block, so that you can define your own SDK_TOOLCHAIN in such 
scenarios. 

Jan

Patch

diff --git a/meta/classes/crossvars.bbclass b/meta/classes/crossvars.bbclass
index 201d460..5a3edc4 100644
--- a/meta/classes/crossvars.bbclass
+++ b/meta/classes/crossvars.bbclass
@@ -17,7 +17,7 @@  python __anonymous() {
         sbuild_dep = "sbuild-chroot-target:do_build"
         buildchroot_dir = d.getVar('BUILDCHROOT_TARGET_DIR', False)
         buildchroot_dep = "buildchroot-target:do_build"
-        sdk_toolchain = "build-essential"
+        sdk_toolchain = " build-essential"
     else:
         d.setVar('BUILD_HOST_ARCH', d.getVar('HOST_ARCH'))
         schroot_dir = d.getVar('SCHROOT_HOST_DIR', False)
@@ -31,5 +31,5 @@  python __anonymous() {
     d.setVar('BUILDCHROOT_DEP', buildchroot_dep)
     if isar_can_build_compat(d):
         sdk_toolchain += " crossbuild-essential-" + d.getVar('COMPAT_DISTRO_ARCH')
-    d.setVar('SDK_TOOLCHAIN', sdk_toolchain)
+    d.appendVar('SDK_TOOLCHAIN', sdk_toolchain)
 }