-
Notifications
You must be signed in to change notification settings - Fork 11
Description
First of all thanks for this repository. This has been pretty informative and interesting.
I'm trying to replicate this repo using LLVM 16.0.4 instead of 14.0.6. I've successfully cross-compiled llc and lld. And i've got the resulting binary files. The issue arises when I try to compile the example LLVM IR, I get the following error:
this.program: error: /lib/wasm32-wasi/libc.a(__main_void.o): undefined symbol: main
Comparing the resulting main.o
files from the 14 and 16 version respectively with wasm2wat I get the following:
14
(type (;0;) (func (result i32)))
(type (;1;) (func (param i32 i32) (result i32)))
(import "env" "__linear_memory" (memory (;0;) 1))
(import "env" "printf" (func (;0;) (type 1)))
(import "env" "__indirect_function_table" (table (;0;) 0 funcref))
(func $__original_main (type 0) (result i32)
i32.const 0
i32.const 0
call 0
drop
i32.const 0)
(func $main (type 1) (param i32 i32) (result i32)
call $__original_main)
(data $.L.str (i32.const 0) "Hello wasm!\0a\00"))
16
(type (;0;) (func (result i32)))
(type (;1;) (func (param i32 i32) (result i32)))
(import "env" "__linear_memory" (memory (;0;) 1))
(import "env" "printf" (func (;0;) (type 1)))
(func $__original_main (type 0) (result i32)
i32.const 0
i32.const 0
call 0
drop
i32.const 0)
(func $main (type 1) (param i32 i32) (result i32)
call $__original_main)
(data $.L.str (i32.const 0) "Hello wasm!\0a\00"))
The only noticeable difference I can see is the lack of the (import "env" "__indirect_function_table" (table (;0;) 0 funcref))
instruction on the 16 version. But I don't know how to tell the compiler to add that instruction.
Searching for an answer I found that that __original_main
main should no longer be generated with the new LLVM versions (from 14 onwards), but yours is 14 and still has it, so I don't know what that means.
You can try it on my fork, here, in case you have time and want to take a look.