@@ -22,7 +22,8 @@ import (
2222// builder.Library struct but that's hard to do since we want to know the
2323// library path in advance in several places).
2424var libVersions = map [string ]int {
25- "musl" : 3 ,
25+ "musl" : 3 ,
26+ "bdwgc" : 2 ,
2627}
2728
2829// Config keeps all configuration affecting the build in a single struct.
@@ -133,7 +134,7 @@ func (c *Config) GC() string {
133134// that can be traced by the garbage collector.
134135func (c * Config ) NeedsStackObjects () bool {
135136 switch c .GC () {
136- case "conservative" , "custom" , "precise" :
137+ case "conservative" , "custom" , "precise" , "boehm" :
137138 for _ , tag := range c .BuildTags () {
138139 if tag == "tinygo.wasm" {
139140 return true
@@ -258,6 +259,15 @@ func MuslArchitecture(triple string) string {
258259 return CanonicalArchName (triple )
259260}
260261
262+ // Returns true if the libc needs to include malloc, for the libcs where this
263+ // matters.
264+ func (c * Config ) LibcNeedsMalloc () bool {
265+ if c .GC () == "boehm" && c .Target .Libc == "wasi-libc" {
266+ return true
267+ }
268+ return false
269+ }
270+
261271// LibraryPath returns the path to the library build directory. The path will be
262272// a library path in the cache directory (which might not yet be built).
263273func (c * Config ) LibraryPath (name string ) string {
@@ -281,9 +291,14 @@ func (c *Config) LibraryPath(name string) string {
281291 archname += "-v" + strconv .Itoa (v )
282292 }
283293
294+ options := ""
295+ if c .LibcNeedsMalloc () {
296+ options += "+malloc"
297+ }
298+
284299 // No precompiled library found. Determine the path name that will be used
285300 // in the build cache.
286- return filepath .Join (goenv .Get ("GOCACHE" ), name + "-" + archname )
301+ return filepath .Join (goenv .Get ("GOCACHE" ), name + options + "-" + archname )
287302}
288303
289304// DefaultBinaryExtension returns the default extension for binaries, such as
0 commit comments