mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-14 16:03:41 +00:00
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.
This commit is contained in:
committed by
Ron Evans
parent
c1c074f170
commit
95a7d065ca
@@ -3,6 +3,7 @@ package builder
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"debug/elf"
|
"debug/elf"
|
||||||
|
"debug/macho"
|
||||||
"debug/pe"
|
"debug/pe"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -62,6 +63,20 @@ func makeArchive(arfile *os.File, objs []string) error {
|
|||||||
fileIndex int
|
fileIndex int
|
||||||
}{symbol.Name, i})
|
}{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 {
|
} else if dbg, err := pe.NewFile(objfile); err == nil {
|
||||||
for _, symbol := range dbg.Symbols {
|
for _, symbol := range dbg.Symbols {
|
||||||
if symbol.StorageClass != 2 {
|
if symbol.StorageClass != 2 {
|
||||||
|
|||||||
+1
-2
@@ -25,6 +25,7 @@ var BoehmGC = Library{
|
|||||||
"-DALL_INTERIOR_POINTERS", // scan interior pointers (needed for Go)
|
"-DALL_INTERIOR_POINTERS", // scan interior pointers (needed for Go)
|
||||||
"-DIGNORE_DYNAMIC_LOADING", // we don't support dynamic loading at the moment
|
"-DIGNORE_DYNAMIC_LOADING", // we don't support dynamic loading at the moment
|
||||||
"-DNO_GETCONTEXT", // musl doesn't support getcontext()
|
"-DNO_GETCONTEXT", // musl doesn't support getcontext()
|
||||||
|
"-DGC_DISABLE_INCREMENTAL", // don't mess with SIGSEGV and such
|
||||||
|
|
||||||
// Use a minimal environment.
|
// Use a minimal environment.
|
||||||
"-DNO_MSGBOX_ON_ERROR", // don't call MessageBoxA on Windows
|
"-DNO_MSGBOX_ON_ERROR", // don't call MessageBoxA on Windows
|
||||||
@@ -68,8 +69,6 @@ var BoehmGC = Library{
|
|||||||
"new_hblk.c",
|
"new_hblk.c",
|
||||||
"obj_map.c",
|
"obj_map.c",
|
||||||
"os_dep.c",
|
"os_dep.c",
|
||||||
"pthread_stop_world.c",
|
|
||||||
"pthread_support.c",
|
|
||||||
"reclaim.c",
|
"reclaim.c",
|
||||||
}
|
}
|
||||||
if strings.Split(target, "-")[2] == "windows" {
|
if strings.Split(target, "-")[2] == "windows" {
|
||||||
|
|||||||
+2
-2
@@ -150,8 +150,8 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
var libcJob *compileJob
|
var libcJob *compileJob
|
||||||
switch config.Target.Libc {
|
switch config.Target.Libc {
|
||||||
case "darwin-libSystem":
|
case "darwin-libSystem":
|
||||||
job := makeDarwinLibSystemJob(config, tmpdir)
|
libcJob = makeDarwinLibSystemJob(config, tmpdir)
|
||||||
libcDependencies = append(libcDependencies, job)
|
libcDependencies = append(libcDependencies, libcJob)
|
||||||
case "musl":
|
case "musl":
|
||||||
var unlock func()
|
var unlock func()
|
||||||
libcJob, unlock, err = libMusl.load(config, tmpdir, nil)
|
libcJob, unlock, err = libMusl.load(config, tmpdir, nil)
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ func defaultTarget(options *Options) (*TargetSpec, error) {
|
|||||||
llvmvendor := "unknown"
|
llvmvendor := "unknown"
|
||||||
switch options.GOOS {
|
switch options.GOOS {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
spec.GC = "precise"
|
spec.GC = "boehm"
|
||||||
platformVersion := "10.12.0"
|
platformVersion := "10.12.0"
|
||||||
if options.GOARCH == "arm64" {
|
if options.GOARCH == "arm64" {
|
||||||
platformVersion = "11.0.0" // first macosx platform with arm64 support
|
platformVersion = "11.0.0" // first macosx platform with arm64 support
|
||||||
|
|||||||
+1
-1
Submodule lib/macos-minimal-sdk updated: 9b69407cb5...e7c72156ea
Reference in New Issue
Block a user