llvm-project/clang/test/CodeGen/wasm-call-main.c
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

14 lines
273 B
C

// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
// Mangle argc/argv main even when it's not defined in this TU.
#include <stddef.h>
int main(int argc, char *argv[]);
int foo(void) {
return main(0, NULL);
}
// CHECK: call i32 @__main_argc_argv(