aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-01-27 18:57:29 +0100
committerRon Evans <[email protected]>2024-02-19 15:49:36 +0100
commit7486277012185e98d3896bfd81271b417ddbb029 (patch)
tree9985d41361cff9157ac8332e7be3d73d38b0591c
parent36d60b8349c7c29c6aab42dbff63793025af628c (diff)
downloadtinygo-7486277012185e98d3896bfd81271b417ddbb029.tar.gz
tinygo-7486277012185e98d3896bfd81271b417ddbb029.zip
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.
-rw-r--r--src/internal/task/task_stack_arm.S2
-rw-r--r--src/internal/task/task_stack_avr.S2
-rw-r--r--src/internal/task/task_stack_cortexm.S2
-rw-r--r--src/internal/task/task_stack_cortexm.go8
-rw-r--r--src/internal/task/task_stack_esp32.S2
-rw-r--r--src/internal/task/task_stack_esp8266.S2
-rw-r--r--src/internal/task/task_stack_tinygoriscv.S2
-rw-r--r--src/machine/machine_rp2040_rom.go2
8 files changed, 17 insertions, 5 deletions
diff --git a/src/internal/task/task_stack_arm.S b/src/internal/task/task_stack_arm.S
index 3a1e3f0ae..81a5aa8a0 100644
--- a/src/internal/task/task_stack_arm.S
+++ b/src/internal/task/task_stack_arm.S
@@ -1,3 +1,5 @@
+//go:build tinygo
+
// Only generate .debug_frame, don't generate .eh_frame.
.cfi_sections .debug_frame
diff --git a/src/internal/task/task_stack_avr.S b/src/internal/task/task_stack_avr.S
index 2cba528f2..2e68b1754 100644
--- a/src/internal/task/task_stack_avr.S
+++ b/src/internal/task/task_stack_avr.S
@@ -1,3 +1,5 @@
+//go:build tinygo
+
.section .bss.tinygo_systemStack
.global tinygo_systemStack
.type tinygo_systemStack, %object
diff --git a/src/internal/task/task_stack_cortexm.S b/src/internal/task/task_stack_cortexm.S
index fe1f44e05..dfe713552 100644
--- a/src/internal/task/task_stack_cortexm.S
+++ b/src/internal/task/task_stack_cortexm.S
@@ -1,3 +1,5 @@
+//go:build tinygo
+
// Only generate .debug_frame, don't generate .eh_frame.
.cfi_sections .debug_frame
diff --git a/src/internal/task/task_stack_cortexm.go b/src/internal/task/task_stack_cortexm.go
index 39b90b75c..226a088c8 100644
--- a/src/internal/task/task_stack_cortexm.go
+++ b/src/internal/task/task_stack_cortexm.go
@@ -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
diff --git a/src/internal/task/task_stack_esp32.S b/src/internal/task/task_stack_esp32.S
index 364759b17..c2e4acc2c 100644
--- a/src/internal/task/task_stack_esp32.S
+++ b/src/internal/task/task_stack_esp32.S
@@ -1,3 +1,5 @@
+//go:build tinygo
+
.section .text.tinygo_startTask,"ax",@progbits
.global tinygo_startTask
.type tinygo_startTask, %function
diff --git a/src/internal/task/task_stack_esp8266.S b/src/internal/task/task_stack_esp8266.S
index e7334edcb..07f4e2659 100644
--- a/src/internal/task/task_stack_esp8266.S
+++ b/src/internal/task/task_stack_esp8266.S
@@ -1,3 +1,5 @@
+//go:build tinygo
+
.section .text.tinygo_startTask,"ax",@progbits
.global tinygo_startTask
.type tinygo_startTask, %function
diff --git a/src/internal/task/task_stack_tinygoriscv.S b/src/internal/task/task_stack_tinygoriscv.S
index 0ac6f1231..5f6127427 100644
--- a/src/internal/task/task_stack_tinygoriscv.S
+++ b/src/internal/task/task_stack_tinygoriscv.S
@@ -1,3 +1,5 @@
+//go:build tinygo
+
.section .text.tinygo_startTask
.global tinygo_startTask
.type tinygo_startTask, %function
diff --git a/src/machine/machine_rp2040_rom.go b/src/machine/machine_rp2040_rom.go
index 2cf96d89d..eea461882 100644
--- a/src/machine/machine_rp2040_rom.go
+++ b/src/machine/machine_rp2040_rom.go
@@ -1,4 +1,4 @@
-//go:build rp2040
+//go:build tinygo && rp2040
package machine