LLVM backend generates incorrect `main` function for wasm32
Open
Nobody has claimed this yet.
P-low
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Steps to Reproduce
hello.lean
def main : IO Unit := do
IO.println s!"Hello!"
lean --bc=Hello.bc --target=wasm32 hello.leanwasm2wat Hello.bc.o | grep main
(func $_lean_main (type 0) (param i32) (result i32)
(func $_init_l_main___closed__1 (type 2) (result i32)
call $_init_l_main___closed__1
(func $main (type 6) (param i64 i32) (result i64)
call $_lean_main
(data $l_main___closed__1 (i32.const 0) "\00\00\00\00")
Expected behavior: main's signature should be (i32, i32) -> i32
Actual behavior: is (i64, i32) -> i64
Versions
Lean (version 4.0.0, commit 4b974fd60b9f, Release)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the hello.lean example and reproduce the issue using lean --bc=Hello.bc --target=wasm32 hello.lean. Inspect the LLVM backend path that generates wasm32's main entry point, then use wasm2wat Hello.bc.o to compare the emitted signature with the expected (i32, i32) -> i32 result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100