Skip to content
This repository was archived by the owner on Sep 30, 2021. It is now read-only.

Commit 7eebf7f

Browse files
committed
[HACK] Export variables as __attribute((used)) to avoid being purged by LTO
It would be better to declare the variable as extern or in header files This patch ensures compatibility with pre-LTO cores
1 parent c028cb4 commit 7eebf7f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Squawk.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ extern intptr_t squawk_register;
7777
extern uint16_t cia;
7878

7979
// Exports
80-
osc_t osc[4];
81-
uint8_t pcm = 128;
80+
__attribute__((used)) osc_t osc[4];
81+
__attribute__((used)) uint8_t pcm = 128;
8282

8383
// ProTracker period tables
8484
const uint16_t period_tbl[84] PROGMEM = {
@@ -371,7 +371,7 @@ void SquawkSynth::stop() {
371371
}
372372

373373
// Progress module by one tick
374-
void squawk_playroutine() {
374+
__attribute__((used)) void squawk_playroutine() {
375375
static bool lockout = false;
376376

377377
if(!order_count) return;

src/Squawk.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ extern void squawk_playroutine() asm("squawk_playroutine");
117117
// uses 132 cycles (not counting playroutine)
118118
// ~1/3 CPU @ 44kHz on 16MHz
119119
#define SQUAWK_CONSTRUCT_ISR(TARGET_REGISTER) \
120-
uint16_t cia, cia_count; \
120+
__attribute__((used)) uint16_t cia, cia_count; \
121121
intptr_t squawk_register = (intptr_t)&TARGET_REGISTER; \
122122
ISR(TIMER1_COMPA_vect, ISR_NAKED) { \
123123
asm volatile( \

0 commit comments

Comments
 (0)