Bug 14879 - 'Fix for target definitions returning 'NoneType' for arm' results in 'NoneType when arch_abi is arm-eabi
Summary: 'Fix for target definitions returning 'NoneType' for arm' results in 'NoneTyp...
Status: RESOLVED OBSOLETE
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 4.0
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 4.0.35
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2022-08-09 19:21 UTC by Orne Brocaar
Modified: 2026-04-30 15:00 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Orne Brocaar 2022-08-09 19:21:25 UTC
I'm using Yocto to compile a Rust application for Raspberry Pi (using the meta-raspberrypi layer). This breaks when using the `raspberrypi0` target with the following error:

ERROR: rust-cross-arm1176jzfshf-vfp-glibc-1.59.0-r0 do_rust_gen_targets: Error executing a python function in exec_func_python() autogenerated:                                                                                                              
                                                                                                                                                                                                                                                            
The stack trace of python calls that resulted in this exception/failure was:                                                                                                                                                                                 
File: 'exec_func_python() autogenerated', lineno: 2, function: <module>                                                                                                                                                                                       
    0001:                                                                                                                     
*** 0002:do_rust_gen_targets(d)                                                                                                                                                                                                                              
    0003:                                                                                                                                                                                                                                                    
File: '/layers/openembedded/openembedded-core/meta/recipes-devtools/rust/rust-cross.inc', lineno: 19, function: do_rust_gen_targets                                                                                                     
    0015:            if arch == "arm" and target_is_armv7(d):                                                                 
    0016:                arch = 'armv7'                                                                                                                                                                                                                      
    0017:            features = d.getVar('TARGET_LLVM_FEATURES') or ""                                                                                                                                                                                       
    0018:            cpu = d.getVar('TARGET_LLVM_CPU')                                                                                                                                                                                                       
*** 0019:        rust_gen_target(d, thing, wd, features, cpu, arch, abi)                                                      
    0020:}                                                                                                                    
    0021:                                                                                                                                                                                                                                                    
    0022:# Otherwise we'll depend on what we provide                                                                                                                                                                                                         
    0023:INHIBIT_DEFAULT_RUST_DEPS = "1"                                                                                                                                                                                                                     
File: '/layers/openembedded/openembedded-core/meta/recipes-devtools/rust/rust-common.inc', lineno: 316, function: rust_gen_target                                                                                                       
    0312:    # build tspec                                                                                                                                                                                                                                   
    0313:    tspec = {}                                                                                                                                                                                                                                      
    0314:    tspec['llvm-target'] = d.getVar('RUST_TARGET_SYS', arch_abi)                                                     
    0315:    tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi)                                                                                                                                                                                    
*** 0316:    tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch_abi))                                                                                                                                                                     
    0317:    tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch_abi)                                                                                                                                                                  
    0318:    tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch_abi)                                                                                                                                                                      
    0319:    tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch_abi)                                                                                                                                                                                
    0320:    tspec['arch'] = arch_to_rust_target_arch(rust_arch)                                                                                                                                                                                             
Exception: TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'


This is the exact same error as 'fixed' by the following commit, but then the reverse:
http://git.openembedded.org/openembedded-core/commit/?h=kirkstone&id=a4886f02dfb78e861fd7afe07b4a25c262bf0421


If using the `raspberrypi0` machine configuration provided by the meta-raspberrypi layer, then `arch_abi` holds the value `arm-eabi`, which was replaced by `arm` in the above commit. Could it be that both `arm` and `arm-eabi` keys must be set? I added a warning log to print the content of arch_abi, which prints:

WARNING: rust-native-1.59.0-r0 do_rust_gen_targets: x86_64                                                                                                                                                                                                   
WARNING: rust-cross-arm1176jzfshf-vfp-glibc-1.59.0-r0 do_rust_gen_targets: x86_64                                                                                                                                                                            
WARNING: rust-cross-arm1176jzfshf-vfp-glibc-1.59.0-r0 do_rust_gen_targets: x86_64                                                                                                                                                                            
WARNING: rust-cross-arm1176jzfshf-vfp-glibc-1.59.0-r0 do_rust_gen_targets: arm-eabi                                                                                                                                                                          


Build Configuration:                                                                                                                                                                                                                                         

BB_VERSION           = "2.0.0"                                                                                                                                                                                                                                
BUILD_SYS            = "x86_64-linux"                                                                                                                                                                                                                         
NATIVELSBSTRING      = "debian-10"                                                                                                                                                                                                                            
TARGET_SYS           = "arm-oe-linux-gnueabi"                                                                                                                                                                                                                 
MACHINE              = "raspberrypi0"                                                                                                                                                                                                                         
TUNE_FEATURES        = "arm thumb vfp arm1176jzfs callconvention-hard"                                                                                                                                                                                       
TARGET_FPU           = "hard"                                                                                                                                                                                                                                
meta                 = "master:37d3b539d5875230deb1d3e8d78069d48e099351"                                                                                                                                                                                     
meta-swupdate        = "kirkstone:e6e2b70159dfd40067a65c07aca91ec31931629b"                                                                                                                                                                                  
meta-clang           = "kirkstone:d669d873edf68dc7440bb07096737203bb7ec505"                                                                                                                                                                                   
meta-raspberrypi     = "kirkstone:0135a02ea577bd39dd552236ead2c5894d89da1d"                                                    
meta-networking                                                                                                                                                                                                                                               
meta-filesystems                                                                                                                                                                                                                                              
meta-python                                                                                                                                                                                                                                                   
meta-oe              = "kirkstone:8f2dc1023482863e2630d1b94052c41ce748b38f"                                                                                                                                                                                   
meta                 = "kirkstone:3564ce3d9b2030dd420362c66147bd327090915c"
Comment 1 Randy MacLeod 2022-08-11 14:46:59 UTC
One of the patches before the major recent work on master fixed this according to Richard. -- YP triage team
Comment 3 Steve Sakoman 2022-08-11 14:50:07 UTC
Ome - could you try applying the patch referenced above to see if it resolves the issue?
Comment 4 Orne Brocaar 2022-08-16 10:30:00 UTC
I applied the changes to which you linked:

---

diff --git a/meta/recipes-devtools/rust/rust-common.inc b/meta/recipes-devtools/rust/rust-common.inc
index ef70c48d0f..fd3f9d2c6b 100644
--- a/meta/recipes-devtools/rust/rust-common.inc
+++ b/meta/recipes-devtools/rust/rust-common.inc
@@ -297,6 +297,11 @@ def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
     sys = sys_for(d, thing)
     prefix = prefix_for(d, thing)
 
+    if thing == "TARGET":
+        abi = d.getVar('ABIEXTENSION')
+        if arch == "arm" and target_is_armv7(d):
+            arch = 'armv7'
+
     rust_arch = oe.rust.arch_to_rust_arch(arch)
 
     if abi:
diff --git a/meta/recipes-devtools/rust/rust-cross.inc b/meta/recipes-devtools/rust/rust-cross.inc
index f6babfeeda..4c026b1f38 100644
--- a/meta/recipes-devtools/rust/rust-cross.inc
+++ b/meta/recipes-devtools/rust/rust-cross.inc
@@ -8,15 +8,10 @@ python do_rust_gen_targets () {
         features = ""
         cpu = "generic"
         arch = d.getVar('{}_ARCH'.format(thing))
-        abi = ""
         if thing is "TARGET":
-            abi = d.getVar('ABIEXTENSION')
-            # arm and armv7 have different targets in llvm
-            if arch == "arm" and target_is_armv7(d):
-                arch = 'armv7'
             features = d.getVar('TARGET_LLVM_FEATURES') or ""
             cpu = d.getVar('TARGET_LLVM_CPU')
-        rust_gen_target(d, thing, wd, features, cpu, arch, abi)
+        rust_gen_target(d, thing, wd, features, cpu, arch)
 }
 
 # Otherwise we'll depend on what we provide

---

Build output:

---

Build Configuration:
BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "debian-10"
TARGET_SYS           = "arm-oe-linux-gnueabi"
MACHINE              = "raspberrypi0-wifi"
TUNE_FEATURES        = "arm thumb vfp arm1176jzfs callconvention-hard"
TARGET_FPU           = "hard"
meta                 = "master:c99df158e0ebff5db2317beb6566046c09df42ce"
meta-swupdate        = "kirkstone:e6e2b70159dfd40067a65c07aca91ec31931629b"
meta-clang           = "kirkstone:d669d873edf68dc7440bb07096737203bb7ec505"
meta-raspberrypi     = "kirkstone:0135a02ea577bd39dd552236ead2c5894d89da1d"
meta-networking      
meta-filesystems     
meta-python          
meta-oe              = "kirkstone:8f2dc1023482863e2630d1b94052c41ce748b38f"
meta                 = "kirkstone:3564ce3d9b2030dd420362c66147bd327090915c"

Initialising tasks: 100% |####################################################################################| Time: 0:00:05
Sstate summary: Wanted 574 Local 544 Mirrors 0 Missed 30 Current 947 (94% match, 98% complete)
Removing 2 stale sstate objects for arch x86_64: 100% |#######################################################| Time: 0:00:00
NOTE: Executing Tasks
ERROR: rust-cross-arm1176jzfshf-vfp-glibc-1.59.0-r0 do_rust_gen_targets: Error executing a python function in exec_func_python() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_rust_gen_targets(d)
     0003:
File: '/layers/openembedded/openembedded-core/meta/recipes-devtools/rust/rust-cross.inc', lineno: 14, function: do_rust_gen_targets
     0010:        arch = d.getVar('{}_ARCH'.format(thing))
     0011:        if thing is "TARGET":
     0012:            features = d.getVar('TARGET_LLVM_FEATURES') or ""
     0013:            cpu = d.getVar('TARGET_LLVM_CPU')
 *** 0014:        rust_gen_target(d, thing, wd, features, cpu, arch)
     0015:}
     0016:
     0017:# Otherwise we'll depend on what we provide
     0018:INHIBIT_DEFAULT_RUST_DEPS = "1"
File: '/layers/openembedded/openembedded-core/meta/recipes-devtools/rust/rust-common.inc', lineno: 319, function: rust_gen_target
     0315:    # build tspec
     0316:    tspec = {}
     0317:    tspec['llvm-target'] = d.getVar('RUST_TARGET_SYS', arch_abi)
     0318:    tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi)
 *** 0319:    tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch_abi))
     0320:    tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch_abi)
     0321:    tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch_abi)
     0322:    tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch_abi)
     0323:    tspec['arch'] = arch_to_rust_target_arch(rust_arch)
Exception: TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

ERROR: Logfile of failure stored in: /build/tmp/raspberrypi0-wifi-glibc/work/x86_64-linux/rust-cross-arm1176jzfshf-vfp-glibc/1.59.0-r0/temp/log.do_rust_gen_targets.426
ERROR: Task (/layers/openembedded/openembedded-core/meta/recipes-devtools/rust/rust-cross_1.59.0.bb:do_rust_gen_targets) failed with exit code '1'

---
Comment 5 Steve Sakoman 2022-08-16 14:56:04 UTC
Could you try to apply this patch in addition to the previous one?

https://git.openembedded.org/openembedded-core/commit/?id=1912c4e9e0ecf9655f3b3a41588b54d7956f5899

If this doesn't work could you give me details on how I might reproduce this on my end?  Extra credit points if we can reproduce with oe-core only :-)
Comment 6 Orne Brocaar 2022-08-17 09:23:53 UTC
I have now the following applied, but am hitting still the same error:

---
diff --git a/meta/recipes-devtools/rust/rust-common.inc b/meta/recipes-devtools/rust/rust-common.inc
index ef70c48d0f..2809de7584 100644
--- a/meta/recipes-devtools/rust/rust-common.inc
+++ b/meta/recipes-devtools/rust/rust-common.inc
@@ -297,6 +297,12 @@ def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
     sys = sys_for(d, thing)
     prefix = prefix_for(d, thing)
 
+    if thing == "TARGET":
+        abi = d.getVar('ABIEXTENSION')
+        # arm and armv7 have different targets in llvm
+        if arch == "arm" and target_is_armv7(d):
+            arch = 'armv7'
+
     rust_arch = oe.rust.arch_to_rust_arch(arch)
 
     if abi:
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
index 1f21c8af26..ad2aaed34e 100644
--- a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
+++ b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc
@@ -27,9 +27,9 @@ DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDP
 
 python do_rust_gen_targets () {
     wd = d.getVar('WORKDIR') + '/targets/'
-    rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_LLVM_FEATURES') or "", d.getVar('TARGET_LLVM_CPU'), d.getVar('TARGET_ARCH'))
-    rust_gen_target(d, 'HOST', wd, "", "generic", d.getVar('HOST_ARCH'))
     rust_gen_target(d, 'BUILD', wd, "", "generic", d.getVar('BUILD_ARCH'))
+    rust_gen_target(d, 'HOST', wd, "", "generic", d.getVar('HOST_ARCH'))
+    rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_LLVM_FEATURES') or "", d.getVar('TARGET_LLVM_CPU'), d.getVar('TARGET_ARCH'))
 }
 
 INHIBIT_DEFAULT_RUST_DEPS = "1"
diff --git a/meta/recipes-devtools/rust/rust-cross.inc b/meta/recipes-devtools/rust/rust-cross.inc
index f6babfeeda..4c026b1f38 100644
--- a/meta/recipes-devtools/rust/rust-cross.inc
+++ b/meta/recipes-devtools/rust/rust-cross.inc
@@ -8,15 +8,10 @@ python do_rust_gen_targets () {
         features = ""
         cpu = "generic"
         arch = d.getVar('{}_ARCH'.format(thing))
-        abi = ""
         if thing is "TARGET":
-            abi = d.getVar('ABIEXTENSION')
-            # arm and armv7 have different targets in llvm
-            if arch == "arm" and target_is_armv7(d):
-                arch = 'armv7'
             features = d.getVar('TARGET_LLVM_FEATURES') or ""
             cpu = d.getVar('TARGET_LLVM_CPU')
-        rust_gen_target(d, thing, wd, features, cpu, arch, abi)
+        rust_gen_target(d, thing, wd, features, cpu, arch)
 }
 
 # Otherwise we'll depend on what we provide
---

Steps to reproduce:

You will find the source repository of the project here, including the steps to setup the environment: https://github.com/chirpstack/chirpstack-gateway-os/tree/issue_14879.

Please note that you must use the issue_14879 branch, as the master branch contains a quickfix to work around this issue. I've also set the default target to raspberrypi0-wifi so that you don't have to change this (https://github.com/chirpstack/chirpstack-gateway-os/commit/f2860c63867da720794c97d96e7933fe8faef8ee).

Then a "bitbake chirpstack-gateway-os-full" should result in the above error.
Comment 7 Dharma B 2022-11-30 04:37:24 UTC
Did this commit in the poky layer https://git.yoctoproject.org/poky/commit/?id=66ff1fb3a164fa794ee186960809e3fa9e938b48 fixes this issue?
Comment 8 Orne Brocaar 2023-01-17 09:52:21 UTC
I'm sorry, at this moment I do not have the time to re-test this on a short notice. Please feel free to close this issue as it seems I can't change the status to closed.

For now, I'm using the following workaround:

DATA_LAYOUT[arm-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
LLVM_TARGET[arm-eabi] = "${RUST_TARGET_SYS}"
TARGET_ENDIAN[arm-eabi] = "little"
TARGET_POINTER_WIDTH[arm-eabi] = "32"
TARGET_C_INT_WIDTH[arm-eabi] = "32"
MAX_ATOMIC_WIDTH[arm-eabi] = "64"
FEATURES[arm-eabi] = "+v6,+vfp2"
Comment 9 Randy MacLeod 2023-01-19 15:56:56 UTC
Ross is going to find someone to take a look.
Comment 10 Randy MacLeod 2023-01-19 15:58:09 UTC
related to https://bugzilla.yoctoproject.org/show_bug.cgi?id=14967
Comment 11 Mathieu Dubois-Briand 2026-04-30 15:00:19 UTC
Obsolete