mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-22 13:29:01 +00:00
windows: add support for the Boehm-Demers-Weiser GC
A few small changes were needed to make this work. In particular, I found a critical bug (see the previous commit) that needed to be fixed to make this work on Windows.
This commit is contained in:
committed by
Ron Evans
parent
fd3976b5bb
commit
b9bf0aa0da
@@ -1007,6 +1007,7 @@ endif
|
|||||||
@cp -rp lib/mingw-w64/mingw-w64-crt/stdio/ucrt_* build/release/tinygo/lib/mingw-w64/mingw-w64-crt/stdio
|
@cp -rp lib/mingw-w64/mingw-w64-crt/stdio/ucrt_* build/release/tinygo/lib/mingw-w64/mingw-w64-crt/stdio
|
||||||
@cp -rp lib/mingw-w64/mingw-w64-headers/crt/ build/release/tinygo/lib/mingw-w64/mingw-w64-headers
|
@cp -rp lib/mingw-w64/mingw-w64-headers/crt/ build/release/tinygo/lib/mingw-w64/mingw-w64-headers
|
||||||
@cp -rp lib/mingw-w64/mingw-w64-headers/defaults/include build/release/tinygo/lib/mingw-w64/mingw-w64-headers/defaults
|
@cp -rp lib/mingw-w64/mingw-w64-headers/defaults/include build/release/tinygo/lib/mingw-w64/mingw-w64-headers/defaults
|
||||||
|
@cp -rp lib/mingw-w64/mingw-w64-headers/include build/release/tinygo/lib/mingw-w64/mingw-w64-headers
|
||||||
@cp -rp lib/nrfx/* build/release/tinygo/lib/nrfx
|
@cp -rp lib/nrfx/* build/release/tinygo/lib/nrfx
|
||||||
@cp -rp lib/picolibc/newlib/libc/ctype build/release/tinygo/lib/picolibc/newlib/libc
|
@cp -rp lib/picolibc/newlib/libc/ctype build/release/tinygo/lib/picolibc/newlib/libc
|
||||||
@cp -rp lib/picolibc/newlib/libc/include build/release/tinygo/lib/picolibc/newlib/libc
|
@cp -rp lib/picolibc/newlib/libc/include build/release/tinygo/lib/picolibc/newlib/libc
|
||||||
|
|||||||
+16
-2
@@ -5,6 +5,7 @@ package builder
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/tinygo-org/tinygo/goenv"
|
"github.com/tinygo-org/tinygo/goenv"
|
||||||
)
|
)
|
||||||
@@ -25,6 +26,10 @@ var BoehmGC = Library{
|
|||||||
"-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()
|
||||||
|
|
||||||
|
// Use a minimal environment.
|
||||||
|
"-DNO_MSGBOX_ON_ERROR", // don't call MessageBoxA on Windows
|
||||||
|
"-DDONT_USE_ATEXIT",
|
||||||
|
|
||||||
// Special flag to work around the lack of __data_start in ld.lld.
|
// Special flag to work around the lack of __data_start in ld.lld.
|
||||||
// TODO: try to fix this in LLVM/lld directly so we don't have to
|
// TODO: try to fix this in LLVM/lld directly so we don't have to
|
||||||
// work around it anymore.
|
// work around it anymore.
|
||||||
@@ -47,7 +52,7 @@ var BoehmGC = Library{
|
|||||||
return filepath.Join(goenv.Get("TINYGOROOT"), "lib/bdwgc")
|
return filepath.Join(goenv.Get("TINYGOROOT"), "lib/bdwgc")
|
||||||
},
|
},
|
||||||
librarySources: func(target string) ([]string, error) {
|
librarySources: func(target string) ([]string, error) {
|
||||||
return []string{
|
sources := []string{
|
||||||
"allchblk.c",
|
"allchblk.c",
|
||||||
"alloc.c",
|
"alloc.c",
|
||||||
"blacklst.c",
|
"blacklst.c",
|
||||||
@@ -66,6 +71,15 @@ var BoehmGC = Library{
|
|||||||
"pthread_stop_world.c",
|
"pthread_stop_world.c",
|
||||||
"pthread_support.c",
|
"pthread_support.c",
|
||||||
"reclaim.c",
|
"reclaim.c",
|
||||||
}, nil
|
}
|
||||||
|
if strings.Split(target, "-")[2] == "windows" {
|
||||||
|
// Due to how the linker on Windows works (that doesn't allow
|
||||||
|
// undefined functions), we need to include these extra files.
|
||||||
|
sources = append(sources,
|
||||||
|
"mallocx.c",
|
||||||
|
"ptr_chck.c",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return sources, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -182,12 +182,13 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
defer unlock()
|
defer unlock()
|
||||||
libcDependencies = append(libcDependencies, libcJob)
|
libcDependencies = append(libcDependencies, libcJob)
|
||||||
case "mingw-w64":
|
case "mingw-w64":
|
||||||
job, unlock, err := libMinGW.load(config, tmpdir, nil)
|
var unlock func()
|
||||||
|
libcJob, unlock, err = libMinGW.load(config, tmpdir, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return BuildResult{}, err
|
return BuildResult{}, err
|
||||||
}
|
}
|
||||||
defer unlock()
|
defer unlock()
|
||||||
libcDependencies = append(libcDependencies, job)
|
libcDependencies = append(libcDependencies, libcJob)
|
||||||
libcDependencies = append(libcDependencies, makeMinGWExtraLibs(tmpdir, config.GOARCH())...)
|
libcDependencies = append(libcDependencies, makeMinGWExtraLibs(tmpdir, config.GOARCH())...)
|
||||||
case "":
|
case "":
|
||||||
// no library specified, so nothing to do
|
// no library specified, so nothing to do
|
||||||
|
|||||||
@@ -395,8 +395,10 @@ func (c *Config) LibcCFlags() []string {
|
|||||||
"-nostdlibinc",
|
"-nostdlibinc",
|
||||||
"-isystem", filepath.Join(path, "include"),
|
"-isystem", filepath.Join(path, "include"),
|
||||||
"-isystem", filepath.Join(root, "lib", "mingw-w64", "mingw-w64-headers", "crt"),
|
"-isystem", filepath.Join(root, "lib", "mingw-w64", "mingw-w64-headers", "crt"),
|
||||||
|
"-isystem", filepath.Join(root, "lib", "mingw-w64", "mingw-w64-headers", "include"),
|
||||||
"-isystem", filepath.Join(root, "lib", "mingw-w64", "mingw-w64-headers", "defaults", "include"),
|
"-isystem", filepath.Join(root, "lib", "mingw-w64", "mingw-w64-headers", "defaults", "include"),
|
||||||
"-D_UCRT",
|
"-D_UCRT",
|
||||||
|
"-D_WIN32_WINNT=0x0a00", // target Windows 10
|
||||||
}
|
}
|
||||||
case "":
|
case "":
|
||||||
// No libc specified, nothing to add.
|
// No libc specified, nothing to add.
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ func defaultTarget(options *Options) (*TargetSpec, error) {
|
|||||||
"src/runtime/runtime_unix.c",
|
"src/runtime/runtime_unix.c",
|
||||||
"src/runtime/signal.c")
|
"src/runtime/signal.c")
|
||||||
case "windows":
|
case "windows":
|
||||||
spec.GC = "precise"
|
spec.GC = "boehm"
|
||||||
spec.Linker = "ld.lld"
|
spec.Linker = "ld.lld"
|
||||||
spec.Libc = "mingw-w64"
|
spec.Libc = "mingw-w64"
|
||||||
// Note: using a medium code model, low image base and no ASLR
|
// Note: using a medium code model, low image base and no ASLR
|
||||||
|
|||||||
Reference in New Issue
Block a user