diff mbox series

[2/2] rust: enable default uwtable and ignore arm no_std test

Message ID 20251222093830.2658141-2-Yash.Shinde@windriver.com
State Accepted, archived
Commit f38b4e8b35d6ce2dba9c1f933e3b22b22c065574
Headers show
Series [1/2] rust: Upgrade 1.91.1 -> 1.92.0 | expand

Commit Message

Yash Shinde Dec. 22, 2025, 9:38 a.m. UTC
From: Hemanth Kumar M D <hemanth.250302@gmail.com>

Rust 1.92.0 adds new test that require unwind table support to be
enabled by default. Set `default-uwtable = true` in the generated
target spec to match upstream behavior.

ref:https://github.com/rust-lang/rust/commit/fe66eaa67acc47525db6f13cf97d54780d87b805

Also ignore the no_std simple-runs UI test on ARM targets. The test
fails with panic=abort due to a known unwind table issue on 32-bit ARM

https://github.com/rust-lang/rust/issues/146996

Signed-off-by: Hemanth Kumar M D <hemanth.250302@gmail.com>
Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
---
 meta/classes-recipe/rust-target-config.bbclass       |  1 +
 .../rust/files/rust-oe-selftest.patch                | 12 ++++++++++++
 2 files changed, 13 insertions(+)

Comments

Randy MacLeod Dec. 22, 2025, 10:40 p.m. UTC | #1
On 2025-12-22 4:38 a.m., Yash.Shinde@windriver.com wrote:
> From: Hemanth Kumar M D<hemanth.250302@gmail.com>
>
> Rust 1.92.0 adds new test that require unwind table support to be
> enabled by default. Set `default-uwtable = true` in the generated
> target spec to match upstream behavior.
>
> ref:https://github.com/rust-lang/rust/commit/fe66eaa67acc47525db6f13cf97d54780d87b805
>
> Also ignore the no_std simple-runs UI test on ARM targets. The test
> fails with panic=abort due to a known unwind table issue on 32-bit ARM
>
> https://github.com/rust-lang/rust/issues/146996

Okay and I'm glad to see the upstream issues linked.

Should we make some of these tspec decisions set-able by well-informed 
users?

Maybe they can already do that using this horridly named "FEATURES" 
variable.
(rename to RUST_FEATURES maybe ?)

For example, this bug:

Unable to produce a Rust static binary with TCLIBC=musl (oe-core/master)
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16076

seems to be due to hard-coding dynamic-linking to True below just after 
your:

+    tspec['default-uwtable'] = True


change.

I've CCed Nick in case you guys have a quick work-around to enable 
static linking.

../Randy

>
> Signed-off-by: Hemanth Kumar M D<hemanth.250302@gmail.com>
> Signed-off-by: Yash Shinde<Yash.Shinde@windriver.com>
> ---
>   meta/classes-recipe/rust-target-config.bbclass       |  1 +
>   .../rust/files/rust-oe-selftest.patch                | 12 ++++++++++++
>   2 files changed, 13 insertions(+)
>
> diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
> index 33a290412e..2a06c4ae8b 100644
> --- a/meta/classes-recipe/rust-target-config.bbclass
> +++ b/meta/classes-recipe/rust-target-config.bbclass
> @@ -418,6 +418,7 @@ def rust_gen_target(d, thing, wd, arch):
>           tspec['llvm-floatabi'] = "soft"
>       elif fpu == "hard":
>           tspec['llvm-floatabi'] = "hard"
> +    tspec['default-uwtable'] = True
>       tspec['dynamic-linking'] = True
>       tspec['executables'] = True
>       tspec['linker-is-gnu'] = True
> diff --git a/meta/recipes-devtools/rust/files/rust-oe-selftest.patch b/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
> index b39b326455..d1fba81612 100644
> --- a/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
> +++ b/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
> @@ -254,3 +254,15 @@ index a3562f2fd93..d4e52ed91be 100644
>        fn linux_hwcap2_aarch64() {
>            let file =
>                concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-hwcap2-aarch64.auxv");
> +diff --git a/tests/ui/no_std/simple-runs.rs b/tests/ui/no_std/simple-runs.rs
> +index af44dfe..e6674e5 100644
> +--- a/tests/ui/no_std/simple-runs.rs
> ++++ b/tests/ui/no_std/simple-runs.rs
> +@@ -2,6 +2,7 @@
> +
> + //@ run-pass
> + //@ compile-flags: -Cpanic=abort
> ++//@ ignore-arm FIXME(#146996)
> + //@ ignore-wasm different `main` convention
> +
> + #![feature(lang_items)]
Yash Shinde Dec. 23, 2025, 6:10 a.m. UTC | #2
On 23-12-2025 04:10, Randy MacLeod wrote:
> On 2025-12-22 4:38 a.m., Yash.Shinde@windriver.com wrote:
>> From: Hemanth Kumar M D<hemanth.250302@gmail.com>
>>
>> Rust 1.92.0 adds new test that require unwind table support to be
>> enabled by default. Set `default-uwtable = true` in the generated
>> target spec to match upstream behavior.
>>
>> ref:https://github.com/rust-lang/rust/commit/fe66eaa67acc47525db6f13cf97d54780d87b805
>>
>> Also ignore the no_std simple-runs UI test on ARM targets. The test
>> fails with panic=abort due to a known unwind table issue on 32-bit ARM
>>
>> https://github.com/rust-lang/rust/issues/146996
>
> Okay and I'm glad to see the upstream issues linked.
>
> Should we make some of these tspec decisions set-able by well-informed 
> users?
>
> Maybe they can already do that using this horridly named "FEATURES" 
> variable.
> (rename to RUST_FEATURES maybe ?)
>
Most of the tspec features are set explicitly here.
We are analyzing on the possibility to check and set them using FEATURES 
to make
user-configurable.


Regards,
Yash

>
> For example, this bug:
>
> Unable to produce a Rust static binary with TCLIBC=musl (oe-core/master)
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=16076
>
> seems to be due to hard-coding dynamic-linking to True below just 
> after your:
>
> +    tspec['default-uwtable'] = True
>
>
> change.
>
> I've CCed Nick in case you guys have a quick work-around to enable 
> static linking.
>
> ../Randy
>
>> Signed-off-by: Hemanth Kumar M D<hemanth.250302@gmail.com>
>> Signed-off-by: Yash Shinde<Yash.Shinde@windriver.com>
>> ---
>>   meta/classes-recipe/rust-target-config.bbclass       |  1 +
>>   .../rust/files/rust-oe-selftest.patch                | 12 ++++++++++++
>>   2 files changed, 13 insertions(+)
>>
>> diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
>> index 33a290412e..2a06c4ae8b 100644
>> --- a/meta/classes-recipe/rust-target-config.bbclass
>> +++ b/meta/classes-recipe/rust-target-config.bbclass
>> @@ -418,6 +418,7 @@ def rust_gen_target(d, thing, wd, arch):
>>           tspec['llvm-floatabi'] = "soft"
>>       elif fpu == "hard":
>>           tspec['llvm-floatabi'] = "hard"
>> +    tspec['default-uwtable'] = True
>>       tspec['dynamic-linking'] = True
>>       tspec['executables'] = True
>>       tspec['linker-is-gnu'] = True
>> diff --git a/meta/recipes-devtools/rust/files/rust-oe-selftest.patch b/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
>> index b39b326455..d1fba81612 100644
>> --- a/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
>> +++ b/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
>> @@ -254,3 +254,15 @@ index a3562f2fd93..d4e52ed91be 100644
>>        fn linux_hwcap2_aarch64() {
>>            let file =
>>                concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-hwcap2-aarch64.auxv");
>> +diff --git a/tests/ui/no_std/simple-runs.rs b/tests/ui/no_std/simple-runs.rs
>> +index af44dfe..e6674e5 100644
>> +--- a/tests/ui/no_std/simple-runs.rs
>> ++++ b/tests/ui/no_std/simple-runs.rs
>> +@@ -2,6 +2,7 @@
>> +
>> + //@ run-pass
>> + //@ compile-flags: -Cpanic=abort
>> ++//@ ignore-arm FIXME(#146996)
>> + //@ ignore-wasm different `main` convention
>> +
>> + #![feature(lang_items)]
>
>
> -- 
> # Randy MacLeod
> # Wind River Linux
Dora, Sunil Kumar Dec. 24, 2025, 4:03 a.m. UTC | #3
Hi Randy,

On 12/23/2025 4:10 AM, Randy MacLeod wrote:
> On 2025-12-22 4:38 a.m., Yash.Shinde@windriver.com wrote:
>> From: Hemanth Kumar M D<hemanth.250302@gmail.com>
>>
>> Rust 1.92.0 adds new test that require unwind table support to be
>> enabled by default. Set `default-uwtable = true` in the generated
>> target spec to match upstream behavior.
>>
>> ref:https://github.com/rust-lang/rust/commit/fe66eaa67acc47525db6f13cf97d54780d87b805
>>
>> Also ignore the no_std simple-runs UI test on ARM targets. The test
>> fails with panic=abort due to a known unwind table issue on 32-bit ARM
>>
>> https://github.com/rust-lang/rust/issues/146996
>
> Okay and I'm glad to see the upstream issues linked.
>
> Should we make some of these tspec decisions set-able by well-informed 
> users?
>
> Maybe they can already do that using this horridly named "FEATURES" 
> variable.
> (rename to RUST_FEATURES maybe ?)
>
The existing FEATURES variables in the .bbclass is currently used for 
low-level CPU instructions.
As you suggested, RUST_FEATURE variable will allow us to keep H/W tuning 
separate from
high-level compiler policy. I will discuss with team.
>
>
> For example, this bug:
>
> Unable to produce a Rust static binary with TCLIBC=musl (oe-core/master)
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=16076
>
Although the bug report did not include a specific recipe, I used 
ripgrep as a reference
to validate the issue and was able to build a fully static musl binary.

I found that changing *tspec['dynamic-linking']* from *true *to *false 
*in the .bbclass alone was not enough
to produce static binary. The problem had two parts.

First, at the target specification level, rust-target-config.bbclass 
forces dynamic-linking to true.
Because of this, the compiler assumes the target is dynamic and ignores 
requests for static linking.
As a result, it still produces a dynamic PIE binary that depends on the 
musl dynamic loader (ld-musl.so).

Second, at the linker wrapper level, *target-rust-ccld* enforces dynamic 
linking by default.
It automatically adds flags such as*-Wl,-Bdynamic* and *-pie*. This 
conflicts with the compiler’s static intent
and causes it to pick shared libraries from the sysroot, which leads to 
the error
“*attempted static linking of dynamic object*”.

To work around this and meet static musl requirements, I applied 
recipe-specific changes to bypass the wrapper’s
enforcement and handle circular dependencies and crate-level leakage.
With these adjustments, the final link correctly uses static archives 
instead of falling back to shared objects.

I will update the bug report with these findings.
>
>
> seems to be due to hard-coding dynamic-linking to True below just 
> after your:
>
> +    tspec['default-uwtable'] = True
>
>
> change.
>
> I've CCed Nick in case you guys have a quick work-around to enable 
> static linking.
>
> ../Randy
>
>> Signed-off-by: Hemanth Kumar M D<hemanth.250302@gmail.com>
>> Signed-off-by: Yash Shinde<Yash.Shinde@windriver.com>
>> ---
>>   meta/classes-recipe/rust-target-config.bbclass       |  1 +
>>   .../rust/files/rust-oe-selftest.patch                | 12 ++++++++++++
>>   2 files changed, 13 insertions(+)
>>
>> diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
>> index 33a290412e..2a06c4ae8b 100644
>> --- a/meta/classes-recipe/rust-target-config.bbclass
>> +++ b/meta/classes-recipe/rust-target-config.bbclass
>> @@ -418,6 +418,7 @@ def rust_gen_target(d, thing, wd, arch):
>>           tspec['llvm-floatabi'] = "soft"
>>       elif fpu == "hard":
>>           tspec['llvm-floatabi'] = "hard"
>> +    tspec['default-uwtable'] = True
>>       tspec['dynamic-linking'] = True
>>       tspec['executables'] = True
>>       tspec['linker-is-gnu'] = True
>> diff --git a/meta/recipes-devtools/rust/files/rust-oe-selftest.patch b/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
>> index b39b326455..d1fba81612 100644
>> --- a/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
>> +++ b/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
>> @@ -254,3 +254,15 @@ index a3562f2fd93..d4e52ed91be 100644
>>        fn linux_hwcap2_aarch64() {
>>            let file =
>>                concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-hwcap2-aarch64.auxv");
>> +diff --git a/tests/ui/no_std/simple-runs.rs b/tests/ui/no_std/simple-runs.rs
>> +index af44dfe..e6674e5 100644
>> +--- a/tests/ui/no_std/simple-runs.rs
>> ++++ b/tests/ui/no_std/simple-runs.rs
>> +@@ -2,6 +2,7 @@
>> +
>> + //@ run-pass
>> + //@ compile-flags: -Cpanic=abort
>> ++//@ ignore-arm FIXME(#146996)
>> + //@ ignore-wasm different `main` convention
>> +
>> + #![feature(lang_items)]
>
>
> -- 
> # Randy MacLeod
> # Wind River Linux
diff mbox series

Patch

diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
index 33a290412e..2a06c4ae8b 100644
--- a/meta/classes-recipe/rust-target-config.bbclass
+++ b/meta/classes-recipe/rust-target-config.bbclass
@@ -418,6 +418,7 @@  def rust_gen_target(d, thing, wd, arch):
         tspec['llvm-floatabi'] = "soft"
     elif fpu == "hard":
         tspec['llvm-floatabi'] = "hard"
+    tspec['default-uwtable'] = True
     tspec['dynamic-linking'] = True
     tspec['executables'] = True
     tspec['linker-is-gnu'] = True
diff --git a/meta/recipes-devtools/rust/files/rust-oe-selftest.patch b/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
index b39b326455..d1fba81612 100644
--- a/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
+++ b/meta/recipes-devtools/rust/files/rust-oe-selftest.patch
@@ -254,3 +254,15 @@  index a3562f2fd93..d4e52ed91be 100644
      fn linux_hwcap2_aarch64() {
          let file =
              concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-hwcap2-aarch64.auxv");
+diff --git a/tests/ui/no_std/simple-runs.rs b/tests/ui/no_std/simple-runs.rs
+index af44dfe..e6674e5 100644
+--- a/tests/ui/no_std/simple-runs.rs
++++ b/tests/ui/no_std/simple-runs.rs
+@@ -2,6 +2,7 @@
+ 
+ //@ run-pass
+ //@ compile-flags: -Cpanic=abort
++//@ ignore-arm FIXME(#146996)
+ //@ ignore-wasm different `main` convention
+ 
+ #![feature(lang_items)]