Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float emulation start for more embedded support #4143

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

laytan
Copy link
Collaborator

@laytan laytan commented Aug 25, 2024

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:

package main

import "base:runtime"

main :: proc() {
	runtime.print_string("Hello")
}

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 host sudo 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.

src/build_settings.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants