[PATCH] D70520: [WebAssembly] Add new `export_name` clang attribute for controlling wasm export names

Dan Gohman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 20 20:32:13 PST 2019


sunfish added a comment.

It appears this doesn't handle exporting an imported function yet, which is fine for now, but it would be good to issue a warning, because wasm itself is capable of representing this:

  void aaa(void) __attribute__((import_module("imp"), import_name("foo"), export_name("bar")));



================
Comment at: lld/wasm/Writer.cpp:523
+      StringRef exportName = f->function->getExportName();
+      if (!exportName.empty()) {
+        name = exportName;
----------------
For wasm exports, it's valid to have empty strings. In fact, I may even have a usecase which wants an empty-string export. It'd be good to use `Optional<>` for export names, rather than special-casing the empty string.

(wasm-ld does often special-case the empty string in symbol names, but wasm export strings aren't ordinary symbol names, so it'd be good to follow wasm's rules for them.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70520/new/

https://reviews.llvm.org/D70520





More information about the cfe-commits mailing list