Dan Gohman 00072c08c7 [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
2020-02-27 07:55:36 -08:00

10 lines
178 B
C

// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
// Don't mangle the no-arg form of main.
int main(void) {
return 0;
}
// CHECK-LABEL: define i32 @main()