[PATCH] D42520: Implement __attribute__((import_module("foo")))

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 08:29:48 PST 2018


sunfish added a comment.

In https://reviews.llvm.org/D42520#987422, @ncw wrote:

> However, https://reviews.llvm.org/D42495 currently in progress involves changing the way symbols are read from a Wasm object file. There's now going to be an explicit symbol table, so the linker won't resolve all imports, but only imports which correspond to symbols. I guess we could have WasmObjectWriter skip any imports that aren't in the `__linker_resolve` module, and not create symbols for them; and the linker could merge together imports from the object files that come from other modules...


I'm behind on the new symbol table structure. What you propose here makes sense. In fact, in that case we can probably eliminate the "__linker_resolve" special name, and just have a bool in MCSymbolWasm which indicates whether a symbol should be omitted from the symbol table.

> Is there any current use-case for allowing the module to be customised?

Linking with ES modules. A tool could generate a C/C++ header file which declares functions provided by the ES module, which could use this attribute to set up the module name.

And actually, thinking about both of these together, I think we should take this attribute a step further and include the fieldname, as in: `__attribute__((import("modulename", "fieldname")))` or so, because you may want to use a different fieldname than the C++ declaration name. I'll rework the patch along these lines.


Repository:
  rL LLVM

https://reviews.llvm.org/D42520





More information about the llvm-commits mailing list