@@ -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.
@@ -138,7 +139,7 @@ func (c *Config) GC() string {
138139// that can be traced by the garbage collector.
139140func (c * Config ) NeedsStackObjects () bool {
140141 switch c .GC () {
141- case "conservative" , "custom" , "precise" :
142+ case "conservative" , "custom" , "precise" , "boehm" :
142143 for _ , tag := range c .BuildTags () {
143144 if tag == "tinygo.wasm" {
144145 return true
@@ -263,6 +264,15 @@ func MuslArchitecture(triple string) string {
263264 return CanonicalArchName (triple )
264265}
265266
267+ // Returns true if the libc needs to include malloc, for the libcs where this
268+ // matters.
269+ func (c * Config ) LibcNeedsMalloc () bool {
270+ if c .GC () == "boehm" && c .Target .Libc == "wasi-libc" {
271+ return true
272+ }
273+ return false
274+ }
275+
266276// LibraryPath returns the path to the library build directory. The path will be
267277// a library path in the cache directory (which might not yet be built).
268278func (c * Config ) LibraryPath (name string ) string {
@@ -286,9 +296,14 @@ func (c *Config) LibraryPath(name string) string {
286296 archname += "-v" + strconv .Itoa (v )
287297 }
288298
299+ options := ""
300+ if c .LibcNeedsMalloc () {
301+ options += "+malloc"
302+ }
303+
289304 // No precompiled library found. Determine the path name that will be used
290305 // in the build cache.
291- return filepath .Join (goenv .Get ("GOCACHE" ), name + "-" + archname )
306+ return filepath .Join (goenv .Get ("GOCACHE" ), name + options + "-" + archname )
292307}
293308
294309// DefaultBinaryExtension returns the default extension for binaries, such as
0 commit comments