[PATCH] D81689: [WebAssembly] New-style command support

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 13:48:58 PDT 2020


sunfish created this revision.
Herald added subscribers: aheejin, jgravelle-google, sbc100, dschuff.
Herald added a project: LLVM.

This adds support for new-style command support. In this mode, all exports
are considered command entrypoints, and the linker inserts calls to
`__wasm_call_ctors` and `__wasm_call_dtors` for all such entrypoints.

This enables support for:

- Command entrypoints taking arguments other than strings and return values other than `int`.
- Multicall executables without requiring on the use of string-based command-line arguments.

This new behavior is disabled when the input has an explicit call to
`__wasm_call_ctors`, indicating code not expecting new-style command
support.

This change does mean that wasm-ld no longer supports DCE-ing the
`__wasm_call_ctors` function when there are no calls to it. If there are no
calls to it, and there are ctors present, we assume it's wasm-ld's job to
insert the calls. This seems ok though, because if there are ctors present,
the program is expecting them to be called. This change affects the
init-fini-gc.ll test.

This also adds a `--emscripten` flag and issues a warning if `-shared` or
`-pie` are used outside of Emscripten mode, to begin preparing for these
options to change meaning when Module Linking-based shared libraries are
implemented.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81689

Files:
  lld/test/wasm/command-exports-no-tors.ll
  lld/test/wasm/command-exports.ll
  lld/test/wasm/init-fini-gc.ll
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/InputChunks.h
  lld/wasm/MarkLive.cpp
  lld/wasm/Options.td
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81689.270226.patch
Type: text/x-patch
Size: 22733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/a9930610/attachment.bin>


More information about the llvm-commits mailing list