Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --component-type and --string-encoding options #32

Merged
merged 4 commits into from
Jul 15, 2024

Conversation

dicej
Copy link
Contributor

@dicej dicej commented Jul 12, 2024

Per bytecodealliance/wit-bindgen#994, this allows all or part of the component type to be specified as one or more WIT files rather than binary-encoded custom sections. This is akin to inserting a wasm-tools component embed command between the linking and componentization stages.

Per bytecodealliance/wit-bindgen#994, this allows all
or part of the component type to be specified as one or more WIT files rather
than binary-encoded custom sections.  This is akin to inserting a `wasm-tools
component embed` command between the linking and componentization stages.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you also be sure to add a test case too?

src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated
Comment on lines 581 to 586
if resolve.worlds.len() != 1 {
bail!(
"expected exactly 1 world in {wit_file:?}; found {}",
resolve.worlds.len()
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant about this as I'm afraid that worlds will sneak in pretty quickly. Could this perhaps stick to the "path plus --world" combo of other tools? That way this could use Resolve::select_world. It would preclude multiple --component-type arguments, however, so that would only work if that's ok for your use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be difficult for two reasons:

  • The goal is to be able to check this WIT file into source control and pass it to wasm-component-ld as easily as we were previously passing _component_type.o files, with no further information needed. Not sure where the world name would be stored.
  • There will definitely be more than one of these files in general. At least one will be bundled as part of the .NET runtime, and another coming from any bindings generated by the application developer (plus any which are part of SDKs that application is using).

Copy link
Contributor Author

@dicej dicej Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should reconsider using WIT (as opposed to e.g. WAT) for this? With WAT there isn't any notion of worlds -- just top-level imports and exports, so all the questions about which world (and which string encoding?) go away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or else: stick with WIT but ensure that wit-bindgen only ever emits exactly one world -- the one it was provided as input (i.e. flatten any include statements that refer to other worlds).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joel and I talked more about this and the conclusion was:

  • The general structure here will stay except that select_world will be used to provide some more future flexibility.
  • The generated *.wit file in the bindgen generators will be generated differently to work with this.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@dicej
Copy link
Contributor Author

dicej commented Jul 15, 2024

I've updated the code here to use Resolve::select_world and updated wit-bindgen to output only single-world WIT files. Working on a test case now.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! One minor comment but otherwise good to go

src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@alexcrichton alexcrichton added this pull request to the merge queue Jul 15, 2024
Merged via the queue into bytecodealliance:main with commit 4a5ffa9 Jul 15, 2024
12 checks passed
@dicej dicej deleted the component-type-option branch July 15, 2024 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants