From 9d1b3ea0e81f011c2bf0e725035667bfe4c922f8 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 15 Mar 2025 14:57:21 -0700 Subject: [PATCH 1/3] testdata/issues: add fixture for #306 The underlying issue appears to be a feature-gated interface. --- testdata/issues/issue306.wit | 19 +++++ testdata/issues/issue306.wit.json | 80 ++++++++++++++++++++ testdata/issues/issue306.wit.json.golden.wit | 19 +++++ 3 files changed, 118 insertions(+) create mode 100644 testdata/issues/issue306.wit create mode 100644 testdata/issues/issue306.wit.json create mode 100644 testdata/issues/issue306.wit.json.golden.wit diff --git a/testdata/issues/issue306.wit b/testdata/issues/issue306.wit new file mode 100644 index 00000000..46a4c6b0 --- /dev/null +++ b/testdata/issues/issue306.wit @@ -0,0 +1,19 @@ +// https://github.com/bytecodealliance/go-modules/issues/306 +package issues:issue306; + +world w { + include issues:dep1/w; +} + +package issues:dep1 { + world w { + import issues:dep2/gated-interface; + } +} + +package issues:dep2 { + @unstable(feature = some-feature-gate) + interface gated-interface { + f: func(v: u64) -> s32; + } +} diff --git a/testdata/issues/issue306.wit.json b/testdata/issues/issue306.wit.json new file mode 100644 index 00000000..0fac3944 --- /dev/null +++ b/testdata/issues/issue306.wit.json @@ -0,0 +1,80 @@ +{ + "worlds": [ + { + "name": "w", + "imports": { + "interface-0": { + "interface": { + "id": 0 + } + } + }, + "exports": {}, + "package": 1 + }, + { + "name": "w", + "imports": { + "interface-0": { + "interface": { + "id": 0 + } + } + }, + "exports": {}, + "package": 2 + } + ], + "interfaces": [ + { + "name": "gated-interface", + "types": {}, + "functions": { + "f": { + "name": "f", + "kind": "freestanding", + "params": [ + { + "name": "v", + "type": "u64" + } + ], + "result": "s32" + } + }, + "stability": { + "unstable": { + "feature": "some-feature-gate" + } + }, + "package": 0 + } + ], + "types": [], + "packages": [ + { + "name": "issues:dep2", + "interfaces": { + "gated-interface": 0 + }, + "worlds": {} + }, + { + "name": "issues:dep1", + "interfaces": {}, + "worlds": { + "w": 0 + } + }, + { + "name": "issues:issue306", + "docs": { + "contents": "https://github.com/bytecodealliance/go-modules/issues/306" + }, + "interfaces": {}, + "worlds": { + "w": 1 + } + } + ] +} \ No newline at end of file diff --git a/testdata/issues/issue306.wit.json.golden.wit b/testdata/issues/issue306.wit.json.golden.wit new file mode 100644 index 00000000..ac07c003 --- /dev/null +++ b/testdata/issues/issue306.wit.json.golden.wit @@ -0,0 +1,19 @@ +package issues:dep1; + +world w { + import issues:dep2/gated-interface; +} + +/// https://github.com/bytecodealliance/go-modules/issues/306 +package issues:issue306 { + world w { + import issues:dep2/gated-interface; + } +} + +package issues:dep2 { + @unstable(feature = some-feature-gate) + interface gated-interface { + f: func(v: u64) -> s32; + } +} From 69bc09d784ee2df73f1bd0fc0c3f45fd2d3990d7 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 15 Mar 2025 14:58:02 -0700 Subject: [PATCH 2/3] wit/bindgen: run wasm-tools with --all-features Fixes #306. --- wit/bindgen/generator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wit/bindgen/generator.go b/wit/bindgen/generator.go index 719bbafc..7ad70478 100644 --- a/wit/bindgen/generator.go +++ b/wit/bindgen/generator.go @@ -2417,7 +2417,7 @@ func (g *generator) componentEmbed(witData string) ([]byte, error) { // TODO: --all-features? filename := "component.wit" - args := []string{"component", "embed", "--only-custom", filename} + args := []string{"component", "embed", "--only-custom", "--all-features", filename} fsMap := map[string]fs.FS{ "": fstest.MapFS{ filename: &fstest.MapFile{Data: []byte(witData)}, From 86ed2025f8a240761a971f3731e98e704debdde2 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 15 Mar 2025 15:10:47 -0700 Subject: [PATCH 3/3] CHANGELOG: update for #306 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12222749..d1fbef05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - [#281](https://github.com/bytecodealliance/go-modules/issues/281): errors from internal `wasm-tools` calls are no longer silently ignored. This required fixing a number of related issues, including synthetic world packages for Component Model metadata generation, WIT generation, and WIT keyword escaping in WIT package or interface names. - [#284](https://github.com/bytecodealliance/go-modules/issues/284): do not use `bool` for `variant` or `result` GC shapes. TinyGo returns `result` and `variant` values with `bool` as 0 or 1, which breaks the memory representation of tagged unions (variants). - [#288](https://github.com/bytecodealliance/go-modules/issues/288): correctly report the `wasm32` ABI alignment of `list` as 4, rather than 8. +- [#306](https://github.com/bytecodealliance/go-modules/issues/306): run `wasm-tools` with the `--all-features` argument so feature-gated WIT is correctly found when synthesizing Component Model metadata for a Go package. ## [v0.5.0] — 2024-12-14