8000 darwin: support Boehm GC (and use by default) by aykevl · Pull Request #4826 · tinygo-org/tinygo · GitHub
[go: up one dir, main page]

Skip to content

darwin: support Boehm GC (and use by default) #4826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
8000 Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
aykevl committed Mar 25, 2025
commit 6c5d50775b6fc4fad99bd19562f034286761151a
15 changes: 15 additions & 0 deletions builder/ar.go
8000
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package builder
import (
"bytes"
"debug/elf"
"debug/macho"
"debug/pe"
"encoding/binary"
"errors"
Expand Down Expand Up @@ -62,6 +63,20 @@ func makeArchive(arfile *os.File, objs []string) error {
fileIndex int
}{symbol.Name, i})
}
} else if dbg, err := macho.NewFile(objfile); err == nil {
for _, symbol := range dbg.Symtab.Syms {
// See mach-o/nlist.h
if symbol.Type&0x0e != 0xe { // (symbol.Type & N_TYPE) != N_SECT
continue // undefined symbol
}
if symbol.Type&0x01 == 0 { // (symbol.Type & N_EXT) == 0
continue // internal symbol (static, etc)
}
symbolTable = append(symbolTable, struct {
name string
fileIndex int
}{symbol.Name, i})
}
} else if dbg, err := pe.NewFile(objfile); err == nil {
for _, symbol := range dbg.Symbols {
if symbol.StorageClass != 2 {
Expand Down
3 changes: 1 addition & 2 deletions builder/bdwgc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var BoehmGC = Library{
"-DALL_INTERIOR_POINTERS", // scan interior pointers (needed for Go)
"-DIGNORE_DYNAMIC_LOADING", // we don't support dynamic loading at the moment
"-DNO_GETCONTEXT", // musl doesn't support getcontext()
"-DGC_DISABLE_INCREMENTAL", // don't mess with SIGSEGV and such

// Use a minimal environment.
"-DNO_MSGBOX_ON_ERROR", // don't call MessageBoxA on Windows
Expand Down Expand Up @@ -68,8 +69,6 @@ var BoehmGC = Library{
"new_hblk.c",
"obj_map.c",
"os_dep.c",
"pthread_stop_world.c",
"pthread_support.c",
"reclaim.c",
}
if strings.Split(target, "-")[2] == "windows" {
Expand Down
4 changes: 2 additions & 2 deletions builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
var libcJob *compileJob
switch config.Target.Libc {
case "darwin-libSystem":
job := makeDarwinLibSystemJob(config, tmpdir)
libcDependencies = append(libcDependencies, job)
libcJob = makeDarwinLibSystemJob(config, tmpdir)
libcDependencies = append(libcDependencies, libcJob)
case "musl":
var unlock func()
libcJob, unlock, err = libMusl.load(config, tmpdir, nil)
Expand Down
2 changes: 1 addition & 1 deletion compileopts/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func defaultTarget(options *Options) (*TargetSpec, error) {
llvmvendor := "unknown"
switch options.GOOS {
case "darwin":
spec.GC = "precise"
spec.GC = "boehm"
platformVersion := "10.12.0"
if options.GOARCH == "arm64" {
platformVersion = "11.0.0" // first macosx platform with arm64 support
Expand Down
2 changes: 1 addition & 1 deletion lib/macos-minimal-sdk
0