From fc17c3565ef4e73c0c4d0a6a3558275fa5ea5d43 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Mon, 20 Jul 2026 16:41:51 +0200 Subject: [PATCH] esp32: remove dead code and fix GC root scanning Remove unused cpuIntUsed and cpuIntToPeripheral variables from interrupt_esp32.go because these were declared but never read. Fix _globals_end in the linker script to cover .data in addition to .bss and .wifi_bss. Previously the GC scan range ended at _wifi_bss_end, missing any heap pointers stored in initialized globals (.data section). Extend to _edata so the conservative collector sees all global root pointers. Signed-off-by: deadprogram --- src/runtime/interrupt/interrupt_esp32.go | 10 ---------- targets/esp32.ld | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/runtime/interrupt/interrupt_esp32.go b/src/runtime/interrupt/interrupt_esp32.go index 9aaa822fa..487feb81a 100644 --- a/src/runtime/interrupt/interrupt_esp32.go +++ b/src/runtime/interrupt/interrupt_esp32.go @@ -53,13 +53,6 @@ const ( lastCPUInt = 30 ) -// cpuIntUsed tracks which CPU interrupt lines have been allocated. -var cpuIntUsed [32]bool - -// cpuIntToPeripheral maps CPU interrupt number → peripheral IRQ source, -// so that handleInterrupt can dispatch to the correct Go handler. -var cpuIntToPeripheral [32]int - // inInterrupt is set while we're inside the interrupt handler so that // interrupt.In() returns the correct value. var inInterrupt bool @@ -75,9 +68,6 @@ func (i Interrupt) Enable() error { return errInterruptRange } - // Mark as used. - cpuIntUsed[i.num] = true - // Read current INTENABLE, set the bit for this CPU interrupt. cur := readINTENABLE() cur |= 1 << uint(i.num) diff --git a/targets/esp32.ld b/targets/esp32.ld index 0f3648cc1..9a7620229 100644 --- a/targets/esp32.ld +++ b/targets/esp32.ld @@ -185,7 +185,7 @@ SECTIONS /* For the garbage collector. */ _globals_start = _sbss; -_globals_end = _wifi_bss_end; +_globals_end = _edata; _heap_start = _edata; /* Go GC heap = the rest of SRAM2 above .data (~113KB), a single safe contiguous * block. The WiFi arena lives in DRAM1 (SRAM1 pool 7/6), so its ~64KB does not