darwin: add support for arm64 GOARCH (aka Apple Silicon)
This patch adds support for generating GOOS=darwin GOARCH=arm64 binaries. This means that it will become possible to run `go test` on recent Macs, for example.
Этот коммит содержится в:
родитель
af6bbaf532
коммит
7a5d4c9537
3 изменённых файлов: 27 добавлений и 0 удалений
1
Makefile
1
Makefile
|
@ -635,6 +635,7 @@ endif
|
||||||
GOOS=linux GOARCH=arm $(TINYGO) build -size short -o test.elf ./testdata/cgo
|
GOOS=linux GOARCH=arm $(TINYGO) build -size short -o test.elf ./testdata/cgo
|
||||||
GOOS=windows GOARCH=amd64 $(TINYGO) build -size short -o test.exe ./testdata/cgo
|
GOOS=windows GOARCH=amd64 $(TINYGO) build -size short -o test.exe ./testdata/cgo
|
||||||
GOOS=darwin GOARCH=amd64 $(TINYGO) build -o test ./testdata/cgo
|
GOOS=darwin GOARCH=amd64 $(TINYGO) build -o test ./testdata/cgo
|
||||||
|
GOOS=darwin GOARCH=arm64 $(TINYGO) build -o test ./testdata/cgo
|
||||||
ifneq ($(OS),Windows_NT)
|
ifneq ($(OS),Windows_NT)
|
||||||
# TODO: this does not yet work on Windows. Somehow, unused functions are
|
# TODO: this does not yet work on Windows. Somehow, unused functions are
|
||||||
# not garbage collected.
|
# not garbage collected.
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
|
#ifdef __MACH__
|
||||||
|
.global _tinygo_startTask
|
||||||
|
_tinygo_startTask:
|
||||||
|
#else
|
||||||
.section .text.tinygo_startTask
|
.section .text.tinygo_startTask
|
||||||
.global tinygo_startTask
|
.global tinygo_startTask
|
||||||
.type tinygo_startTask, %function
|
.type tinygo_startTask, %function
|
||||||
tinygo_startTask:
|
tinygo_startTask:
|
||||||
|
#endif
|
||||||
.cfi_startproc
|
.cfi_startproc
|
||||||
// Small assembly stub for starting a goroutine. This is already run on the
|
// Small assembly stub for starting a goroutine. This is already run on the
|
||||||
// new stack, with the callee-saved registers already loaded.
|
// new stack, with the callee-saved registers already loaded.
|
||||||
|
@ -23,13 +28,25 @@ tinygo_startTask:
|
||||||
blr x19
|
blr x19
|
||||||
|
|
||||||
// After return, exit this goroutine. This is a tail call.
|
// After return, exit this goroutine. This is a tail call.
|
||||||
|
#ifdef __MACH__
|
||||||
|
b _tinygo_pause
|
||||||
|
#else
|
||||||
b tinygo_pause
|
b tinygo_pause
|
||||||
|
#endif
|
||||||
.cfi_endproc
|
.cfi_endproc
|
||||||
|
#ifndef __MACH__
|
||||||
.size tinygo_startTask, .-tinygo_startTask
|
.size tinygo_startTask, .-tinygo_startTask
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __MACH__
|
||||||
|
.global _tinygo_swapTask
|
||||||
|
_tinygo_swapTask:
|
||||||
|
#else
|
||||||
.global tinygo_swapTask
|
.global tinygo_swapTask
|
||||||
.type tinygo_swapTask, %function
|
.type tinygo_swapTask, %function
|
||||||
tinygo_swapTask:
|
tinygo_swapTask:
|
||||||
|
#endif
|
||||||
// This function gets the following parameters:
|
// This function gets the following parameters:
|
||||||
// x0 = newStack uintptr
|
// x0 = newStack uintptr
|
||||||
// x1 = oldStack *uintptr
|
// x1 = oldStack *uintptr
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
|
#ifdef __MACH__
|
||||||
|
.global _tinygo_scanCurrentStack
|
||||||
|
_tinygo_scanCurrentStack:
|
||||||
|
#else
|
||||||
.section .text.tinygo_scanCurrentStack
|
.section .text.tinygo_scanCurrentStack
|
||||||
.global tinygo_scanCurrentStack
|
.global tinygo_scanCurrentStack
|
||||||
.type tinygo_scanCurrentStack, %function
|
.type tinygo_scanCurrentStack, %function
|
||||||
tinygo_scanCurrentStack:
|
tinygo_scanCurrentStack:
|
||||||
|
#endif
|
||||||
// Sources:
|
// Sources:
|
||||||
// * https://developer.arm.com/architectures/learn-the-architecture/armv8-a-instruction-set-architecture/procedure-call-standard
|
// * https://developer.arm.com/architectures/learn-the-architecture/armv8-a-instruction-set-architecture/procedure-call-standard
|
||||||
// * https://godbolt.org/z/qrvrEh
|
// * https://godbolt.org/z/qrvrEh
|
||||||
|
@ -16,7 +21,11 @@ tinygo_scanCurrentStack:
|
||||||
|
|
||||||
// Scan the stack.
|
// Scan the stack.
|
||||||
mov x0, sp
|
mov x0, sp
|
||||||
|
#ifdef __MACH__
|
||||||
|
bl _tinygo_scanstack
|
||||||
|
#else
|
||||||
bl tinygo_scanstack
|
bl tinygo_scanstack
|
||||||
|
#endif
|
||||||
|
|
||||||
// Restore stack state and return.
|
// Restore stack state and return.
|
||||||
ldp x29, x30, [sp], #96
|
ldp x29, x30, [sp], #96
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче