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

Register target features in custom section when using xforms #3967

Merged
merged 2 commits into from
May 27, 2024

Conversation

daxpedda
Copy link
Collaborator

@daxpedda daxpedda commented May 22, 2024

I noticed that tools like wasm-opt don't like it when we use reference types but don't actually register them in the appropriate custom section as specified in the tooling convention (which is out of date).

crates/wasm-conventions/src/lib.rs Outdated Show resolved Hide resolved
crates/wasm-conventions/src/lib.rs Outdated Show resolved Hide resolved
@daxpedda daxpedda requested a review from Liamolucko May 25, 2024 12:27
crates/wasm-conventions/src/lib.rs Outdated Show resolved Hide resolved
crates/wasm-conventions/Cargo.toml Show resolved Hide resolved
crates/wasm-conventions/src/lib.rs Outdated Show resolved Hide resolved
crates/wasm-conventions/src/lib.rs Outdated Show resolved Hide resolved
crates/wasm-conventions/src/lib.rs Outdated Show resolved Hide resolved
@daxpedda daxpedda requested a review from Liamolucko May 26, 2024 07:08

// The first byte contains an integer describing the target feature count, which we increase by one.
let mut data = Cursor::new(&section.data);
let count = leb128::read::unsigned(&mut data).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't use unwrap, since it can fail if data ends while it's still reading or the integer doesn't fit in a u64.

Copy link
Collaborator Author

@daxpedda daxpedda May 26, 2024

Choose a reason for hiding this comment

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

This can't fail because we already read it successfully beforehand (or return an error on failure) or inserted it correctly ourselves if no section was found.

Let me know if I missed something!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, good point, I didn't think about that.

@daxpedda daxpedda requested a review from Liamolucko May 26, 2024 22:50
Copy link
Collaborator

@Liamolucko Liamolucko left a comment

Choose a reason for hiding this comment

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

LGTM!

@daxpedda daxpedda merged commit b4da51c into rustwasm:main May 27, 2024
25 checks passed
daxpedda added a commit to daxpedda/wasm-bindgen that referenced this pull request Jun 19, 2024
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