[v2,1/5] dpkg-base: Fix enabling of cross build profile

Message ID f11c64ea4d0c98e4022fcb479e1eaea380662a1b.1715771298.git.jan.kiszka@siemens.com
State Superseded, archived
Headers show
Series More kbuild improvements, single-build source packages, cross profile fix | expand

Commit Message

Jan Kiszka May 15, 2024, 11:08 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

ISAR_CROSS_COMPILE might be set even if we are not cross-building a
package. Use an output of crossbuild.bbclass, BUILD_ARCH, to find out
if we are actually cross-building a package.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/dpkg-base.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Schmidt, Adriaan May 16, 2024, 6:06 a.m. UTC | #1
Kiszka, Jan (T CED), Mittwoch, 15. Mai 2024 13:08:
> ISAR_CROSS_COMPILE might be set even if we are not cross-building a
> package. Use an output of crossbuild.bbclass, BUILD_ARCH, to find out
> if we are actually cross-building a package.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  meta/classes/dpkg-base.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
> index 30caedf9..93321976 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -215,7 +215,7 @@ dpkg_runbuild() {
> 
>  def isar_deb_build_profiles(d):
>      deb_build_profiles = d.getVar('DEB_BUILD_PROFILES')
> -    if bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE')):
> +    if d.getVar('BUILD_ARCH') != d.getVar('DISTRO_ARCH'):

That's the question "are we _actually_ cross-compiling"?

Elsewhere (multiarch.bbclass, linux-custom.inc) we have that
check implemented as "ISAR_CROSS_COMPILE && DISTRO_ARCH != HOST_ARCH".

As a follow-up we should look into unifying this.
Maybe have crossvars.bbclass figure out how we're building, and set
one variable to be consumed by recipes, e.g.

ISAR_BUILDPROFILE="native|emulated|cross"

Or even add an override (:buildprofile-native, ...) to make it easier to use?

Adriaan


>          deb_build_profiles += ' cross'
>      return deb_build_profiles.strip()
> 
> --
> 2.35.3
Jan Kiszka May 16, 2024, 6:15 a.m. UTC | #2
On 16.05.24 08:06, Schmidt, Adriaan (T CED EDC-DE) wrote:
> Kiszka, Jan (T CED), Mittwoch, 15. Mai 2024 13:08:
>> ISAR_CROSS_COMPILE might be set even if we are not cross-building a
>> package. Use an output of crossbuild.bbclass, BUILD_ARCH, to find out
>> if we are actually cross-building a package.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  meta/classes/dpkg-base.bbclass | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
>> index 30caedf9..93321976 100644
>> --- a/meta/classes/dpkg-base.bbclass
>> +++ b/meta/classes/dpkg-base.bbclass
>> @@ -215,7 +215,7 @@ dpkg_runbuild() {
>>
>>  def isar_deb_build_profiles(d):
>>      deb_build_profiles = d.getVar('DEB_BUILD_PROFILES')
>> -    if bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE')):
>> +    if d.getVar('BUILD_ARCH') != d.getVar('DISTRO_ARCH'):
> 
> That's the question "are we _actually_ cross-compiling"?
> 
> Elsewhere (multiarch.bbclass, linux-custom.inc) we have that
> check implemented as "ISAR_CROSS_COMPILE && DISTRO_ARCH != HOST_ARCH".
> 
> As a follow-up we should look into unifying this.
> Maybe have crossvars.bbclass figure out how we're building, and set
> one variable to be consumed by recipes, e.g.
> 
> ISAR_BUILDPROFILE="native|emulated|cross"
> 
> Or even add an override (:buildprofile-native, ...) to make it easier to use?
> 

I don't disagree.

Jan

Patch

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 30caedf9..93321976 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -215,7 +215,7 @@  dpkg_runbuild() {
 
 def isar_deb_build_profiles(d):
     deb_build_profiles = d.getVar('DEB_BUILD_PROFILES')
-    if bb.utils.to_boolean(d.getVar('ISAR_CROSS_COMPILE')):
+    if d.getVar('BUILD_ARCH') != d.getVar('DISTRO_ARCH'):
         deb_build_profiles += ' cross'
     return deb_build_profiles.strip()