Skip to contentSkip to conversation

feature-arm-crypto: Add +nocrypto to -mcpu when crypto not in features

PATCH Superseded Khem Raj 2 participants 3 messages Jul 21, 2025 – Jul 23, 2025

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/1 feature-arm-crypto: Add +nocrypto to -mcpu when crypto not in features

When crypto is not in tune features then add +nocryto to -mcpu explicitly. This makes the behavior between clang and gcc match. Currently -mcpu=cortex-a72 has different behavior in clang and gcc in terms of what features are considered default. Clang's philosophy to enable common features but maximally, gcc on other hand takes minimal. Clang therefore enables crypto with default set but gcc does not. crypto is optional on cortext-a53 and cortex-a72 while, this is not as common but Broadcom SOCs in raspberrypi3/4 have dropped crypto for cost reasons [1] This results in illegal instruction traps [2] [3] when building components e.g. chromium, qtwebengine, weston etc with clang using -mcpu=cortex-a72 for rpi4 target.

Adding +nocrypto makes it behave like gcc does today. We do have separate tune if crypto enabled cortex-a72 cores are to be targeted (cortexa72-cryto) as DEFAULTTUNE

[1] https://forums.raspberrypi.com/viewtopic.php?f=63&t=207888#p1332960
[2] https://github.com/llvm/llvm-project/issues/85699
[3] https://github.com/llvm/llvm-project/issues/90365

Cc Quentin Schulz <[email protected]>

---
v2: Move the change to feature-arm-crypto.inc

 meta/conf/machine/include/arm/feature-arm-crypto.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/conf/machine/include/arm/feature-arm-crypto.inc +2 -1
index aade6ce08d5..8202de78e46 100644
@@ -2,4 +2,5 @@
 # armv8-a, armv8.1-a, armv8.3-a, armv8.4-a, armv8.5-a, armv8.6-a, and armv8-r
 
 TUNEVALID[crypto] = "Enable cryptographic instructions for ARMv8"
-TUNE_CCARGS_MARCH_OPTS .= "${@bb.utils.contains('TUNE_FEATURES', 'crypto', '+crypto', '', d)}"
+# See  https://github.com/llvm/llvm-project/issues/85699
+TUNE_CCARGS_MARCH_OPTS .= "${@bb.utils.contains('TUNE_FEATURES', 'crypto', '+crypto', '+nocrypto', d)}"
Acked-by on v2 1/1
#1 lore raw

Hi Khem,

Quoted 6 lines · Khem Raj

When crypto is not in tune features then add +nocryto to -mcpu explicitly. This makes the behavior between clang and gcc match. Currently -mcpu=cortex-a72 has different behavior in clang and gcc in terms of what features are considered default. Clang's philosophy to enable common features but maximally, gcc on other hand takes minimal.

The docs seems to be saying the opposite though?

https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mcpu-2

"""
Many of the supported CPUs implement optional architectural extensions. Where this is so the architectural extensions are normally enabled by default. If implementations that lack the extension exist, then the extension syntax can be used to disable those extensions that have been omitted. """

Quoted 8 lines

Clang therefore enables crypto with default set but gcc does not. crypto is optional on cortext-a53 and cortex-a72 while, this is not as common but Broadcom SOCs in raspberrypi3/4 have dropped crypto for cost reasons [1] This results in illegal instruction traps [2] [3] when building components e.g. chromium, qtwebengine, weston etc with clang using -mcpu=cortex-a72 for rpi4 target.

Quoted 4 lines

Adding +nocrypto makes it behave like gcc does today. We do have separate tune if crypto enabled cortex-a72 cores are to be targeted (cortexa72-cryto) as DEFAULTTUNE

Not entirely clear from the commit log why we apply this unconditionally to all arm cores now.

I guess it could be as simple as adding

"""
armv8-[ar] and armv8.[1-6]a have +crypto and +nocrypto support, so let's explicitly disable crypto whenever it isn't requested. """

Quoted 6 lines

[1] https://forums.raspberrypi.com/viewtopic.php?f=63&t=207888#p1332960
[2] https://github.com/llvm/llvm-project/issues/85699
[3] https://github.com/llvm/llvm-project/issues/90365

Cc Quentin Schulz <[email protected]>

Looks good to me otherwise, so

Thanks!
Quentin

author
#2 lore raw
Quoted 11 lines · Quentin Schulz

Hi Khem,

Quoted 6 lines · Khem Raj

When crypto is not in tune features then add +nocryto to -mcpu explicitly. This makes the behavior between clang and gcc match. Currently -mcpu=cortex-a72 has different behavior in clang and gcc in terms of what features are considered default. Clang's philosophy to enable common features but maximally, gcc on other hand takes minimal.

The docs seems to be saying the opposite though?

It was in contrast to clang, not CPU specifications. clang tends to enable more than gcc by default.

Quoted 15 lines

https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mcpu-2

"""
Many of the supported CPUs implement optional architectural extensions. Where this is so the architectural extensions are normally enabled by default. If implementations that lack the extension exist, then the extension syntax can be used to disable those extensions that have been omitted. """

Quoted 8 lines

Clang therefore enables crypto with default set but gcc does not. crypto is optional on cortext-a53 and cortex-a72 while, this is not as common but Broadcom SOCs in raspberrypi3/4 have dropped crypto for cost reasons [1] This results in illegal instruction traps [2] [3] when building components e.g. chromium, qtwebengine, weston etc with clang using -mcpu=cortex-a72 for rpi4 target.

Quoted 6 lines
Quoted 4 lines

Adding +nocrypto makes it behave like gcc does today. We do have separate tune if crypto enabled cortex-a72 cores are to be targeted (cortexa72-cryto) as DEFAULTTUNE

Not entirely clear from the commit log why we apply this unconditionally to all arm cores now.

Well, crypto is add-on which was optional earlier (armv8a) but is part of CPU in newer cores e.g. arm9. I am not sure what more we can add here.

Quoted 6 lines

I guess it could be as simple as adding

"""
armv8-[ar] and armv8.[1-6]a have +crypto and +nocrypto support, so let's explicitly disable crypto whenever it isn't requested. """

They are not limited to armv8, one can specify them for armv9 cores ( e.g. cortex-a725 too

Quoted 14 lines
Quoted 7 lines

[1] https://forums.raspberrypi.com/viewtopic.php?f=63&t=207888#p1332960
[2] https://github.com/llvm/llvm-project/issues/85699
[3] https://github.com/llvm/llvm-project/issues/90365

Cc Quentin Schulz <[email protected]>

Looks good to me otherwise, so

Thanks!
Quentin