diff mbox series

[meta-lts-mixins,wrynose/rust,07/10] rust-target-config.bbclass: pass on all RISC-V extensions to LLVM

Message ID 442604caedc3e100243dfc203b25d0c8e24f7dc4.1795997683.git.scott.murray@konsulko.com
State New
Headers show
Series Update to 1.100.0 | expand

Commit Message

Scott Murray Nov. 30, 2026, 12:52 a.m. UTC
From: Trevor Gamblin <tgamblin@baylibre.com>

llvm_features_from_tune() doesn't pass on all RISC-V extensions listed
in TUNE_FEATURES, but rather has a fixed subset listed, and ignores
others. This means that with new profiles and custom tunes, Rust code
still gets compiled for riscv64gc plus a handful of extras.

LLVM's RISC-V extension names match those we use for TUNE_FEATURES, so
we can instead pass on each extension in the same order.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(adapted from oe-core commit 3b78f64f23d9ad1e0c94943f4a180189a57474eb)
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
 classes-recipe/rust-target-config.bbclass | 34 ++++++-----------------
 1 file changed, 8 insertions(+), 26 deletions(-)
diff mbox series

Patch

diff --git a/classes-recipe/rust-target-config.bbclass b/classes-recipe/rust-target-config.bbclass
index 2faecd5..89fbd19 100644
--- a/classes-recipe/rust-target-config.bbclass
+++ b/classes-recipe/rust-target-config.bbclass
@@ -83,32 +83,14 @@  def llvm_features_from_tune(d):
     if 'cortexa57' in feat:
         f.append("+v8a")
     if 'rv' in feat:
-        if 'm' in feat:
-            f.append("+m")
-        if 'a' in feat:
-            f.append("+a")
-        if 'f' in feat:
-            f.append("+f")
-        if 'd' in feat:
-            f.append("+d")
-        if 'c' in feat:
-            f.append("+c")
-        if 'v' in feat:
-            f.append("+v")
-        if 'zicbom' in feat:
-            f.append("+zicbom")
-        if 'zicsr' in feat:
-            f.append("+zicsr")
-        if 'zifencei' in feat:
-            f.append("+zifencei")
-        if 'zba' in feat:
-            f.append("+zba")
-        if 'zbb' in feat:
-            f.append("+zbb")
-        if 'zbc' in feat:
-            f.append("+zbc")
-        if 'zbs' in feat:
-            f.append("+zbs")
+        # LLVM uses the same names as TUNE_FEATURES for RISC-V extensions, so
+        # pass on every single-letter (except the base i) and z, s or x
+        # extension, in TUNE_FEATURES order to keep the result stable. Other
+        # tune flags (e.g. "rv", "64" or core names) aren't extensions.
+        for e in dict.fromkeys(d.getVar('TUNE_FEATURES').split()):
+            if (len(e) == 1 and e.isalpha() and e != 'i') or \
+                    (len(e) > 1 and e[0] in 'zsx' and e.isalnum()):
+                f.append("+" + e)
     return f
 llvm_features_from_tune[vardepvalue] = "${@llvm_features_from_tune(d)}"