Commit b7560aa
On AVR, an empty FastLED Blink sketch built with fbuild was ~10% larger
than the same sketch built with PlatformIO. Symbol diff on attiny85
attributed the entire 342-byte delta to three symbols from `Tone.cpp`
in the ATtinyCore framework (`__vector_3`, `__vector_1`, `noTone`)
that PlatformIO drops as unreferenced archive members but that fbuild
was pulling in because it linked framework `.o` files directly.
The mechanism: `.o` files passed positionally to `avr-gcc` are always
kept by the linker. Section-GC doesn't help because the ISRs override
AVR libc's weak `__vector_default` and are reachable from the AVR
interrupt vector table. `noTone` and its static state come along for
the ride.
Fix: partition link inputs into existing `.a` archives (pass-through)
and raw `.o` objects, archive the raw objects into `libframework.a`
with `avr-gcc-ar`, and feed only archives to the linker. Archive-
member-selection drops members whose strong symbols are unreferenced
before the vector table sees them — matches PlatformIO's behaviour.
`gcc-ar` (not plain `ar`) is required because the default avr.json
profile enables `-flto -fuse-linker-plugin`; `gcc-ar` writes the LTO
bytecode plugin index so the linker can still resolve LTO objects.
Patch shape:
- `AvrLinker` gains a `gcc_ar_path: PathBuf` field; constructor takes
it; orchestrator passes `toolchain.get_gcc_ar_path()` (already
exposed alongside `get_ar_path` and already used by `pick_archiver`).
- `partition_link_inputs` factored to module scope so the partition
logic is unit-tested without invoking real `avr-gcc-ar`.
- `link()` does the archive-then-link dance; `build_link_args` stays a
pure argv builder.
Tests:
- `link_partitions_archives_and_objects` — mixed input partitioning
- `partition_handles_all_archives`, `_all_objects`, `_empty`,
`_treats_unknown_extensions_as_objects`
- `test_avr_linker_creation` updated for new `gcc_ar_path` field
Out of scope: same shape likely affects Teensy / RP2040 / STM32, but
the symbol-diff evidence is AVR-only and broader changes need
platform-by-platform fixture validation. Tracked separately if
reproductions surface.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 8f7910a commit b7560aa
2 files changed
Lines changed: 120 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
57 | 78 | | |
58 | 79 | | |
59 | 80 | | |
60 | 81 | | |
61 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
62 | 86 | | |
63 | 87 | | |
64 | 88 | | |
| |||
92 | 116 | | |
93 | 117 | | |
94 | 118 | | |
95 | | - | |
96 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
97 | 124 | | |
98 | 125 | | |
99 | 126 | | |
| |||
123 | 150 | | |
124 | 151 | | |
125 | 152 | | |
126 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
127 | 180 | | |
128 | 181 | | |
129 | 182 | | |
| |||
191 | 244 | | |
192 | 245 | | |
193 | 246 | | |
| 247 | + | |
194 | 248 | | |
195 | 249 | | |
196 | 250 | | |
| |||
203 | 257 | | |
204 | 258 | | |
205 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
206 | 317 | | |
207 | 318 | | |
208 | 319 | | |
| |||
212 | 323 | | |
213 | 324 | | |
214 | 325 | | |
| 326 | + | |
215 | 327 | | |
216 | 328 | | |
217 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
| 246 | + | |
244 | 247 | | |
245 | 248 | | |
246 | 249 | | |
| |||
0 commit comments