Skip to contentSkip to conversation

Failure for rust-cross for arm(v5)

PATCH In review [email protected] 2 participants 7 messages Dec 5, 2023

lore
Share & tools
lore
#0 lore raw

v2 cover Failure for rust-cross for arm(v5)

From: Jermain Horsman <[email protected]>

I ran into the following when trying to compile rust for arm (on kirkstone):

Exception: TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

After some investigation I notices some patches on master which were not available on kirkstone.
Using the patches included here I am able to compile successfully.

v2:
I've included all patches that were originally send as a series on the mailing list.
I've also included a single patch that should prevent the issue with the oe-selftest reported on the first version.

Richard Purdie (5):
rust-common: Set llvm-target correctly for cross SDK targets
rust-cross-canadian: Fix ordering of target json config generation rust-cross/rust-common: Merge arm target handling code to fix
cross-canadian
rust-cross: Simplfy the rust_gen_target calls
native: Clear TUNE_FEATURES/ABIEXTENSION

 meta/classes/native.bbclass                   |  2 ++
 meta/recipes-devtools/rust/rust-common.inc    | 24 +++++++++++++------
 .../rust/rust-cross-canadian-common.inc       |  5 ++--
 meta/recipes-devtools/rust/rust-cross.inc     | 21 ++++------------
 4 files changed, 26 insertions(+), 26 deletions(-)
Signature · 1 line
2.42.0.windows.2
#1 lore raw

PATCH v2 1/5 rust-common: Set llvm-target correctly for cross SDK targets

From: Richard Purdie <[email protected]>

When a 'BUILD' target is requested we shouldn't be looking at TARGET_SYS but at BUILD_SYS. Due to the way rust mangles triplets, we need the HOST_SYS triplet to work with existing code - fixing that issue is a separate patch.

Also drop the arch_abi argument, it doens't make any sense to a getVar() call and was a copy and paste error.

Based on a patch from Otavio Salvador <[email protected]> but separated out and tweaked.

Fixes bd36593ba3 ("rust-common: Drop LLVM_TARGET and simplify")
(cherry picked from commit d554161a045d12411f288394e253c54aa4c1257c)
---
 meta/recipes-devtools/rust/rust-common.inc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meta/recipes-devtools/rust/rust-common.inc +5 -1
index db0bd8fc1b..ac00fd3d43 100644
@@ -307,9 +307,13 @@ def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""):
     features = features or d.getVarFlag('FEATURES', arch_abi) or ""
     features = features.strip()
 
+    llvm_target = d.getVar('RUST_TARGET_SYS')
+    if thing == "BUILD":
+        llvm_target = d.getVar('RUST_HOST_SYS')
+
     # build tspec
     tspec = {}
-    tspec['llvm-target'] = d.getVar('RUST_TARGET_SYS', arch_abi)
+    tspec['llvm-target'] = llvm_target
     tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi)
     tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch_abi))
     tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch_abi)
Signature · 1 line
2.42.0.windows.2
#2 lore raw

PATCH v2 2/5 rust-cross-canadian: Fix ordering of target json config generation

In reply to [email protected]

From: Richard Purdie <[email protected]>

Based upon a patch from Otavio Salvador <[email protected]>, ensure the target json files are written in the correct order with the most specific last incase it overwrites earlier files if the prefixes match.

(cherry picked from commit 1912c4e9e0ecf9655f3b3a41588b54d7956f5899)
---
 meta/recipes-devtools/rust/rust-cross-canadian-common.inc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
meta/recipes-devtools/rust/rust-cross-canadian-common.inc +3 -2
index 1f21c8af26..df4901f1fa 100644
@@ -27,9 +27,10 @@ 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'))
+    # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last
     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"
Signature · 1 line
2.42.0.windows.2
#3 lore raw

PATCH v2 3/5 rust-cross/rust-common: Merge arm target handling code to fix cross-canadian

In reply to [email protected]

From: Richard Purdie <[email protected]>

rust-cross had special handling for armv7 targets but we also need this for cross-canadian. Merge the code into the main function so everything is consistent.

Also then fix the arm definition to be arm-eabi since ABI is correctly being looked up.

(cherry picked from commit ff3c3dbbd2bf1bb7bb70b55cca203e9eedcf14a8)
---
 meta/recipes-devtools/rust/rust-common.inc | 6 ++++++
 meta/recipes-devtools/rust/rust-cross.inc  | 7 +------
 2 files changed, 7 insertions(+), 6 deletions(-)
meta/recipes-devtools/rust/rust-common.inc +6 -0
index ac00fd3d43..3252827818 100644
@@ -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:
meta/recipes-devtools/rust/rust-cross.inc +1 -6
index f6babfeeda..4c026b1f38 100644
@@ -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
Signature · 1 line
2.42.0.windows.2
#4 lore raw

Patchtest results for [kirkstone][PATCH v2 3/5] rust-cross/rust-common: Merge arm target handling code to fix cross-canadian

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/kirkstone-v2-3-5-rust-cross-rust-common-Merge-arm-target-handling-code-to-fix-cross-canadian.patch

FAIL: test shortlog length: Edit shortlog so that it is 90 characters or less (currently 91 characters) (test_mbox.TestMbox.test_shortlog_length)

PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)
SKIP: test target mailing list: Series merged, no reason to check other mailing lists (test_mbox.TestMbox.test_target_mailing_list)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!

#5 lore raw

PATCH v2 4/5 rust-cross: Simplfy the rust_gen_target calls

In reply to [email protected]

From: Richard Purdie <[email protected]>

Match the code in rust-cross-canadian so that further simplifications can be considered in future.

(cherry picked from commit 5cb62d0a33777cb9afb1eea5f736a2580ce50dc7)
---
 meta/recipes-devtools/rust/rust-common.inc | 12 ++++++------
 meta/recipes-devtools/rust/rust-cross.inc  | 16 ++++------------
 2 files changed, 10 insertions(+), 18 deletions(-)
meta/recipes-devtools/rust/rust-common.inc +6 -6
index 3252827818..a73367bbd5 100644
@@ -119,12 +119,12 @@ def llvm_features(d):
 
 
 ## arm-unknown-linux-gnueabihf
-DATA_LAYOUT[arm] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-TARGET_ENDIAN[arm] = "little"
-TARGET_POINTER_WIDTH[arm] = "32"
-TARGET_C_INT_WIDTH[arm] = "32"
-MAX_ATOMIC_WIDTH[arm] = "64"
-FEATURES[arm] = "+v6,+vfp2"
+DATA_LAYOUT[arm-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+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"
 
 ## armv7-unknown-linux-gnueabihf
 DATA_LAYOUT[armv7-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
meta/recipes-devtools/rust/rust-cross.inc +4 -12
index 4c026b1f38..2e47a3aa5f 100644
@@ -1,17 +1,9 @@
 python do_rust_gen_targets () {
     wd = d.getVar('WORKDIR') + '/targets/'
-    # It is important 'TARGET' is last here so that it overrides our less
-    # informed choices for BUILD & HOST if TARGET happens to be the same as
-    # either of them.
-    for thing in ['BUILD', 'HOST', 'TARGET']:
-        bb.debug(1, "rust_gen_target for " + thing)
-        features = ""
-        cpu = "generic"
-        arch = d.getVar('{}_ARCH'.format(thing))
-        if thing is "TARGET":
-            features = d.getVar('TARGET_LLVM_FEATURES') or ""
-            cpu = d.getVar('TARGET_LLVM_CPU')
-        rust_gen_target(d, thing, wd, features, cpu, arch)
+    # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last
+    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'))
 }
 
 # Otherwise we'll depend on what we provide
Signature · 1 line
2.42.0.windows.2
#6 lore raw

PATCH v2 5/5 native: Clear TUNE_FEATURES/ABIEXTENSION

In reply to [email protected]

From: Richard Purdie <[email protected]>

Some recipes reference these. Rather than continually trying to chase down the references and taskhash issues, clear the variables for an easier life and simpler code. These wouldn't convey anything useful in a native build.

(cherry picked from commit f8edeead263708889d31a7ff578ef8274cb678b4)
---
 meta/classes/native.bbclass | 2 ++
 1 file changed, 2 insertions(+)
meta/classes/native.bbclass +2 -0
index 4de96cd59b..56726301bd 100644
@@ -23,6 +23,8 @@ TARGET_CFLAGS = "${BUILD_CFLAGS}"
 TARGET_CXXFLAGS = "${BUILD_CXXFLAGS}"
 TARGET_LDFLAGS = "${BUILD_LDFLAGS}"
 TARGET_FPU = ""
+TUNE_FEATURES = ""
+ABIEXTENSION = ""
 
 HOST_ARCH = "${BUILD_ARCH}"
 HOST_OS = "${BUILD_OS}"
Signature · 1 line
2.42.0.windows.2