Browse Source
Changing LLVM and/or Rust to avoid special handling of `main` is a fair amount of work, and there could be other toolchains with similar special rules for functions named `main`, so rename the command entrypoint back to `run`. We could potentially re-evaluate this in the future, such as in a preview3 timeframe, but for now, let's go with the simplest thing that works.pull/6374/head
Dan Gohman
2 years ago
committed by
GitHub
3 changed files with 14 additions and 36 deletions
@ -1,27 +0,0 @@ |
|||
# The component model CLI world exports its entrypoint under the name |
|||
# "main". However, LLVM has special handling for functions named `main` |
|||
# in order to handle the `main(void)` vs `main(int argc, char **argv)` |
|||
# difference on Wasm where the caller needs to know the exact signature. |
|||
# To avoid this, define a function with a different name and export it |
|||
# as `main`. |
|||
# |
|||
# To generate the `main.o` file from this `main.s` file, compile with |
|||
# `clang --target=wasm32-wasi -c main.s` |
|||
|
|||
.text |
|||
.functype main () -> (i32) |
|||
.export_name main, main |
|||
.functype _start () -> () |
|||
.import_name _start, _start |
|||
.import_module _start, __main_module__ |
|||
.section .text.main,"",@ |
|||
.hidden main |
|||
.globl main |
|||
.type main,@function |
|||
main: |
|||
.functype main () -> (i32) |
|||
call _start |
|||
i32.const 0 |
|||
return |
|||
end_function |
|||
.no_dead_strip main |
Loading…
Reference in new issue