Float emulation start for more embedded support #4143
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Had a quick look at float emulation today so we can support use cases where targets don't support floats in the future. With the current progress in this PR a simple hello world compiles for riscv64 without floats:
odin run test.odin -file -target:linux_riscv64 -no-crt -default-to-nil-allocator -reloc-mode:static -microarch:generic -target-features:"m"
(you want to have qemu user mode emulation if you are on another architecture for your hostsudo apt install qemu-user qemu-user-static
)When you start importing more packages and using more float features you will keep getting more linker errors about functions that are needed. The basic process is adding them to the runtime package and to the checker (in order to add it to the final output).
We think the implementations can just be ported from LLVM's compiler-rt https://github.com/llvm/llvm-project/tree/main/compiler-rt which uses the same license as llvm as a backend itself, so there shouldn't be any licensing issues.
Once we have float emulation for one target, adding it for other targets should be fairly simple.
I am making this a draft so somebody else can pick it up if they want to, because I don't have much time to spend on this in the near future.
So if anybody wants to pick this up further, you can just take the changes here as a base and add to it.