[PATCH] D40559: Run Wasm entrypoint on load
Nicholas Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 09:09:13 PST 2017
ncw added a comment.
In https://reviews.llvm.org/D40559#938273, @ruiu wrote:
> I believe you want to report an error when a user passes both --relocatable and --entry.
That's already done by the existing code in `LinkerDriver::link`.
I've added a new test, and updated the existing ones, and I think all the cases are covered now.
================
Comment at: wasm/Driver.cpp:328
+ if (!Config->Entry.empty())
+ addSyntheticUndefinedFunction(Config->Entry);
----------------
sbc100 wrote:
> Don't we always want some kind of entry point for non-relocatable binaries. Without it it will be hard to gc unused functions. (I suppose we could use the '-u' flag to pin the function we want kept instead?)
I think it makes sense to allow having no entry point. In this case, the only exports will be the (non-hidden) functions defined in the `.o` files, plus the (non-hidden) functions defined in objects that were loaded from any `.a` files.
It would be nice for "completeness" to add a `-u` commandline argument, to allow pulling in symbols from `.a` files that come from translation units we're not otherwise touching.
I'm expecting that 99% of people with a Wasm module will be wanting to export an API consisting of several functions, so the `--entry` argument was never really going to be enough to be useful in the general case for selecting which functions should be exported.
I'll add `-u` support to wasm-lld while I'm at it!
================
Comment at: wasm/Driver.cpp:352
+ if (!Sym)
+ fatal("entry point not found: " + Config->Entry);
if (!Sym->isFunction())
----------------
sbc100 wrote:
> We probably don't need these two checks here and in Writer.cpp.
Done, I've kept the second checks as an assertion though. (And also added a check for whether Sym is actually defined, fixing a crash.)
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D40559
More information about the llvm-commits
mailing list