Skip to content

Commit 7486277

Browse files
aykevldeadprogram
authored andcommitted
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.
1 parent 36d60b8 commit 7486277

File tree

8 files changed

+17
-5
lines changed

8 files changed

+17
-5
lines changed

src/internal/task/task_stack_arm.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build tinygo
2+
13
// Only generate .debug_frame, don't generate .eh_frame.
24
.cfi_sections .debug_frame
35

src/internal/task/task_stack_avr.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build tinygo
2+
13
.section .bss.tinygo_systemStack
24
.global tinygo_systemStack
35
.type tinygo_systemStack, %object

src/internal/task/task_stack_cortexm.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build tinygo
2+
13
// Only generate .debug_frame, don't generate .eh_frame.
24
.cfi_sections .debug_frame
35

src/internal/task/task_stack_cortexm.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ func (s *state) archInit(r *calleeSavedRegs, fn uintptr, args unsafe.Pointer) {
5252
}
5353

5454
func (s *state) resume() {
55-
switchToTask(s.sp)
55+
tinygo_switchToTask(s.sp)
5656
}
5757

5858
//export tinygo_switchToTask
59-
func switchToTask(uintptr)
59+
func tinygo_switchToTask(uintptr)
6060

6161
//export tinygo_switchToScheduler
62-
func switchToScheduler(*uintptr)
62+
func tinygo_switchToScheduler(*uintptr)
6363

6464
func (s *state) pause() {
65-
switchToScheduler(&s.sp)
65+
tinygo_switchToScheduler(&s.sp)
6666
}
6767

6868
// SystemStack returns the system stack pointer. On Cortex-M, it is always

src/internal/task/task_stack_esp32.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build tinygo
2+
13
.section .text.tinygo_startTask,"ax",@progbits
24
.global tinygo_startTask
35
.type tinygo_startTask, %function

src/internal/task/task_stack_esp8266.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build tinygo
2+
13
.section .text.tinygo_startTask,"ax",@progbits
24
.global tinygo_startTask
35
.type tinygo_startTask, %function

src/internal/task/task_stack_tinygoriscv.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build tinygo
2+
13
.section .text.tinygo_startTask
24
.global tinygo_startTask
35
.type tinygo_startTask, %function

src/machine/machine_rp2040_rom.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build rp2040
1+
//go:build tinygo && rp2040
22

33
package machine
44

0 commit comments

Comments
 (0)