Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
// keep functions interoperable, pass int64 types as pointers to
// stack-allocated values.
// Use -wasm-abi=generic to disable this behaviour.
if config.Options.WasmAbi == "js" && strings.HasPrefix(config.Triple(), "wasm") {
if config.WasmAbi() == "js" {
err := transform.ExternalInt64AsPtr(mod)
if err != nil {
return err
Expand Down
9 changes: 9 additions & 0 deletions compileopts/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@ func (c *Config) RelocationModel() string {
return "static"
}

// WasmAbi returns the WASM ABI which is specified in the target JSON file, and
// the value is overridden by `-wasm-abi` flag if it is provided
func (c *Config) WasmAbi() string {
if c.Options.WasmAbi != "" {
return c.Options.WasmAbi
}
return c.Target.WasmAbi
}

type TestConfig struct {
CompileTestBinary bool
// TODO: Filter the test functions to run, include verbose flag, etc
Expand Down
1 change: 1 addition & 0 deletions compileopts/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type TargetSpec struct {
JLinkDevice string `json:"jlink-device"`
CodeModel string `json:"code-model"`
RelocationModel string `json:"relocation-model"`
WasmAbi string `json:"wasm-abi"`
}

// overrideProperties overrides all properties that are set in child into itself using reflection.
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ func main() {
programmer := flag.String("programmer", "", "which hardware programmer to use")
cFlags := flag.String("cflags", "", "additional cflags for compiler")
ldFlags := flag.String("ldflags", "", "additional ldflags for linker")
wasmAbi := flag.String("wasm-abi", "js", "WebAssembly ABI conventions: js (no i64 params) or generic")
wasmAbi := flag.String("wasm-abi", "", "WebAssembly ABI conventions: js (no i64 params) or generic")
heapSize := flag.String("heap-size", "1M", "default heap size in bytes (only supported by WebAssembly)")

var flagJSON, flagDeps *bool
Expand Down
6 changes: 1 addition & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ func runTest(path, target string, t *testing.T) {
VerifyIR: true,
Debug: true,
PrintSizes: "",
WasmAbi: "js",
}

if target == "wasi" {
config.WasmAbi = "generic"
WasmAbi: "",
}

binary := filepath.Join(tmpdir, "test")
Expand Down
3 changes: 2 additions & 1 deletion targets/wasi.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"--no-demangle",
"{root}/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a"
],
"emulator": ["wasmtime"]
"emulator": ["wasmtime"],
"wasm-abi": "generic"
}
3 changes: 2 additions & 1 deletion targets/wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"--no-demangle",
"{root}/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a"
],
"emulator": ["node", "targets/wasm_exec.js"]
"emulator": ["node", "targets/wasm_exec.js"],
"wasm-abi": "js"
}