Repository navigation
fix(nrf52): compile the framework libraries a sketch reaches - #2077
Conversation
The nRF52 orchestrator put only `Wire/` and `SPI/` on the include path and never compiled either library, so a sketch calling `Wire.begin()` compiled and then failed to link with `undefined reference to TwoWire::begin()` (#2072, on main as well). Resolve the bundled `libraries/` tree the way the Teensy/STM32/RP2040/ ESP8266/Renesas orchestrators already do: seed the shared library-dependency finder from the project's translation units, honor `lib_deps`, and add only the reached libraries' include dirs and sources. Unreached libraries (`Bluefruit52Lib`, `Adafruit_LittleFS`, ...) stay out, so they cannot shadow a core header or bloat the build. `Adafruit_TinyUSB_Arduino` is excluded from the candidates because the orchestrator's TinyUSB block already compiles it, and any source already in the core set (the `SPI.cpp` the TinyUSB host adapter needs) is filtered out so no translation unit is built twice. The Adafruit BSP uses the flat 1.0 layout (`libraries/Wire/Wire_nRF52.cpp`), which the shared discovery helper already handles; the fixture mirrors it.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
End-to-end receipt on the branch (worktree binary
and Same project on |
What
The nRF52 orchestrator put only
Wire/andSPI/on the include path and never compiled either library. A sketch that callsWire.begin()therefore compiled and then failed to link:That is #2072, reproduced on
mainwith the installed CLI (2.5.50) againsttests/platform/nrf52840_dkplus a five-lineWiresketch.PlatformIO compiles the framework's built-in libraries through LDF when they are included; the Teensy, STM32, RP2040, ESP8266 and Renesas orchestrators here already do the same. nRF52 was the gap.
How
nrf52/framework_libs.rsresolves the core'slibraries/tree with the shared finder (resolve_framework_library_selection_active_declared_with_extra), seeded from the project's translation units, honoringlib_depsand active#ifbranches, with the include path built so far so SDK headers resolve as they will at compile time. The orchestrator then adds the reached libraries' include dirs and sources before the compiler is created (step 6b), solib_depsbuilds see the same path.Rails:
Bluefruit52Lib,Adafruit_LittleFS,Adafruit_nRFCrypto, ... stay out when the sketch does not include them, so they cannot shadow a core header or bloat the build.Adafruit_TinyUSB_Arduinois never a candidate. The orchestrator's TinyUSB block already compiles the stack (with its USB-CDC config) on every nRF52840 build.SPI.cppthe TinyUSB host adapter needs — are filtered out by normalized path before being added.libraries/Wire/Wire_nRF52.cpp,libraries/SPI/SPI.cpp+SPI_nrf52832.cpp). The shared discovery helper already implements the Arduino spec for both layouts; the new test fixture mirrors the flat one, and both SPI sources are compiled (the nRF52832 one is#ifdef NRF52832_XXAA-guarded, exactly as Arduino builds it).Tests
crates/fbuild-build-arm/src/nrf52/framework_libs_tests.rs(7 tests, new):sketch_include_compiles_the_bundled_library—#include <Wire.h>⇒Wire_nRF52.cppin the compile set and the Wire dir on the include path;SPI.cppnot selected.unreached_library_contributes_nothing—Bluefruit52Lib/Adafruit_LittleFSabsent.flat_layout_library_contributes_every_source— bothSPI.cppandSPI_nrf52832.cpp.orchestrator_compiled_library_is_never_selected— TinyUSB excluded even when the sketch includes it.already_compiled_sources_are_not_duplicated— the manually addedSPI.cppis not handed back.declared_lib_deps_selects_a_library—lib_depsnames a library the scan cannot infer.missing_libraries_dir_is_empty— a core withoutlibraries/is not an error.Receipts:
main, real build oftests/platform/nrf52840_dk+Wire.begin()): link failed with the fourundefined referenceerrors quoted above.soldr cargo test -p fbuild-build-arm --lib⇒ 307 passed, 0 failed, 2 ignored.soldr cargo fmt --all -- --checkclean.#2072 stays open until the end-to-end
fbuild buildreceipt is attached (host is at load ~90-120/16 this tick, so the CLI rebuild needed for it is still running).Part of #2035.