Skip to content

Commit

Permalink
all: make TinyGo code usable with "big Go" CGo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aykevl authored and deadprogram committed Feb 19, 2024
1 parent 36d60b8 commit 7486277
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/internal/task/task_stack_arm.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build tinygo

// Only generate .debug_frame, don't generate .eh_frame.
.cfi_sections .debug_frame

Expand Down
2 changes: 2 additions & 0 deletions src/internal/task/task_stack_avr.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build tinygo

.section .bss.tinygo_systemStack
.global tinygo_systemStack
.type tinygo_systemStack, %object
Expand Down
2 changes: 2 additions & 0 deletions src/internal/task/task_stack_cortexm.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build tinygo

// Only generate .debug_frame, don't generate .eh_frame.
.cfi_sections .debug_frame

Expand Down
8 changes: 4 additions & 4 deletions src/internal/task/task_stack_cortexm.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ func (s *state) archInit(r *calleeSavedRegs, fn uintptr, args unsafe.Pointer) {
}

func (s *state) resume() {
switchToTask(s.sp)
tinygo_switchToTask(s.sp)
}

//export tinygo_switchToTask
func switchToTask(uintptr)
func tinygo_switchToTask(uintptr)

//export tinygo_switchToScheduler
func switchToScheduler(*uintptr)
func tinygo_switchToScheduler(*uintptr)

func (s *state) pause() {
switchToScheduler(&s.sp)
tinygo_switchToScheduler(&s.sp)
}

// SystemStack returns the system stack pointer. On Cortex-M, it is always
Expand Down
2 changes: 2 additions & 0 deletions src/internal/task/task_stack_esp32.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build tinygo

.section .text.tinygo_startTask,"ax",@progbits
.global tinygo_startTask
.type tinygo_startTask, %function
Expand Down
2 changes: 2 additions & 0 deletions src/internal/task/task_stack_esp8266.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build tinygo

.section .text.tinygo_startTask,"ax",@progbits
.global tinygo_startTask
.type tinygo_startTask, %function
Expand Down
2 changes: 2 additions & 0 deletions src/internal/task/task_stack_tinygoriscv.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build tinygo

.section .text.tinygo_startTask
.global tinygo_startTask
.type tinygo_startTask, %function
Expand Down
2 changes: 1 addition & 1 deletion src/machine/machine_rp2040_rom.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build rp2040
//go:build tinygo && rp2040

package machine

Expand Down

0 comments on commit 7486277

Please sign in to comment.