diff mbox series

[v2] rust-target-config: fix target_features for vfpv3d16

Message ID 20230809-rust-vfpv3d16-v2-1-dc2d492b7013@skidata.com
State Accepted, archived
Commit d79f0a0702b667625e12c9e131932e02cb08bada
Headers show
Series [v2] rust-target-config: fix target_features for vfpv3d16 | expand

Commit Message

Benjamin Bara Aug. 9, 2023, 1:11 p.m. UTC
From: Benjamin Bara <benjamin.bara@skidata.com>

A build with vfpv3d16 (armv7at2hf-vfpv3d16) tune currently warns:
'+d16' is not a recognized feature for this target (ignoring feature)

This correlates with the supported target_features for arm[1].

With the now enabled features, rustc might use vdiv.f64 with register
d17, which leads to an illegal instruction on the given platform.

Therefore, adapt the features s.t. they correspond to the
armv7_unknown_linux_gnueabihf target[2].

Additionally, only set the latest supported version of VFP.

[1] https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_codegen_ssa/src/target_features.rs#L32
[2] https://github.com/rust-lang/rust/blob/1.70.0/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs#L15

Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
---
v2:
- move armv7 check back
- only add '-neon' on armv7
- only set latest supported VFP version
- Link to v1: https://lore.kernel.org/r/20230802-rust-vfpv3d16-v1-1-9af645a4b407@skidata.com
---
 meta/classes-recipe/rust-target-config.bbclass | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)


---
base-commit: 46f938bbd3a143d38c5a67cfd781f19c22664c57
change-id: 20230801-rust-vfpv3d16-a65080a9bcfa

Best regards,
diff mbox series

Patch

diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
index 21a56ede3e..9aa1fc4da5 100644
--- a/meta/classes-recipe/rust-target-config.bbclass
+++ b/meta/classes-recipe/rust-target-config.bbclass
@@ -21,16 +21,18 @@  def llvm_features_from_tune(d):
 
     if 'vfpv4' in feat:
         f.append("+vfp4")
-    if 'vfpv3' in feat:
+    elif 'vfpv3' in feat:
         f.append("+vfp3")
-    if 'vfpv3d16' in feat:
-        f.append("+d16")
-
-    if 'vfpv2' in feat or 'vfp' in feat:
+    elif 'vfpv3d16' in feat:
+        f.append("+vfp3")
+        f.append("-d32")
+    elif 'vfpv2' in feat or 'vfp' in feat:
         f.append("+vfp2")
 
     if 'neon' in feat:
         f.append("+neon")
+    elif target_is_armv7(d):
+        f.append("-neon")
 
     if 'mips32' in feat:
         f.append("+mips32")