@@ -22,7 +22,8 @@ import (
22
22
// builder.Library struct but that's hard to do since we want to know the
23
23
// library path in advance in several places).
24
24
var libVersions = map [string ]int {
25
- "musl" : 3 ,
25
+ "musl" : 3 ,
26
+ "bdwgc" : 2 ,
26
27
}
27
28
28
29
// Config keeps all configuration affecting the build in a single struct.
@@ -138,7 +139,7 @@ func (c *Config) GC() string {
138
139
// that can be traced by the garbage collector.
139
140
func (c * Config ) NeedsStackObjects () bool {
140
141
switch c .GC () {
141
- case "conservative" , "custom" , "precise" :
142
+ case "conservative" , "custom" , "precise" , "boehm" :
142
143
for _ , tag := range c .BuildTags () {
143
144
if tag == "tinygo.wasm" {
144
145
return true
@@ -263,6 +264,15 @@ func MuslArchitecture(triple string) string {
263
264
return CanonicalArchName (triple )
264
265
}
265
266
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
+
266
276
// LibraryPath returns the path to the library build directory. The path will be
267
277
// a library path in the cache directory (which might not yet be built).
268
278
func (c * Config ) LibraryPath (name string ) string {
@@ -286,9 +296,14 @@ func (c *Config) LibraryPath(name string) string {
286
296
archname += "-v" + strconv .Itoa (v )
287
297
}
288
298
299
+ options := ""
300
+ if c .LibcNeedsMalloc () {
301
+ options += "+malloc"
302
+ }
303
+
289
304
// No precompiled library found. Determine the path name that will be used
290
305
// in the build cache.
291
- return filepath .Join (goenv .Get ("GOCACHE" ), name + "-" + archname )
306
+ return filepath .Join (goenv .Get ("GOCACHE" ), name + options + "-" + archname )
292
307
}
293
308
294
309
// DefaultBinaryExtension returns the default extension for binaries, such as
0 commit comments