ARM Cortex-M series CPU models with optional features default to having those features enabled #17374
Labels
arch-arm
32-bit ARM
bug
Observed behavior contradicts documented or intended behavior
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
Milestone
For example, the ARM Cortex-M7 has three options for FPU:
Specifying
thumb-freestanding-eabihf
as the target andcortex_m7
as the CPU results in all optional SP+DP floating point features being enabled.For example: currently, if a user wants to compile for the Playdate console, which uses a Cortex-M7 with a single-precision FPU, it requires the user to dig through the source file for
std.Target.arm
to figure out which double-precision features they need to disable. This is not trivial since it requires looking up the definition offp_armv8d16
to see that it addsvfp4d16
,vfp4d16
to see that it addsvfp3d16
and so on recursively until all offending features have been identified.In the end you end with the CPU string
cortex_m7-fp_armv8d16-vfp4d16-vfp3d16-vfp2-fp64-fpregs64
.This problem with Cortex-M7 in praticular was actually mentioned in passing in an issue in 2020 (#4631 (comment), #4631 (comment)), where Andrew wrote
If I'm interpreting this right and it still holds today, this means that CPU models with optional features should default to having them disabled.
So specifying just
cortex_m7
should mean that no FPU features are enabled and in order to build for a SP or SP+DP Cortex-M7 you need to usecortex_m7+fp_armv8d16sp
orcortex_m7+fp_armv8d16
respectively.From quickly skimming through
std.Target.arm
, the are other affected models like M4, M33 and M35P.ARM provides a helpful comparison table that lists optional features in PDF form on their website. The Wikipedia page for ARM Cortex-M also lists a (less authoritative) overview of optional features (scroll down to the "ARM Cortex-M instruction variations" table).
There are probably other CPU models with optional features that have similar issues.
The text was updated successfully, but these errors were encountered: