Skip to content

Commit

Permalink
Auto merge of rust-lang#130987 - thejpster:revise-arm-platform-notes-…
Browse files Browse the repository at this point in the history
…soft-float, r=ehuss

Revise arm platform notes regarding soft float

This PR updates the Arm microcontroller platform docs to recommend `-fpregs` instead of `+soft-float` as [discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60-Ctarget-feature.3D.2Bsoft-float.60.20considered.20harmful)
  • Loading branch information
bors committed Oct 21, 2024
2 parents 3ec4308 + 5cc1c7b commit edbd939
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 22 deletions.
15 changes: 9 additions & 6 deletions src/doc/rustc/src/platform-support/arm-none-eabi.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ their own document.
There are two 32-bit instruction set architectures (ISAs) defined by Arm:

- The [*A32 ISA*][a32-isa], with fixed-width 32-bit instructions. Previously
known as the *Arm* ISA, this originated with the original Arm1 of 1985 and has
known as the *Arm* ISA, this originated with the original ARM1 of 1985 and has
been updated by various revisions to the architecture specifications ever
since.
- The [*T32 ISA*][t32-isa], with a mix of 16-bit and 32-bit width instructions.
Note that this term includes both the original 16-bit width *Thumb* ISA
introduced with the Armv4T architecture in 1994, and the later 16/32-bit sized
*Thumb-2* ISA introduced with the Armv6T2 architecture in 2003.

Again, these ISAs have been revised by subsequent revisions to the relevant Arm
architecture specifications.
*Thumb-2* ISA introduced with the Armv6T2 architecture in 2003. Again, these
ISAs have been revised by subsequent revisions to the relevant Arm
architecture specifications.

There is also a 64-bit ISA with fixed-width 32-bit instructions called the *A64
ISA*, but targets which implement that instruction set generally start with
Expand Down Expand Up @@ -106,10 +105,14 @@ features you do not have available, leaving you with the optimized instruction
scheduling and support for the features you do have. More details are available
in the detailed target-specific documentation.

**Note:** Many target-features are currently unstable and subject to change, and
<div class="warning">

Many target-features are currently unstable and subject to change, and
if you use them you should disassemble the compiler output and manually inspect
it to ensure only appropriate instructions for your CPU have been generated.

</div>

If you wish to use the *target-cpu* and *target-feature* options, you can add
them to your `.cargo/config.toml` file alongside any other flags your project
uses (likely linker related ones):
Expand Down
15 changes: 11 additions & 4 deletions src/doc/rustc/src/platform-support/thumbv7em-none-eabi.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ to use these flags.
| CPU | FPU | DSP | Target CPU | Target Features |
| ---------- | --- | --- | ----------- | --------------- |
| Any | No | Yes | None | None |
| Cortex-M4 | No | Yes | `cortex-m4` | `+soft-float` |
| Cortex-M4 | No | Yes | `cortex-m4` | `-fpregs` |
| Cortex-M4F | SP | Yes | `cortex-m4` | None |
| Cortex-M7 | No | Yes | `cortex-m7` | `+soft-float` |
| Cortex-M7 | No | Yes | `cortex-m7` | `-fpregs` |
| Cortex-M7F | SP | Yes | `cortex-m7` | `-fp64` |
| Cortex-M7F | DP | Yes | `cortex-m7` | None |

Expand All @@ -50,6 +50,13 @@ to use these flags.
| Cortex-M7F | SP | Yes | `cortex-m7` | `-fp64` |
| Cortex-M7F | DP | Yes | `cortex-m7` | None |

<div class="warning">

Never use the `-fpregs` *target-feature* with the `thumbv7em-none-eabihf` target
as it will cause compilation units to have different ABIs, which is unsound.

</div>

### Arm Cortex-M4 and Arm Cortex-M4F

The target CPU is `cortex-m4`.
Expand All @@ -59,7 +66,7 @@ The target CPU is `cortex-m4`.
* enabled by default with this *target*
* Cortex-M4F has a single precision FPU
* support is enabled by default with this *target-cpu*
* disable support using the `+soft-float` feature (`eabi` only)
* disable support using the `-fpregs` *target-feature* (`eabi` only)

### Arm Cortex-M7 and Arm Cortex-M7F

Expand All @@ -71,4 +78,4 @@ The target CPU is `cortex-m7`.
* Cortex-M7F have either a single-precision or double-precision FPU
* double-precision support is enabled by default with this *target-cpu*
* opt-out by using the `-f64` *target-feature*
* disable support entirely using the `+soft-float` feature (`eabi` only)
* disable support entirely using the `-fpregs` *target-feature* (`eabi` only)
37 changes: 25 additions & 12 deletions src/doc/rustc/src/platform-support/thumbv8m.main-none-eabi.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ to use these flags.
| CPU | FPU | DSP | MVE | Target CPU | Target Features |
| ----------- | --- | --- | --------- | ------------- | --------------------- |
| Unspecified | No | No | No | None | None |
| Cortex-M33 | No | No | No | `cortex-m33` | `+soft-float,-dsp` |
| Cortex-M33 | No | Yes | No | `cortex-m33` | `+soft-float` |
| Cortex-M33 | No | No | No | `cortex-m33` | `-fpregs,-dsp` |
| Cortex-M33 | No | Yes | No | `cortex-m33` | `-fpregs` |
| Cortex-M33 | SP | No | No | `cortex-m33` | `-dsp` |
| Cortex-M33 | SP | Yes | No | `cortex-m33` | None |
| Cortex-M35P | No | No | No | `cortex-m35p` | `+soft-float,-dsp` |
| Cortex-M35P | No | Yes | No | `cortex-m35p` | `+soft-float` |
| Cortex-M35P | No | No | No | `cortex-m35p` | `-fpregs,-dsp` |
| Cortex-M35P | No | Yes | No | `cortex-m35p` | `-fpregs` |
| Cortex-M35P | SP | No | No | `cortex-m35p` | `-dsp` |
| Cortex-M35P | SP | Yes | No | `cortex-m35p` | None |
| Cortex-M55 | No | Yes | No | `cortex-m55` | `+soft-float,-mve` |
| Cortex-M55 | No | Yes | No | `cortex-m55` | `-fpregs,-mve` |
| Cortex-M55 | DP | Yes | No | `cortex-m55` | `-mve` |
| Cortex-M55 | No | Yes | Int | `cortex-m55` | `+soft-float,-mve.fp` |
| Cortex-M55 | No | Yes | Int | `cortex-m55` | `-fpregs,-mve.fp,+mve`|
| Cortex-M55 | DP | Yes | Int | `cortex-m55` | `-mve.fp` |
| Cortex-M55 | DP | Yes | Int+Float | `cortex-m55` | None |
| Cortex-M85 | No | Yes | No | `cortex-m85` | `+soft-float,-mve` |
| Cortex-M85 | No | Yes | No | `cortex-m85` | `-fpregs,-mve` |
| Cortex-M85 | DP | Yes | No | `cortex-m85` | `-mve` |
| Cortex-M85 | No | Yes | Int | `cortex-m85` | `+soft-float,-mve.fp` |
| Cortex-M85 | No | Yes | Int | `cortex-m85` | `-fpregs,-mve.fp,+mve`|
| Cortex-M85 | DP | Yes | Int | `cortex-m85` | `-mve.fp` |
| Cortex-M85 | DP | Yes | Int+Float | `cortex-m85` | None |

Expand All @@ -74,6 +74,19 @@ to use these flags.
| Cortex-M85 | DP | Yes | Int | `cortex-m85` | `-mve.fp` |
| Cortex-M85 | DP | Yes | Int+Float | `cortex-m85` | None |

*Technically* you can use this hard-float ABI on a CPU which has no FPU but does
have Integer MVE, because MVE provides the same set of registers as the FPU
(including `s0` and `d0`). The particular set of flags that might enable this
unusual scenario are currently not recorded here.

<div class="warning">

Never use the `-fpregs` *target-feature* with the `thumbv8m.main-none-eabihf`
target as it will cause compilation units to have different ABIs, which is
unsound.

</div>

### Arm Cortex-M33

The target CPU is `cortex-m33`.
Expand All @@ -83,7 +96,7 @@ The target CPU is `cortex-m33`.
* enabled by default with this *target-cpu*
* Has an optional single precision FPU
* support is enabled by default with this *target-cpu*
* disable support using the `+soft-float` feature (`eabi` only)
* disable support using the `-fpregs` *target-feature* (`eabi` only)

### Arm Cortex-M35P

Expand All @@ -94,7 +107,7 @@ The target CPU is `cortex-m35p`.
* enabled by default with this *target-cpu*
* Has an optional single precision FPU
* support is enabled by default with this *target-cpu*
* disable support using the `+soft-float` feature (`eabi` only)
* disable support using the `-fpregs` *target-feature* (`eabi` only)

### Arm Cortex-M55

Expand All @@ -106,7 +119,7 @@ The target CPU is `cortex-m55`.
* Has an optional double-precision FPU that also supports half-precision FP16
values
* support is enabled by default with this *target-cpu*
* disable support using the `+soft-float` feature (`eabi` only)
* disable support using the `-fpregs` *target-feature* (`eabi` only)
* Has optional support for M-Profile Vector Extensions
* Also known as *Helium Technology*
* Available with only integer support, or both integer/float support
Expand All @@ -125,7 +138,7 @@ The target CPU is `cortex-m85`.
* Has an optional double-precision FPU that also supports half-precision FP16
values
* support is enabled by default with this *target-cpu*
* disable support using the `+soft-float` feature (`eabi` only)
* disable support using the `-fpregs` *target-feature* (`eabi` only)
* Has optional support for M-Profile Vector Extensions
* Also known as *Helium Technology*
* Available with only integer support, or both integer/float support
Expand Down

0 comments on commit edbd939

Please sign in to comment.