all: make TinyGo code usable with "big Go" CGo

I managed to get CGo sort-of working in VSCode (meaning that it will
typecheck code in the IDE itself) using a few crude hacks, but it
requires a few minor changes to the TinyGo standard library.

I intend to eventually add this support in the TinyGo extension for
VSCode directly, but for now I've manually updated .vscode/settings.json
to get IDE support. In any case, it would be nice to have this for when
I hopefully add this to the TinyGo extension eventually.
Этот коммит содержится в:
Ayke van Laethem 2024-01-27 18:57:29 +01:00 коммит произвёл Ron Evans
родитель 36d60b8349
коммит 7486277012
8 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,5 @@
//go:build tinygo
// Only generate .debug_frame, don't generate .eh_frame. // Only generate .debug_frame, don't generate .eh_frame.
.cfi_sections .debug_frame .cfi_sections .debug_frame

Просмотреть файл

@ -1,3 +1,5 @@
//go:build tinygo
.section .bss.tinygo_systemStack .section .bss.tinygo_systemStack
.global tinygo_systemStack .global tinygo_systemStack
.type tinygo_systemStack, %object .type tinygo_systemStack, %object

Просмотреть файл

@ -1,3 +1,5 @@
//go:build tinygo
// Only generate .debug_frame, don't generate .eh_frame. // Only generate .debug_frame, don't generate .eh_frame.
.cfi_sections .debug_frame .cfi_sections .debug_frame

Просмотреть файл

@ -52,17 +52,17 @@ func (s *state) archInit(r *calleeSavedRegs, fn uintptr, args unsafe.Pointer) {
} }
func (s *state) resume() { func (s *state) resume() {
switchToTask(s.sp) tinygo_switchToTask(s.sp)
} }
//export tinygo_switchToTask //export tinygo_switchToTask
func switchToTask(uintptr) func tinygo_switchToTask(uintptr)
//export tinygo_switchToScheduler //export tinygo_switchToScheduler
func switchToScheduler(*uintptr) func tinygo_switchToScheduler(*uintptr)
func (s *state) pause() { func (s *state) pause() {
switchToScheduler(&s.sp) tinygo_switchToScheduler(&s.sp)
} }
// SystemStack returns the system stack pointer. On Cortex-M, it is always // SystemStack returns the system stack pointer. On Cortex-M, it is always

Просмотреть файл

@ -1,3 +1,5 @@
//go:build tinygo
.section .text.tinygo_startTask,"ax",@progbits .section .text.tinygo_startTask,"ax",@progbits
.global tinygo_startTask .global tinygo_startTask
.type tinygo_startTask, %function .type tinygo_startTask, %function

Просмотреть файл

@ -1,3 +1,5 @@
//go:build tinygo
.section .text.tinygo_startTask,"ax",@progbits .section .text.tinygo_startTask,"ax",@progbits
.global tinygo_startTask .global tinygo_startTask
.type tinygo_startTask, %function .type tinygo_startTask, %function

Просмотреть файл

@ -1,3 +1,5 @@
//go:build tinygo
.section .text.tinygo_startTask .section .text.tinygo_startTask
.global tinygo_startTask .global tinygo_startTask
.type tinygo_startTask, %function .type tinygo_startTask, %function

Просмотреть файл

@ -1,4 +1,4 @@
//go:build rp2040 //go:build tinygo && rp2040
package machine package machine