Skip to content

Add --entry command line parameter #231

Closed

Description

@jfbastien

I'd like to be able to invoke wasm.opt awesome.wast --entry main and automatically get main invoked (as if awesome.wast had (invoke main ...)). This is desirable because I already have valid .wast files (and create .wasm binaries with them), and invoke is an extra for spec's convenience which isn't valid .wast. It's similar to how C programs by default have main as an entry point and UNIX-y environments _start (which then calls main).

binaryen's interpreter supports a similar option, and automatically figure out the number of parameters for main (because the export sometimes has 0, 1, or 2 parameters):
WebAssembly/binaryen@c0c40ce

Activity

  1. haxxpop commented on Feb 3, 2016

    @haxxpop
    Contributor

    lgtm

  2. sunfishcode commented on Feb 3, 2016

    @sunfishcode
    Member

    How does this relate to WebAssembly/design#495?

  3. kripken commented on Feb 3, 2016

    @kripken
    Member

    What do you mean by wasm.opt? We don't have a tool by that name currently?

  4. haxxpop commented on Feb 3, 2016

    @haxxpop
    Contributor

    @kripken it's from make opt (the native version of wasm)
    @sunfishcode I think that is exactly what @jfbastien means. However, that feature has not been implemented in spec yet. I would probably implement it soon, if you want :)

  5. kripken commented on Feb 3, 2016

    @kripken
    Member

    @haxxpop oh right, thanks!

  6. sunfishcode commented on Feb 3, 2016

    @sunfishcode
    Member

    @haxxpop Yes, it would be good to keep the spec and the design in sync, rather than having them each do their own thing. Thanks!

  7. jfbastien commented on Feb 3, 2016

    @jfbastien
    MemberAuthor

    That's what binaryen-shell does now, and it's convenient. We can also standardize on invoke or some declarator for entry point, but right now I'd like something and I'd like it to be uniform between tools, so IMO agreeing with the design isn't as high priority as getting things working.

  8. lukewagner commented on Feb 3, 2016

    @lukewagner
    Member

    In the interim before start is implemented in ml-proto, seems easy enough to work around in the harness by appending (invoke blah) to the .wast.

  9. rossberg commented on Feb 4, 2016

    @rossberg
    Member

    I'll look into it.

  10. jfbastien commented on Feb 4, 2016

    @jfbastien
    MemberAuthor

    It seems like renaming "invoke" to "start" and enforcing that there's just one is the best approach. I'll add support for "start" to binaryen.

  11. rossberg commented on Feb 4, 2016

    @rossberg
    Member

    I actually think that 'invoke' makes much more sense, since you can invoke any exported function. You can just as well allow multiple --invoke parameters on the command line. This is somewhat orthogonal to the start function.

  12. jfbastien commented on Feb 4, 2016

    @jfbastien
    MemberAuthor

    Supporting "start" from binaryen is indeed orthogonal to adding command-line parameters to spec.

    I'd rather call the parameter --entry though, since binaryen-shell already uses that name and it's consistent with Linux-y things.

  13. added a commit that references this issue on Feb 4, 2016
  14. jfbastien commented on Feb 4, 2016

    @jfbastien
    MemberAuthor

    I opened a PR to add start to binaryen: WebAssembly/binaryen#182

  15. added a commit that references this issue on Feb 5, 2016
  16. sunfishcode commented on Feb 12, 2016

    @sunfishcode
    Member

    With start now in both design and spec, is this issue still needed?

  17. jfbastien commented on Feb 12, 2016

    @jfbastien
    MemberAuthor

    No, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions