HomePhabricator

[WebAssembly] Mangle the argc/argv `main` as `__wasm_argc_argv`.

Authored by sunfishcode on Nov 25 2019, 9:50 AM.

Description

[WebAssembly] Mangle the argc/argv main as __wasm_argc_argv.

WebAssembly enforces a rule that caller and callee signatures must
match. This means that the traditional technique of passing main
argc and argv even when it doesn't need them doesn't work.

Currently the backend renames main to __original_main, however this
doesn't interact well with LTO'ing libc, and the name isn't intuitive.
This patch allows us to transition to __main_argc_argv instead.

This implements the proposal in
https://github.com/WebAssembly/tool-conventions/pull/134
with a flag to disable it when targeting Emscripten, though this is
expected to be temporary, as discussed in the proposal comments.

Differential Revision: https://reviews.llvm.org/D70700