add wasm-abi field in TargetSpec && set generic for WASI by default (#1421)
Signed-off-by: mathetake <takeshi@tetrate.io>
Этот коммит содержится в:
родитель
9ad2315079
коммит
9a015f4f64
7 изменённых файлов: 17 добавлений и 9 удалений
|
@ -79,7 +79,7 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
|
||||||
// keep functions interoperable, pass int64 types as pointers to
|
// keep functions interoperable, pass int64 types as pointers to
|
||||||
// stack-allocated values.
|
// stack-allocated values.
|
||||||
// Use -wasm-abi=generic to disable this behaviour.
|
// 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)
|
err := transform.ExternalInt64AsPtr(mod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -329,6 +329,15 @@ func (c *Config) RelocationModel() string {
|
||||||
return "static"
|
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 {
|
type TestConfig struct {
|
||||||
CompileTestBinary bool
|
CompileTestBinary bool
|
||||||
// TODO: Filter the test functions to run, include verbose flag, etc
|
// TODO: Filter the test functions to run, include verbose flag, etc
|
||||||
|
|
|
@ -55,6 +55,7 @@ type TargetSpec struct {
|
||||||
JLinkDevice string `json:"jlink-device"`
|
JLinkDevice string `json:"jlink-device"`
|
||||||
CodeModel string `json:"code-model"`
|
CodeModel string `json:"code-model"`
|
||||||
RelocationModel string `json:"relocation-model"`
|
RelocationModel string `json:"relocation-model"`
|
||||||
|
WasmAbi string `json:"wasm-abi"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// overrideProperties overrides all properties that are set in child into itself using reflection.
|
// overrideProperties overrides all properties that are set in child into itself using reflection.
|
||||||
|
|
2
main.go
2
main.go
|
@ -828,7 +828,7 @@ func main() {
|
||||||
programmer := flag.String("programmer", "", "which hardware programmer to use")
|
programmer := flag.String("programmer", "", "which hardware programmer to use")
|
||||||
cFlags := flag.String("cflags", "", "additional cflags for compiler")
|
cFlags := flag.String("cflags", "", "additional cflags for compiler")
|
||||||
ldFlags := flag.String("ldflags", "", "additional ldflags for linker")
|
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)")
|
heapSize := flag.String("heap-size", "1M", "default heap size in bytes (only supported by WebAssembly)")
|
||||||
|
|
||||||
var flagJSON, flagDeps *bool
|
var flagJSON, flagDeps *bool
|
||||||
|
|
|
@ -165,11 +165,7 @@ func runTest(path, target string, t *testing.T) {
|
||||||
VerifyIR: true,
|
VerifyIR: true,
|
||||||
Debug: true,
|
Debug: true,
|
||||||
PrintSizes: "",
|
PrintSizes: "",
|
||||||
WasmAbi: "js",
|
WasmAbi: "",
|
||||||
}
|
|
||||||
|
|
||||||
if target == "wasi" {
|
|
||||||
config.WasmAbi = "generic"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binary := filepath.Join(tmpdir, "test")
|
binary := filepath.Join(tmpdir, "test")
|
||||||
|
|
|
@ -18,5 +18,6 @@
|
||||||
"--no-demangle",
|
"--no-demangle",
|
||||||
"{root}/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a"
|
"{root}/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a"
|
||||||
],
|
],
|
||||||
"emulator": ["wasmtime"]
|
"emulator": ["wasmtime"],
|
||||||
|
"wasm-abi": "generic"
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,6 @@
|
||||||
"--no-demangle",
|
"--no-demangle",
|
||||||
"{root}/lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a"
|
"{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"
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче