Skip to content

Commit 922fd01

Browse files
authored
Merge pull request #15 from faddat/codex/update-readme-and-ci-for-cgo-and-wazero
Document wazero build option
2 parents 59915e2 + 4541581 commit 922fd01

3 files changed

Lines changed: 43 additions & 9 deletions

File tree

.github/workflows/go.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Go Build and Test
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
77
workflow_dispatch:
88

@@ -14,7 +14,7 @@ jobs:
1414

1515
- uses: actions/setup-go@v5
1616
with:
17-
go-version: '1.24'
17+
go-version: "1.24"
1818
cache: false
1919

2020
- name: Check go mod tidy
@@ -28,5 +28,8 @@ jobs:
2828
- name: Go integration tests
2929
run: make test
3030

31+
- name: Go wazero tests
32+
run: go test -tags wazero ./...
33+
3134
- name: Go safety tests
3235
run: make test-safety

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ applications, in particular from
77
[x/wasm](https://github.com/CosmWasm/wasmd/tree/master/x/wasm).
88

99
More information on what is CosmWasm and how to use it can be found here:
10-
[CosmWasm Docs](https://docs.cosmwasm.com). To generate and show
11-
the Rust part documentation you can run `make doc-rust`.
10+
[CosmWasm Docs](https://docs.cosmwasm.com). To generate and show the Rust part
11+
documentation you can run `make doc-rust`.
1212

1313
## Structure
1414

@@ -80,8 +80,9 @@ CGO_ENABLED=0 go build ./types
8080

8181
This package contains the code binding the libwasmvm build to the Go code. All
8282
low level FFI handling code belongs there. This package can only be built using
83-
cgo. Using the `internal/` convention makes this package fully private.
84-
For an overview of the exported C functions and their Go wrappers see [docs/CGO_INTERFACE.md](docs/CGO_INTERFACE.md).
83+
cgo. Using the `internal/` convention makes this package fully private. For an
84+
overview of the exported C functions and their Go wrappers see
85+
[docs/CGO_INTERFACE.md](docs/CGO_INTERFACE.md).
8586

8687
#### Package github.com/CosmWasm/wasmvm
8788

@@ -103,6 +104,17 @@ linking disabled an additional build tag is available.
103104
go build -tags "nolink_libwasmvm"
104105
```
105106

107+
You can also build using the experimental
108+
[wazero](https://github.com/tetratelabs/wazero) runtime which removes the need
109+
for CGO:
110+
111+
```sh
112+
CGO_ENABLED=0 go build -tags wazero .
113+
```
114+
115+
Once wazero has feature parity with the Rust implementation, the Rust dependency
116+
will be removed.
117+
106118
## Supported Platforms
107119

108120
See [COMPILER_VERSIONS.md](docs/COMPILER_VERSIONS.md) for information on Go and
@@ -153,9 +165,9 @@ which for example excludes all 32 bit systems.
153165

154166
## Development
155167

156-
There are two halves to this code - go and rust. The first step is to ensure that
157-
there is a proper dll built for your platform. This should be `api/libwasmvm.X`,
158-
where X is:
168+
There are two halves to this code - go and rust. The first step is to ensure
169+
that there is a proper dll built for your platform. This should be
170+
`api/libwasmvm.X`, where X is:
159171

160172
- `so` for Linux systems
161173
- `dylib` for MacOS

docs/MIGRATING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,22 @@ where the old name was deprecated.
7272
| `VoteMsg.Vote` | `VoteMsg.Option` | Brings consistency with Cosmos SDK naming |
7373

7474
[ft]: https://stackoverflow.com/a/60073310
75+
76+
## Building with or without CGO
77+
78+
The default build links against the Rust based `libwasmvm` and therefore
79+
requires CGO:
80+
81+
```sh
82+
go build ./...
83+
```
84+
85+
If you want a pure Go build without the Rust dependency, disable CGO and enable
86+
the `wazero` build tag:
87+
88+
```sh
89+
CGO_ENABLED=0 go build -tags wazero ./...
90+
```
91+
92+
Once wazero provides all features of the Rust implementation, the Rust
93+
dependency will be removed.

0 commit comments

Comments
 (0)