mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-31 17:59:03 +00:00
builder: add strlen to wasm builtins
LLVM 22 can replace string-scanning loops with calls to strlen during optimization. Add the implementation to wasmbuiltins and invalidate cached archives. Add an optimized wasm-unknown smoke test that exercises the reflect name-decoding path which exposed the missing symbol.
This commit is contained in:
@@ -43,11 +43,11 @@ var libWasmBuiltins = Library{
|
|||||||
sourceDir: func() string { return filepath.Join(goenv.Get("TINYGOROOT"), "lib/wasi-libc") },
|
sourceDir: func() string { return filepath.Join(goenv.Get("TINYGOROOT"), "lib/wasi-libc") },
|
||||||
librarySources: func(target string, _ bool) ([]string, error) {
|
librarySources: func(target string, _ bool) ([]string, error) {
|
||||||
return []string{
|
return []string{
|
||||||
// memory builtins needed for llvm.memcpy.*, llvm.memmove.*, and
|
// Memory builtins needed for LLVM intrinsics and library calls.
|
||||||
// llvm.memset.* LLVM intrinsics.
|
|
||||||
"libc-top-half/musl/src/string/memcpy.c",
|
"libc-top-half/musl/src/string/memcpy.c",
|
||||||
"libc-top-half/musl/src/string/memmove.c",
|
"libc-top-half/musl/src/string/memmove.c",
|
||||||
"libc-top-half/musl/src/string/memset.c",
|
"libc-top-half/musl/src/string/memset.c",
|
||||||
|
"libc-top-half/musl/src/string/strlen.c",
|
||||||
|
|
||||||
// exp, exp2, and log are needed for LLVM math builtin functions
|
// exp, exp2, and log are needed for LLVM math builtin functions
|
||||||
// like llvm.exp.*.
|
// like llvm.exp.*.
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
var libVersions = map[string]int{
|
var libVersions = map[string]int{
|
||||||
"musl": 3,
|
"musl": 3,
|
||||||
"bdwgc": 2,
|
"bdwgc": 2,
|
||||||
|
"wasmbuiltins": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config keeps all configuration affecting the build in a single struct.
|
// Config keeps all configuration affecting the build in a single struct.
|
||||||
|
|||||||
@@ -576,6 +576,7 @@ ifneq ($(WASM), 0)
|
|||||||
$(TINYGO) build -size short -o $(SMOKE_OUT).wasm -target=wasm examples/wasm/export
|
$(TINYGO) build -size short -o $(SMOKE_OUT).wasm -target=wasm examples/wasm/export
|
||||||
$(TINYGO) build -size short -o $(SMOKE_OUT).wasm -target=wasm examples/wasm/main
|
$(TINYGO) build -size short -o $(SMOKE_OUT).wasm -target=wasm examples/wasm/main
|
||||||
$(TINYGO) build -size short -o $(SMOKE_OUT).wasm -target=wasm-unknown examples/hello-wasm-unknown
|
$(TINYGO) build -size short -o $(SMOKE_OUT).wasm -target=wasm-unknown examples/hello-wasm-unknown
|
||||||
|
$(TINYGO) build -size short -o $(SMOKE_OUT).wasm -target=wasm-unknown -opt=2 ./testdata/wasm-unknown-opt
|
||||||
endif
|
endif
|
||||||
|
|
||||||
smoketest-flags: SMOKE_OUT = build/smoke/flags
|
smoketest-flags: SMOKE_OUT = build/smoke/flags
|
||||||
|
|||||||
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "reflect"
|
||||||
|
|
||||||
|
type value struct {
|
||||||
|
Field int
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:wasmexport typeNameLength
|
||||||
|
func typeNameLength() uint32 {
|
||||||
|
return uint32(len(reflect.TypeOf(value{}).String()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user