Skip to content

Commit 27486dd

Browse files
authored
Merge pull request #307 from bytecodealliance/ydnar/issue-306
wit/bindgen: always run wasm-tools with --all-features
2 parents cfe612d + 86ed202 commit 27486dd

File tree

5 files changed

+120
-1
lines changed

5 files changed

+120
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
2121
- [#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.
2222
- [#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).
2323
- [#288](https://github.com/bytecodealliance/go-modules/issues/288): correctly report the `wasm32` ABI alignment of `list<T>` as 4, rather than 8.
24+
- [#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.
2425

2526
## [v0.5.0] — 2024-12-14
2627

testdata/issues/issue306.wit

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// https://github.com/bytecodealliance/go-modules/issues/306
2+
package issues:issue306;
3+
4+
world w {
5+
include issues:dep1/w;
6+
}
7+
8+
package issues:dep1 {
9+
world w {
10+
import issues:dep2/gated-interface;
11+
}
12+
}
13+
14+
package issues:dep2 {
15+
@unstable(feature = some-feature-gate)
16+
interface gated-interface {
17+
f: func(v: u64) -> s32;
18+
}
19+
}

testdata/issues/issue306.wit.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"worlds": [
3+
{
4+
"name": "w",
5+
"imports": {
6+
"interface-0": {
7+
"interface": {
8+
"id": 0
9+
}
10+
}
11+
},
12+
"exports": {},
13+
"package": 1
14+
},
15+
{
16+
"name": "w",
17+
"imports": {
18+
"interface-0": {
19+
"interface": {
20+
"id": 0
21+
}
22+
}
23+
},
24+
"exports": {},
25+
"package": 2
26+
}
27+
],
28+
"interfaces": [
29+
{
30+
"name": "gated-interface",
31+
"types": {},
32+
"functions": {
33+
"f": {
34+
"name": "f",
35+
"kind": "freestanding",
36+
"params": [
37+
{
38+
"name": "v",
39+
"type": "u64"
40+
}
41+
],
42+
"result": "s32"
43+
}
44+
},
45+
"stability": {
46+
"unstable": {
47+
"feature": "some-feature-gate"
48+
}
49+
},
50+
"package": 0
51+
}
52+
],
53+
"types": [],
54+
"packages": [
55+
{
56+
"name": "issues:dep2",
57+
"interfaces": {
58+
"gated-interface": 0
59+
},
60+
"worlds": {}
61+
},
62+
{
63+
"name": "issues:dep1",
64+
"interfaces": {},
65+
"worlds": {
66+
"w": 0
67+
}
68+
},
69+
{
70+
"name": "issues:issue306",
71+
"docs": {
72+
"contents": "https://github.com/bytecodealliance/go-modules/issues/306"
73+
},
74+
"interfaces": {},
75+
"worlds": {
76+
"w": 1
77+
}
78+
}
79+
]
80+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package issues:dep1;
2+
3+
world w {
4+
import issues:dep2/gated-interface;
5+
}
6+
7+
/// https://github.com/bytecodealliance/go-modules/issues/306
8+
package issues:issue306 {
9+
world w {
10+
import issues:dep2/gated-interface;
11+
}
12+
}
13+
14+
package issues:dep2 {
15+
@unstable(feature = some-feature-gate)
16+
interface gated-interface {
17+
f: func(v: u64) -> s32;
18+
}
19+
}

wit/bindgen/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2417,7 +2417,7 @@ func (g *generator) componentEmbed(witData string) ([]byte, error) {
24172417

24182418
// TODO: --all-features?
24192419
filename := "component.wit"
2420-
args := []string{"component", "embed", "--only-custom", filename}
2420+
args := []string{"component", "embed", "--only-custom", "--all-features", filename}
24212421
fsMap := map[string]fs.FS{
24222422
"": fstest.MapFS{
24232423
filename: &fstest.MapFile{Data: []byte(witData)},

0 commit comments

Comments
 (0)