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

internal: some WIP on being able to compile wazero for MCUs using TinyGo #1855

Closed
wants to merge 5 commits into from

Conversation

deadprogram
Copy link
Contributor

This PR is a place for some WIP on getting wazero to compile with TinyGo so it can be run on microcontrollers.

See #1854 for details.

This is as far as I have been able to get this far with the code in this PR:

$ tinygo build -o basic.uf2 -target=itsybitsy-m4 -tags=tinygo ./examples/basic/
# github.com/tetratelabs/wazero/internal/sock
internal/sock/sock.go:66:59: undefined: net.TCPListener
internal/sock/sock_supported.go:8:22: undefined: syscall.SHUT_RD
internal/sock/sock_supported.go:9:22: undefined: syscall.SHUT_RDWR
internal/sock/sock_supported.go:10:22: undefined: syscall.SHUT_WR
internal/sock/sock.go:73:28: undefined: net.TCPListener

@deadprogram
Copy link
Contributor Author

Now that I look bit deeper, the bigger problem is likely to be not being able to generate the needed code for the target itself that it would be running on: https://github.com/tetratelabs/wazero/tree/main/internal/asm

This is not a small task.

@ncruces
Copy link
Collaborator

ncruces commented Nov 30, 2023

Is an interpreter not useful at all?

@deadprogram
Copy link
Contributor Author

Is an interpreter not useful at all?

I would be happy to get interpreter working, but not sure that will work either due to instruction set of target being ARMv7-M Thumb

@evacchi
Copy link
Contributor

evacchi commented Dec 1, 2023

the interpreter should work regardless. You can compile wazero today to wasm with GOOS=wasip1 GOARCH=wasm and it will build the interpreter.

@deadprogram
Copy link
Contributor Author

the interpreter should work regardless.

OK, good to know. I will continue playing with it this weekend.

@deadprogram
Copy link
Contributor Author

With my latest commits using a couple unmerged branches of tinygo, I am now getting this:

$ tinygo build -o wazero-micro.uf2 -target itsybitsy-m4 -stack-size 8kb -tags tinygo ./examples/basic/
tinygo:ld.lld: error: undefined hidden symbol: __math_invalidf
>>> referenced by sf_sqrt.c:0 (/home/ron/Development/tinygo/tinygo/lib/picolibc/newlib/libm/math/sf_sqrt.c:0)
>>>               sf_sqrt.c.o:(sqrtf) in archive /home/ron/.cache/tinygo/picolibc-thumbv7em-unknown-unknown-eabi-cortex-m4/lib.a
>>> did you mean: __math_invalid
>>> defined in: /home/ron/.cache/tinygo/picolibc-thumbv7em-unknown-unknown-eabi-cortex-m4/lib.a(math_err_invalid)
failed to run tool: ld.lld
error: failed to link /tmp/tinygo2978757582/main: exit status 1

@deadprogram
Copy link
Contributor Author

A couple fixes from @aykevl and I was able to at least compile:

$ tinygo build -size short -o wazero-micro.uf2 -target itsybitsy-m4 -stack-size 8kb -tags tinygo ./examples/basic/
   code    data     bss |   flash     ram
 375788   72072   18544 |  447860   90616

Now to start getting things to work!

@evacchi
Copy link
Contributor

evacchi commented Dec 8, 2023

Nice!

@evacchi
Copy link
Contributor

evacchi commented Feb 14, 2024

nice to see further progress here!

@evacchi
Copy link
Contributor

evacchi commented Mar 26, 2024

should we close this one?

@deadprogram
Copy link
Contributor Author

Closing in favor of the @orsinium collection of PRs.

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.

3 participants