Skip to content

json-from-wast: name emitted files after the output stem - #2542

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
eyupcanakman:fix/json-from-wast-wabt-output
Jun 29, 2026
Merged

alexcrichton merged 1 commit into
bytecodealliance:mainfrom
eyupcanakman:fix/json-from-wast-wabt-output

Conversation

@eyupcanakman

@eyupcanakman eyupcanakman commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

json-from-wast named its emitted *.wasm and *.wat files after the source .wast stem, so -o out.json still wrote <source>.0.wasm rather than out.0.wasm the way wast2json does. This derives the stem from the -o output path when one is given and falls back to the source stem otherwise. Added a cli test for both cases.

Refs #1471.

@eyupcanakman
eyupcanakman requested a review from a team as a code owner June 19, 2026 20:32
@eyupcanakman
eyupcanakman requested review from alexcrichton and removed request for a team June 19, 2026 20:32
@alexcrichton

Copy link
Copy Markdown
Member

Thanks! The CI failure might be some CRLF thing, but I'm not entirely sure.

Out of curiosity though, could you explain a bit more why you want an exact match? Naively it seems good to strip the leading $ and it seems better to render "-1" instead of u32::MAX. I'm not opposed to these changes necessarily, but for future-selves I think it'd be good to have written down motivation. (even if it's "just because it's nice to byte-for-byte match" if that's the case)

@eyupcanakman

Copy link
Copy Markdown
Contributor Author

It was just to match wast2json more closely, but your question made me check who consumes this, and chicory (which runs json-from-wast) parses the i32/i64 values as signed, so the unsigned change would break their Integer.parseInt (and probably the $-prefix). I'd lean toward trimming this to just the filename fix and dropping the int and name changes, unless you'd rather keep the full match. The Windows fail was a path-separator thing in the test, not CRLF, and I'll fix that.

@alexcrichton

Copy link
Copy Markdown
Member

That sounds reasonable to me, yeah 👍

The emitted `*.wasm` and `*.wat` files used the source `.wast` stem, so `-o out.json` wrote `<source>.0.wasm` instead of `out.0.wasm` like `wast2json`. Derive the stem from the `-o` output path when present and fall back to the source stem otherwise.

Refs bytecodealliance#1471.
@eyupcanakman
eyupcanakman force-pushed the fix/json-from-wast-wabt-output branch from ff56368 to 80bdb63 Compare June 25, 2026 20:16
@eyupcanakman eyupcanakman changed the title Bring json-from-wast output closer to wast2json json-from-wast: name emitted files after the output stem Jun 25, 2026
@eyupcanakman

Copy link
Copy Markdown
Contributor Author

Trimmed this to just the filename change and reverted the int and name bits along with the snapshots. The Windows fail was the cli test runner handing a backslash path to source_filename, so I normalized the % substitution to forward slashes like wast already does.

@alexcrichton alexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@alexcrichton
alexcrichton added this pull request to the merge queue Jun 29, 2026
Merged via the queue into bytecodealliance:main with commit e6e1797 Jun 29, 2026
70 of 72 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
wasm-tools 1.253.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* Limit the element count of fixed-length lists by @eyupcanakman in bytecodealliance/wasm-tools#2537
* wasmparser: Rename BinaryReaderError to Error by @lann in bytecodealliance/wasm-tools#2546
* fix: signature lowering for strings and lists on modules with 64bit memory by @christoph-dfinity in bytecodealliance/wasm-tools#2544
* json-from-wast: name emitted files after the output stem by @eyupcanakman in bytecodealliance/wasm-tools#2542
* Refactor `KebabStr` to not require unsafe code by @alexcrichton in bytecodealliance/wasm-tools#2548
* Add CustomSectionReader -> BinaryReader conversion by @WorldSEnder in bytecodealliance/wasm-tools#2550
* wasmparser: Add Error::missing_wasm_feature by @lann in bytecodealliance/wasm-tools#2549
* fix: use ptr-sized type when returning via ptr indirection under memory64 by @christoph-dfinity in bytecodealliance/wasm-tools#2553
* Synchronize threading intrinsics with specification by @alexcrichton in bytecodealliance/wasm-tools#2554
* Remove `resource.drop async` by @alexcrichton in bytecodealliance/wasm-tools#2552
* Initial work for `versionsuffix` and `external-id` by @alexcrichton in bytecodealliance/wasm-tools#2555
* Make parsing errors downcastable by @PhoebeSzmucer in bytecodealliance/wasm-tools#2557
* Add `SourceMap::resolve_span` for resolving global span locations by @PhoebeSzmucer in bytecodealliance/wasm-tools#2559
* Render error by @PhoebeSzmucer in bytecodealliance/wasm-tools#2560
* Support `external-id` on more items by @alexcrichton in bytecodealliance/wasm-tools#2558
* Release wasm-tools 1.253.0 by @github-actions[bot] in bytecodealliance/wasm-tools#2561

## New Contributors
* @christoph-dfinity made their first contribution in bytecodealliance/wasm-tools#2544

**Full Changelog**: https://github.com/bytecodealliance/wasm-tools/compare/v1.252.0...v1.253.0</pre>
  <p>View the full release notes at <a href="https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.253.0">https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.253.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!13746
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