Skip to content

Format of the custom section #23

@alexcrichton

Description

@alexcrichton

The general idea behind this tool is that source languages will encode data into a custom section of the wasm binary which the wasm-bindgen tool will decode and remove, using it to generate appropriate JS bindings.

Currently, however, this isn't what happens! Instead we shove data into a static as rustc doesn't expose a way to emit data into a custom section as-is. Additionally the static is just a totally random encoding that I got working, it's not principled at all. We should fix that!

I think it's relatively uncontroversial to use a custom section to communicate this information, and we'll continue to work around rustc's lack of ability to emit a custom section in the meantime and will otherwise take advantage of the ability to do this in rustc as soon as it becomes available! In the meantime, though, I think it may be useful to discuss the custom format as well.

Right now the wasm-bindgen-cli-shared crate shows off effectively what's encoded right now, the top-level entry being a Program and a wasm binary has multiple Program instances. That is, however, only what the bindgen tool currently uses and will likely change over time both in requirements and breadth. In that sense, does it makes sense to lock down a binary format just yet? Or maybe we can lock down an extensible format like JSON which you can easily add keys to over time?

One thing I definitely want to do in the near term is to version the wasm-bindgen information in the sense that if the CLI installed at a particular git rev finds information produced by a different git rev then it should immediately generate an error saying they're out of sync (as it's so unstable). Eventually this'll probably get removed and we'll want to have the producer and consumer versioned separately, but that may be awhile!

In any case, this is all just some off-the-cuff thinking, I'd love to hear others' thoughts on this too!

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