Skip to content

Commit 65258fc

Browse files
committed
WIP wasip1: add Boehm GC support
1 parent 8fcbbc1 commit 65258fc

File tree

9 files changed

+12
-10
lines changed

9 files changed

+12
-10
lines changed

GNUmakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ endif
264264
wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
265265
lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a:
266266
@if [ ! -e lib/wasi-libc/Makefile ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
267-
cd lib/wasi-libc && $(MAKE) -j4 EXTRA_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" MALLOC_IMPL=none CC="$(CLANG)" AR=$(LLVM_AR) NM=$(LLVM_NM)
267+
cd lib/wasi-libc && $(MAKE) -j4 EXTRA_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" CC="$(CLANG)" AR=$(LLVM_AR) NM=$(LLVM_NM)
268268

269269
# Generate WASI syscall bindings
270270
WASM_TOOLS_MODULE=github.com/bytecodealliance/wasm-tools-go

builder/build.go

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
169169
defer unlock()
170170
libcDependencies = append(libcDependencies, libcJob)
171171
case "wasi-libc":
172+
libcJob = dummyCompileJob("")
172173
path := filepath.Join(root, "lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a")
173174
if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {
174175
return BuildResult{}, errors.New("could not find wasi-libc, perhaps you need to run `make wasi-libc`?")

compileopts/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (c *Config) GC() string {
122122
// that can be traced by the garbage collector.
123123
func (c *Config) NeedsStackObjects() bool {
124124
switch c.GC() {
125-
case "conservative", "custom", "precise":
125+
case "conservative", "custom", "precise", "boehm":
126126
for _, tag := range c.BuildTags() {
127127
if tag == "tinygo.wasm" {
128128
return true

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/tinygo-org/tinygo
33
go 1.19
44

55
require (
6-
github.com/aykevl/go-wasm v0.0.2-0.20240825160117-b76c3f9f0982
6+
github.com/aykevl/go-wasm v0.0.2-0.20250317121156-42b86c494139
77
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2
88
github.com/chromedp/cdproto v0.0.0-20220113222801-0725d94bb6ee
99
github.com/chromedp/chromedp v0.7.6

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/aykevl/go-wasm v0.0.2-0.20240825160117-b76c3f9f0982 h1:cD7QfvrJdYmBw2tFP/VyKPT8ZESlcrwSwo7SvH9Y4dc=
2-
github.com/aykevl/go-wasm v0.0.2-0.20240825160117-b76c3f9f0982/go.mod h1:7sXyiaA0WtSogCu67R2252fQpVmJMh9JWJ9ddtGkpWw=
1+
github.com/aykevl/go-wasm v0.0.2-0.20250317121156-42b86c494139 h1:2O/WuAt8J5id3khcAtVB90czG80m+v0sfkLE07GrCVg=
2+
github.com/aykevl/go-wasm v0.0.2-0.20250317121156-42b86c494139/go.mod h1:7sXyiaA0WtSogCu67R2252fQpVmJMh9JWJ9ddtGkpWw=
33
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2 h1:oMCHnXa6CCCafdPDbMh/lWRhRByN0VFLvv+g+ayx1SI=
44
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
55
github.com/chromedp/cdproto v0.0.0-20211126220118-81fa0469ad77/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U=

lib/bdwgc

Submodule bdwgc updated 214 files

src/runtime/arch_tinygowasm_malloc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build tinygo.wasm && !(custommalloc || wasm_unknown)
1+
//go:build tinygo.wasm && !(custommalloc || wasm_unknown || gc.boehm)
22

33
package runtime
44

src/runtime/gc_stack_portable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build (gc.conservative || gc.custom || gc.precise) && tinygo.wasm
1+
//go:build (gc.conservative || gc.custom || gc.precise || gc.boehm) && tinygo.wasm
22

33
package runtime
44

targets/wasip1.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"linker": "wasm-ld",
99
"libc": "wasi-libc",
1010
"rtlib": "compiler-rt",
11-
"gc": "precise",
11+
"gc": "boehm",
1212
"scheduler": "asyncify",
1313
"default-stack-size": 65536,
1414
"cflags": [
@@ -23,7 +23,8 @@
2323
"--no-demangle"
2424
],
2525
"extra-files": [
26-
"src/runtime/asm_tinygowasm.S"
26+
"src/runtime/asm_tinygowasm.S",
27+
"src/runtime/gc_boehm.c"
2728
],
2829
"emulator": "wasmtime run --dir={tmpDir}::/tmp {}"
2930
}

0 commit comments

Comments
 (0)