Skip to content

Commit 9ddc627

Browse files
committed
darwin: support Boehm GC (and use by default)
This mostly required some updates to macos-minimal-sdk to add the needed header files and symbols.
1 parent 48f145c commit 9ddc627

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

builder/ar.go

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package builder
33
import (
44
"bytes"
55
"debug/elf"
6+
"debug/macho"
67
"debug/pe"
78
"encoding/binary"
89
"errors"
@@ -62,6 +63,20 @@ func makeArchive(arfile *os.File, objs []string) error {
6263
fileIndex int
6364
}{symbol.Name, i})
6465
}
66+
} else if dbg, err := macho.NewFile(objfile); err == nil {
67+
for _, symbol := range dbg.Symtab.Syms {
68+
// See mach-o/nlist.h
69+
if symbol.Type&0x0e != 0xe { // (symbol.Type & N_TYPE) != N_SECT
70+
continue // undefined symbol
71+
}
72+
if symbol.Type&0x01 == 0 { // (symbol.Type & N_EXT) == 0
73+
continue // internal symbol (static, etc)
74+
}
75+
symbolTable = append(symbolTable, struct {
76+
name string
77+
fileIndex int
78+
}{symbol.Name, i})
79+
}
6580
} else if dbg, err := pe.NewFile(objfile); err == nil {
6681
for _, symbol := range dbg.Symbols {
6782
if symbol.StorageClass != 2 {

builder/build.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
150150
var libcJob *compileJob
151151
switch config.Target.Libc {
152152
case "darwin-libSystem":
153-
job := makeDarwinLibSystemJob(config, tmpdir)
154-
libcDependencies = append(libcDependencies, job)
153+
libcJob = makeDarwinLibSystemJob(config, tmpdir)
154+
libcDependencies = append(libcDependencies, libcJob)
155155
case "musl":
156156
var unlock func()
157157
libcJob, unlock, err = libMusl.load(config, tmpdir, nil)

compileopts/target.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func defaultTarget(options *Options) (*TargetSpec, error) {
380380
llvmvendor := "unknown"
381381
switch options.GOOS {
382382
case "darwin":
383-
spec.GC = "precise"
383+
spec.GC = "boehm"
384384
platformVersion := "10.12.0"
385385
if options.GOARCH == "arm64" {
386386
platformVersion = "11.0.0" // first macosx platform with arm64 support

lib/macos-minimal-sdk

0 commit comments

Comments
 (0)