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

Support for RV32IM #4192

Open
puma314 opened this issue Mar 13, 2024 · 4 comments
Open

Support for RV32IM #4192

puma314 opened this issue Mar 13, 2024 · 4 comments
Labels
enhancement New feature or request riscv RISC-V

Comments

@puma314
Copy link

puma314 commented Mar 13, 2024

Is it possible to compile TinyGo to a RV32IM (RISC-V 32 bit) backend? I tried running

tinygo build -o main.elf -target=riscv32 main.go

But got the following error on this very simple program:

package main


func main() {
	a := 1
	b := 1
	c := a + b
	_ = c
}
$ tinygo build -o main.elf -target=riscv32 main.go
# runtime
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:30:21: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:84:42: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/time.go:11:33: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/baremetal.go:59:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/baremetal.go:64:2: undefined: exit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/panic.go:52:2: undefined: abort
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/panic.go:71:2: undefined: abort
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:14:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:26:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:35:4: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:69:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:90:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:96:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:184:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:264:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:269:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:276:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:283:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:288:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:290:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:336:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:338:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:340:3: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:351:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:359:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:360:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:364:4: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:366:4: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:381:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:383:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/print.go:385:2: undefined: putchar
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/runtime.go:70:9: undefined: ticksToNanoseconds
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/runtime.go:70:28: undefined: ticks
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:92:9: undefined: ticks
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:162:10: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:167:10: undefined: ticks
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:172:53: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:175:26: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:203:17: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:205:16: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:217:39: undefined: timeUnit
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler.go:223:4: undefined: sleepTicks
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/scheduler_any.go:15:31: undefined: nanosecondsToTicks
/opt/homebrew/Cellar/tinygo/0.31.2/src/runtime/time.go:12:9: undefined: nanosecondsToTicks
@aykevl
Copy link
Member

aykevl commented Mar 14, 2024

What is the board/chip you want to target? TinyGo needs a lot more than just the instruction set architecture.

@puma314
Copy link
Author

puma314 commented Mar 15, 2024

It's is a bit of an unusual use-case--our team is building a zero-knowledge VM (zkVM) that proves the execution of the RISC-V32im instruction set: https://github.com/succinctlabs/sp1.

We use ecalls to do stdin and stdout into the zkVM environment, but other than that usually we just have pure golang code that is proving some sort of computation.

@aykevl
Copy link
Member

aykevl commented Mar 15, 2024

In that case, the zkVM would be the target. Especially since you say this:

We use ecalls to do stdin and stdout into the zkVM environment, [...]

This means that functions like putchar would call those kinds of syscalls. The runtime needs to know about these sorts of details, for example to print panic messages or to correctly schedule goroutines.

Also, the linker will need to know details like at which address it can be linked and which memory area it can use for the heap.

@jharveyb
Copy link

Relevant PR from another zkVM project:

risc0#1

Relevant discussion:

risc0/risc0#1222

@deadprogram deadprogram added enhancement New feature or request riscv RISC-V labels Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request riscv RISC-V
Projects
None yet
Development

No branches or pull requests

4 participants