Commit 4284ea8
authored
reboot
* reboot `wit-bindgen-go`
This re-introduces Go support, with a new implementation written from scratch.
While the previous incarnation targeted TinyGo and reused the C generator for
lifting and lowering, this one targets "big" Go and handles lifting and lowering
itself. In addition, it supports idiomatic, goroutine-based concurrency on top
of the component model async ABI, including streams and futures.
This implementation is also distinct from the
[go-modules](https://github.com/bytecodealliance/go-modules) project, which has
a number of limitations (e.g. no async support, not safe for use with "big" Go)
and is no longer being actively maintained.
Note that the async support currently requires [a small
patch](dicej/go@a1c8322)
to the Go `runtime` library. I plan to work with the upstream project to make
that patch unecessary in the future. Components that don't use async features
should work with stock, unpatched Go.
One of the tricky parts about lowering values and passing pointers to
e.g. `{stream,future}.{read,write}` is that we must tell the Go garbage
collector to pin the pointers (i.e. mark the pointee as both immovable and
uncollectable) for as long as the host has access to them, but then unpin them
promptly afterward to avoid leaks. We do this using `runtime.Pinner` instances,
most of which are locally scoped and easy to reason about. However, we must use
a couple of globally-scoped pinners as well: one for `cabi_realloc` allocations
by the host when it lowers parameters (which we unpin after lifting those
parameters) and another for returning values from sync-lifted exports (which we
unpin in post-return functions).
There are a couple of known missing features which I'll open GitHub issues for:
1. Resource handles are not being restored for unwritten items in the case of an incomplete stream or future write.
2. Importing and/or exporting multiple versions of the same package will cause name clashes.
In addition, I plan to expand the test coverage beyond the basics covered in
this commit.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
add ping-pong Go tests
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
address review feedback
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
add wit-bindgen-go to ci/publish.rs
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
enable Go in test CI matrix
I'm assuming the default version of Go on the GitHub worker image will be
sufficient; if not, we can install a different one explicitly.
I'm not enabling the async tests for Go yet, since that will require publishing
and installing a build of Go with [this
patch](dicej/go@a1c8322);
I'll need to do some homework to find out the best way to do that.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
fix codegen tests
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
update Go runtime tests to use `run` export
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
run cargo fmt
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
remove `publish = false` from crates/go/Cargo.toml
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
temporarily skip async codegen tests for Go
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
add `async = true` config directive to `async-trait-function.wit`
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
indicate that `async-trait-function.wit-no-std` works for Rust
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
add error contexts to `Go::compile`
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
add `actions/setup-go` to workflow
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
add finalizers where appropriate; tweak `StreamReader` API
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
update workspace to 2024 edition
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* remove indirection in `wit_types.Option`
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* add crates/go/README.md
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Signed-off-by: Joel Dice <joel.dice@fermyon.com>wit-bindgen-go (#1447)1 parent f1d72d4 commit 4284ea8
File tree
97 files changed
+6301
-646
lines changed- .github/workflows
- ci
- crates
- core/src
- cpp/src
- csharp/src
- c/src
- go
- src
- guest-rust
- macro/src
- src
- rt
- async_support
- markdown/src
- moonbit/src
- rust/src
- test/src
- src/bin
- tests
- codegen
- runtime-async/async
- ping-pong
- simple-call-import
- simple-future
- simple-import-params-results
- simple-pending-import
- simple-stream-payload
- simple-stream
- runtime
- demo
- flavorful
- lists
- many-arguments
- numbers
- records
- resource-import-and-export
- resources
- results
- strings-simple
- strings
- variants
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
97 files changed
+6301
-646
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
365 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
809 | 815 | | |
810 | 816 | | |
811 | 817 | | |
| |||
1134 | 1140 | | |
1135 | 1141 | | |
1136 | 1142 | | |
1137 | | - | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1138 | 1147 | | |
1139 | 1148 | | |
1140 | 1149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
0 commit comments