Skip to content

Commit

Permalink
fix: support TinyGo 0.35.0 (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Dec 23, 2024
1 parent e5394e3 commit 358c617
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-sdk-go-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ jobs:
- name: Setup TinyGo
uses: acifani/setup-tinygo@v2
with:
tinygo-version: 0.33.0
tinygo-version: 0.35.0
- name: Build Program
run: ./build.sh
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## UNRELEASED

- test: add tests for AssemblyScript SDK Transform [#659](https://github.com/hypermodeinc/modus/pull/659)
- chore: lint example test [#656](https://github.com/hypermodeinc/modus/pull/656)
- fix: unused imports should not be included in metadata [#657](https://github.com/hypermodeinc/modus/pull/657)
- test: add tests for AssemblyScript SDK Transform [#659](https://github.com/hypermodeinc/modus/pull/659)
- fix: improve Go version handling [#660](https://github.com/hypermodeinc/modus/pull/660)
- fix: update runtime wasm tests [#661](https://github.com/hypermodeinc/modus/pull/661)
- fix: support TinyGo 0.35.0 [#661](https://github.com/hypermodeinc/modus/pull/662)

## 2024-12-13 - Runtime 0.15.0

Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"bedrockruntime",
"binaryen",
"buger",
"buildmode",
"cconf",
"chewxy",
"classid",
Expand Down
Binary file modified runtime/languages/golang/testdata/build/testdata.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions runtime/wasmhost/wasmhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (host *wasmHost) GetModuleInstance(ctx context.Context, plugin *plugins.Plu
jwtClaims := middleware.GetJWTClaims(ctx)
cfg := wazero.NewModuleConfig().
WithName("").
WithStartFunctions("_initialize", "_start").
WithSysWalltime().WithSysNanotime().
WithRandSource(rand.Reader).
WithStdout(wOut).WithStderr(wErr).
Expand Down
14 changes: 14 additions & 0 deletions sdk/go/tools/modus-go-build/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,24 @@ import (
const minTinyGoVersion = "0.33.0"

func Compile(config *config.Config) error {

tinygoVersion, err := getCompilerVersion(config)
if err != nil {
return err
}

args := []string{"build"}
args = append(args, "-target", "wasip1")
args = append(args, "-o", filepath.Join(config.OutputDir, config.WasmFileName))

// WASI "reactor mode" (-buildmode=c-shared) is required for TinyGo 0.35.0 and later.
// Otherwise, the _start function runs and immediately exits before any function can execute.
// This also switches the startup function to _initialize instead of _start, so the Modus runtime
// needs to match.
if tinygoVersion.GreaterThanOrEqual(version.Must(version.NewVersion("0.35.0"))) {
args = append(args, "-buildmode", "c-shared")
}

// disable the asyncify scheduler until we better understand how to use it
args = append(args, "-scheduler", "none")

Expand Down

0 comments on commit 358c617

Please sign in to comment.