Skip to content

Commit edbd939

Browse files
committed
Auto merge of rust-lang#130987 - thejpster:revise-arm-platform-notes-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)
2 parents 3ec4308 + 5cc1c7b commit edbd939

File tree

3 files changed

+45
-22
lines changed

3 files changed

+45
-22
lines changed

src/doc/rustc/src/platform-support/arm-none-eabi.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ their own document.
4242
There are two 32-bit instruction set architectures (ISAs) defined by Arm:
4343

4444
- The [*A32 ISA*][a32-isa], with fixed-width 32-bit instructions. Previously
45-
known as the *Arm* ISA, this originated with the original Arm1 of 1985 and has
45+
known as the *Arm* ISA, this originated with the original ARM1 of 1985 and has
4646
been updated by various revisions to the architecture specifications ever
4747
since.
4848
- The [*T32 ISA*][t32-isa], with a mix of 16-bit and 32-bit width instructions.
4949
Note that this term includes both the original 16-bit width *Thumb* ISA
5050
introduced with the Armv4T architecture in 1994, and the later 16/32-bit sized
51-
*Thumb-2* ISA introduced with the Armv6T2 architecture in 2003.
52-
53-
Again, these ISAs have been revised by subsequent revisions to the relevant Arm
54-
architecture specifications.
51+
*Thumb-2* ISA introduced with the Armv6T2 architecture in 2003. Again, these
52+
ISAs have been revised by subsequent revisions to the relevant Arm
53+
architecture specifications.
5554

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

109-
**Note:** Many target-features are currently unstable and subject to change, and
108+
<div class="warning">
109+
110+
Many target-features are currently unstable and subject to change, and
110111
if you use them you should disassemble the compiler output and manually inspect
111112
it to ensure only appropriate instructions for your CPU have been generated.
112113

114+
</div>
115+
113116
If you wish to use the *target-cpu* and *target-feature* options, you can add
114117
them to your `.cargo/config.toml` file alongside any other flags your project
115118
uses (likely linker related ones):

src/doc/rustc/src/platform-support/thumbv7em-none-eabi.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ to use these flags.
3535
| CPU | FPU | DSP | Target CPU | Target Features |
3636
| ---------- | --- | --- | ----------- | --------------- |
3737
| Any | No | Yes | None | None |
38-
| Cortex-M4 | No | Yes | `cortex-m4` | `+soft-float` |
38+
| Cortex-M4 | No | Yes | `cortex-m4` | `-fpregs` |
3939
| Cortex-M4F | SP | Yes | `cortex-m4` | None |
40-
| Cortex-M7 | No | Yes | `cortex-m7` | `+soft-float` |
40+
| Cortex-M7 | No | Yes | `cortex-m7` | `-fpregs` |
4141
| Cortex-M7F | SP | Yes | `cortex-m7` | `-fp64` |
4242
| Cortex-M7F | DP | Yes | `cortex-m7` | None |
4343

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

53+
<div class="warning">
54+
55+
Never use the `-fpregs` *target-feature* with the `thumbv7em-none-eabihf` target
56+
as it will cause compilation units to have different ABIs, which is unsound.
57+
58+
</div>
59+
5360
### Arm Cortex-M4 and Arm Cortex-M4F
5461

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

6471
### Arm Cortex-M7 and Arm Cortex-M7F
6572

@@ -71,4 +78,4 @@ The target CPU is `cortex-m7`.
7178
* Cortex-M7F have either a single-precision or double-precision FPU
7279
* double-precision support is enabled by default with this *target-cpu*
7380
* opt-out by using the `-f64` *target-feature*
74-
* disable support entirely using the `+soft-float` feature (`eabi` only)
81+
* disable support entirely using the `-fpregs` *target-feature* (`eabi` only)

src/doc/rustc/src/platform-support/thumbv8m.main-none-eabi.md

+25-12
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ to use these flags.
3939
| CPU | FPU | DSP | MVE | Target CPU | Target Features |
4040
| ----------- | --- | --- | --------- | ------------- | --------------------- |
4141
| Unspecified | No | No | No | None | None |
42-
| Cortex-M33 | No | No | No | `cortex-m33` | `+soft-float,-dsp` |
43-
| Cortex-M33 | No | Yes | No | `cortex-m33` | `+soft-float` |
42+
| Cortex-M33 | No | No | No | `cortex-m33` | `-fpregs,-dsp` |
43+
| Cortex-M33 | No | Yes | No | `cortex-m33` | `-fpregs` |
4444
| Cortex-M33 | SP | No | No | `cortex-m33` | `-dsp` |
4545
| Cortex-M33 | SP | Yes | No | `cortex-m33` | None |
46-
| Cortex-M35P | No | No | No | `cortex-m35p` | `+soft-float,-dsp` |
47-
| Cortex-M35P | No | Yes | No | `cortex-m35p` | `+soft-float` |
46+
| Cortex-M35P | No | No | No | `cortex-m35p` | `-fpregs,-dsp` |
47+
| Cortex-M35P | No | Yes | No | `cortex-m35p` | `-fpregs` |
4848
| Cortex-M35P | SP | No | No | `cortex-m35p` | `-dsp` |
4949
| Cortex-M35P | SP | Yes | No | `cortex-m35p` | None |
50-
| Cortex-M55 | No | Yes | No | `cortex-m55` | `+soft-float,-mve` |
50+
| Cortex-M55 | No | Yes | No | `cortex-m55` | `-fpregs,-mve` |
5151
| Cortex-M55 | DP | Yes | No | `cortex-m55` | `-mve` |
52-
| Cortex-M55 | No | Yes | Int | `cortex-m55` | `+soft-float,-mve.fp` |
52+
| Cortex-M55 | No | Yes | Int | `cortex-m55` | `-fpregs,-mve.fp,+mve`|
5353
| Cortex-M55 | DP | Yes | Int | `cortex-m55` | `-mve.fp` |
5454
| Cortex-M55 | DP | Yes | Int+Float | `cortex-m55` | None |
55-
| Cortex-M85 | No | Yes | No | `cortex-m85` | `+soft-float,-mve` |
55+
| Cortex-M85 | No | Yes | No | `cortex-m85` | `-fpregs,-mve` |
5656
| Cortex-M85 | DP | Yes | No | `cortex-m85` | `-mve` |
57-
| Cortex-M85 | No | Yes | Int | `cortex-m85` | `+soft-float,-mve.fp` |
57+
| Cortex-M85 | No | Yes | Int | `cortex-m85` | `-fpregs,-mve.fp,+mve`|
5858
| Cortex-M85 | DP | Yes | Int | `cortex-m85` | `-mve.fp` |
5959
| Cortex-M85 | DP | Yes | Int+Float | `cortex-m85` | None |
6060

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

77+
*Technically* you can use this hard-float ABI on a CPU which has no FPU but does
78+
have Integer MVE, because MVE provides the same set of registers as the FPU
79+
(including `s0` and `d0`). The particular set of flags that might enable this
80+
unusual scenario are currently not recorded here.
81+
82+
<div class="warning">
83+
84+
Never use the `-fpregs` *target-feature* with the `thumbv8m.main-none-eabihf`
85+
target as it will cause compilation units to have different ABIs, which is
86+
unsound.
87+
88+
</div>
89+
7790
### Arm Cortex-M33
7891

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

88101
### Arm Cortex-M35P
89102

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

99112
### Arm Cortex-M55
100113

@@ -106,7 +119,7 @@ The target CPU is `cortex-m55`.
106119
* Has an optional double-precision FPU that also supports half-precision FP16
107120
values
108121
* support is enabled by default with this *target-cpu*
109-
* disable support using the `+soft-float` feature (`eabi` only)
122+
* disable support using the `-fpregs` *target-feature* (`eabi` only)
110123
* Has optional support for M-Profile Vector Extensions
111124
* Also known as *Helium Technology*
112125
* Available with only integer support, or both integer/float support
@@ -125,7 +138,7 @@ The target CPU is `cortex-m85`.
125138
* Has an optional double-precision FPU that also supports half-precision FP16
126139
values
127140
* support is enabled by default with this *target-cpu*
128-
* disable support using the `+soft-float` feature (`eabi` only)
141+
* disable support using the `-fpregs` *target-feature* (`eabi` only)
129142
* Has optional support for M-Profile Vector Extensions
130143
* Also known as *Helium Technology*
131144
* Available with only integer support, or both integer/float support

0 commit comments

Comments
 (0)