[all-commits] [llvm/llvm-project] 00072c: [WebAssembly] Mangle the argc/argv `main` as `__wa...

Dan Gohman via All-commits all-commits at lists.llvm.org
Thu Feb 27 07:56:05 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 00072c08c75050ae2c835b7bb0e505475dbcd7b9
      https://github.com/llvm/llvm-project/commit/00072c08c75050ae2c835b7bb0e505475dbcd7b9
  Author: Dan Gohman <sunfish at mozilla.com>
  Date:   2020-02-27 (Thu, 27 Feb 2020)

  Changed paths:
    M clang/lib/AST/Mangle.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/lib/CodeGen/CodeGenModule.h
    M clang/lib/Frontend/InitHeaderSearch.cpp
    A clang/test/CodeGen/wasm-call-main.c
    A clang/test/CodeGen/wasm-main.c
    A clang/test/CodeGen/wasm-main_argc_argv.c

  Log Message:
  -----------
  [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




More information about the All-commits mailing list