Hi guys, I’m a rust newbie who has been exploring bare metal rust. I’ve been reading a lot of the RFCs, PRs, etc., and there seems to be some possible misunderstandings regarding soft float. I guess I’m sharing my thoughts here as a pre-RFC pre bug report type thing. Please let me know if you think I should raise an issue or RFC relating to any of this.
Issue 1
The rustc
codgen option soft-float -- generate software floating point library calls
is incorrect, looking at the source you can see it has nothing to do with generating software floating point calls (which you get with target-feature
codegen option), rather it changes the floating point ABI. This leads to expectations that something like this should work.
Possible solutions:
-
Fix the doc to say: “
soft-float -- force use of soft float ABI (this will likely make this link incompatible with everything else including core)
” -
Make the option mirror llvm correctly by: "
float-abi=type -- set the float ABI default, soft or hard
" This is potentially a breaking change. (My preferred option) -
Add the above but leave the former as an undocumented deprecated option to prevent a breaking change.
-
Get rid of the option entirely. It is a fairly useless option because it makes you incompatible with any other crate including
core
,std
. Although I guess it could be useful if you are not linking anything with floats.
Issue 2
The target configuration json has no way to specify the float ABI so you are stuck with the default of the triple. This is fine for arm, which has the float ABI is specifiable with the triple but, AFAIK, is not possible for aarch64, x86-64 and others. This leads to the need for things like float-free core
because you can’t specify a soft float ABI on all targets.
Solution:
- Add
float-abi
to target configuration with a default value ofdefault
so nothing breaks
Appendix
The use case for a lot of this is kernel development without using floating point registers. To ensure this you need to use a soft float ABI and make sure no floating point code is generated. The latter is done with target-feature
, from my experiments these are the target features needed but I’m sure you could look in llvm source to see exactly which.
- x86-64
-mmx,-sse,+soft-float
- aarch64
-fp-armv8
- arm
+soft-float