Skip to content

Conversation

@sbc100
Copy link
Member

@sbc100 sbc100 commented Jan 17, 2026

See https://github.com/WebAssembly/compact-import-section

For this initial commit I've just added a single simple test in form of test/binary/compact-imports.txt. Once we update the testsuite repo we can pull in the official tests.

@sbc100 sbc100 force-pushed the compact_import branch 2 times, most recently from 27733a7 to 66515ca Compare January 17, 2026 03:31
@sbc100 sbc100 requested a review from keithw January 17, 2026 03:31
@sbc100 sbc100 force-pushed the compact_import branch 2 times, most recently from 7df3a9e to e3ba87d Compare January 17, 2026 04:31
@sbc100 sbc100 requested a review from bvisness January 17, 2026 04:49
@sbc100 sbc100 requested a review from dschuff January 17, 2026 18:46
Copy link

@bvisness bvisness left a comment

Choose a reason for hiding this comment

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

All looks reasonable to me, although I've not looked at WABT's code before.

@sbc100 sbc100 force-pushed the compact_import branch 2 times, most recently from 7df27ea to a4bda2c Compare January 18, 2026 01:05
Base automatically changed from ReadExternalKind to main January 20, 2026 20:57
@sbc100 sbc100 force-pushed the compact_import branch 2 times, most recently from 753bf18 to 3720508 Compare January 20, 2026 21:01
See https://github.com/WebAssembly/compact-import-section

For this initial commit I've just added a single simple test
in form of test/binary/compact-imports.txt.  Once we update the
`testsuite` repo we can pull in the official tests.
Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

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

LGTM % few nits

@sbc100 sbc100 merged commit bad0cc8 into main Jan 21, 2026
17 checks passed
@sbc100 sbc100 deleted the compact_import branch January 21, 2026 20:53
@dschuff
Copy link
Member

dschuff commented Jan 21, 2026

This does sort of raise the question of how a tool should handle compact imports. Since it looks like there will be both a text and a binary format, you could argue that a true "pass-through/roundtrip" encoding would only encode compact imports in binary where they are encoded in the text. But of course it also makes sense to encode them everywhere possible, just to reduce binary size. Maybe wabt should default to only round-tripping? (And optionally have a flag to opportunistically use compact imports?)

@sbc100
Copy link
Member Author

sbc100 commented Jan 21, 2026

This does sort of raise the question of how a tool should handle compact imports. Since it looks like there will be both a text and a binary format, you could argue that a true "pass-through/roundtrip" encoding would only encode compact imports in binary where they are encoded in the text. But of course it also makes sense to encode them everywhere possible, just to reduce binary size. Maybe wabt should default to only round-tripping? (And optionally have a flag to opportunistically use compact imports?)

Right now that flag is --enable-compact-imports. Do you think we would ever want the binaryen writer to not opportunistically use compact imports when the feature is enabled?

I guess if we might have users who want to enable them in the reader but disabled them in the writer, but so far that hasn't come up for other features.

@dschuff
Copy link
Member

dschuff commented Jan 21, 2026

Right, for Binaryen, I don't know of any case where we wouldn't want to opportunistically use compact imports when they are enabled. Wabt is more interesting, because its job is to be a low-level tool that round-trips text and binary, rather than an optimization/transformation tool, and changing the encoding is a transformation.

@sbc100
Copy link
Member Author

sbc100 commented Jan 21, 2026

Yeah, right no the compact imports are not remembered on read, and we write them purely opportunistically. We should probably followup by preserving them in the IR instead.

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.

5 participants