Skip to content

Commit 174d492

Browse files
authored
compileopts, targets, main: support Wasmtime v14 (#3972)
compileopts, targets, main: support Wasmtime v14
1 parent 5355473 commit 174d492

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

.github/workflows/linux.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ jobs:
140140
- name: Install wasmtime
141141
run: |
142142
mkdir -p $HOME/.wasmtime $HOME/.wasmtime/bin
143-
curl https://github.com/bytecodealliance/wasmtime/releases/download/v13.0.0/wasmtime-v13.0.0-x86_64-linux.tar.xz -o wasmtime-v13.0.0-x86_64-linux.tar.xz -SfL
144-
tar -C $HOME/.wasmtime/bin --wildcards -xf wasmtime-v13.0.0-x86_64-linux.tar.xz --strip-components=1 wasmtime-v13.0.0-x86_64-linux/*
143+
curl https://github.com/bytecodealliance/wasmtime/releases/download/v14.0.4/wasmtime-v14.0.4-x86_64-linux.tar.xz -o wasmtime-v14.0.4-x86_64-linux.tar.xz -SfL
144+
tar -C $HOME/.wasmtime/bin --wildcards -xf wasmtime-v14.0.4-x86_64-linux.tar.xz --strip-components=1 wasmtime-v14.0.4-x86_64-linux/*
145145
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
146146
- name: Download release artifact
147147
uses: actions/download-artifact@v3
@@ -187,8 +187,8 @@ jobs:
187187
- name: Install wasmtime
188188
run: |
189189
mkdir -p $HOME/.wasmtime $HOME/.wasmtime/bin
190-
curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v13.0.0/wasmtime-v13.0.0-x86_64-linux.tar.xz -o wasmtime-v13.0.0-x86_64-linux.tar.xz -SfL
191-
tar -C $HOME/.wasmtime/bin --wildcards -xf wasmtime-v13.0.0-x86_64-linux.tar.xz --strip-components=1 wasmtime-v13.0.0-x86_64-linux/*
190+
curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v14.0.4/wasmtime-v14.0.4-x86_64-linux.tar.xz -o wasmtime-v14.0.4-x86_64-linux.tar.xz -SfL
191+
tar -C $HOME/.wasmtime/bin --wildcards -xf wasmtime-v14.0.4-x86_64-linux.tar.xz --strip-components=1 wasmtime-v14.0.4-x86_64-linux/*
192192
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
193193
- name: Restore LLVM source cache
194194
uses: actions/cache/restore@v3

.github/workflows/windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
run: make wasi-libc
9797
- name: Install wasmtime
9898
run: |
99-
scoop install wasmtime@13.0.0
99+
scoop install wasmtime@14.0.4
100100
- name: make gen-device
101101
run: make -j3 gen-device
102102
- name: Test TinyGo
@@ -203,7 +203,7 @@ jobs:
203203
- name: Install Dependencies
204204
shell: bash
205205
run: |
206-
scoop install binaryen && scoop install wasmtime@13.0.0
206+
scoop install binaryen && scoop install wasmtime@14.0.4
207207
- name: Checkout
208208
uses: actions/checkout@v3
209209
- name: Install Go

compileopts/target.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
386386
"--stack-first",
387387
"--no-demangle",
388388
)
389-
spec.Emulator = "wasmtime --mapdir=/tmp::{tmpDir} {}"
389+
spec.Emulator = "wasmtime --dir={tmpDir}::/tmp {}"
390390
spec.ExtraFiles = append(spec.ExtraFiles,
391391
"src/runtime/asm_tinygowasm.S",
392392
"src/internal/task/task_asyncify_wasm.S",

main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c
797797
needsEnvInVars = true
798798
}
799799
}
800-
var args, env []string
800+
var args, emuArgs, env []string
801801
var extraCmdEnv []string
802802
if needsEnvInVars {
803803
runtimeGlobals := make(map[string]string)
@@ -820,13 +820,14 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c
820820
} else if config.EmulatorName() == "wasmtime" {
821821
// Wasmtime needs some special flags to pass environment variables
822822
// and allow reading from the current directory.
823-
args = append(args, "--dir=.")
823+
emuArgs = append(emuArgs, "--dir=.")
824824
for _, v := range environmentVars {
825-
args = append(args, "--env", v)
825+
emuArgs = append(emuArgs, "--env", v)
826826
}
827827
if len(cmdArgs) != 0 {
828-
// mark end of wasmtime arguments and start of program ones: --
829-
args = append(args, "--")
828+
// Use of '--' argument no longer necessary as of Wasmtime v14:
829+
// https://github.com/bytecodealliance/wasmtime/pull/6946
830+
// args = append(args, "--")
830831
args = append(args, cmdArgs...)
831832
}
832833

@@ -876,7 +877,7 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c
876877
return result, err
877878
}
878879
name = emulator[0]
879-
emuArgs := append([]string(nil), emulator[1:]...)
880+
emuArgs = append(emuArgs, emulator[1:]...)
880881
args = append(emuArgs, args...)
881882
}
882883
var cmd *exec.Cmd

targets/wasi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
"extra-files": [
2323
"src/runtime/asm_tinygowasm.S"
2424
],
25-
"emulator": "wasmtime --mapdir=/tmp::{tmpDir} {}"
25+
"emulator": "wasmtime --dir={tmpDir}::/tmp {}"
2626
}

0 commit comments

Comments
 (0)