fix(rp2040): do not infer Bluetooth-only Arduino-Pico libraries when Bluetooth is off - #1606
Merged
Merged
Conversation
…Bluetooth is off Since #1473 seeds every TU a local library compiles, FastLED's unity TUs (lib/FastLED/fl/build/*.cpp, previously skipped because the seed walk pruned any dir named 'build') reach platforms/arm/rp/ble_rp.cpp.hpp. Its #include <BTstackLib.h> sits behind '#if FL_BLE_AVAILABLE && defined(FL_IS_RP2350)', both header-derived and therefore undecidable to the scanner, so every arm is scanned and BTstackLib is selected for a plain Pico 2 build. BTstackLib.h includes the core's _needsbt.h, which static_asserts ENABLE_CLASSIC, so the build fails. Arduino-Pico declares its Bluetooth libraries with #include <_needsbt.h>. Drop those from the RP2040 framework-library candidates unless ENABLE_CLASSIC is set (ipbtstack menu or build_flags); a lib_deps entry still selects one.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository: FastLED/fbuild/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A plain Raspberry Pi Pico 2 (rp2350,
board = rpipico2, no Bluetooth) FastLED build has failed since fbuild 2.5.28. The framework-library selector picks Arduino-Pico'sBTstackLib, and compiling it fails:Bisect
Clean builds (
--clean) of the same generated project (.build/fbuild/rp2350from FastLEDbash compile rp2350 --examples Blink, earlephilhower core 5.7.0):The only build change in 2.5.27..2.5.28 is ae0cf3a (#1473): "compile only reached lib/ libraries ... only selected local libraries seed framework-library selection".
Root cause
collect_local_library_seedswalkedlib/<name>/throughshould_scan_entry, which prunes any directory namedbuild. FastLED ships flat inlib/FastLED/and keeps all of its translation units infl/build/*.cpp, which are unity TUs. So fbuild 2.5.27 seeded only one FastLED file (platforms/esp/32/drivers/gpio_isr_rx/fast_isr.S). Since fix(build): fail oversize images, compile only reached lib/ libraries, warn on ignored version pins #1473, seeds come fromInstalledLibrary::get_source_files(), which is what the build actually compiles. That adds all 29fl/build/*+.cppunity TUs. The new seeding is correct ("what compiles is what seeds"). The old behaviour got this right only by accident.fl/build/platforms+.cpp→platforms/_build.cpp.hpp→platforms/arm/rp/_build.cpp.hpp→platforms/arm/rp/ble_rp.cpp.hpp. That file has#include <BTstackLib.h>under#if FL_BLE_AVAILABLE && defined(FL_IS_RP2350). FastLED headers#defineboth macros, so by design (docs/architecture/library-selection.md, "undecidable" row, Framework-library scan misses <SPI.h> for SAMD: neither the active conditional include nor the #if 0 LDF hint is seen #1371) the scanner scans every arm.BTstackLibgets selected.BTstackLib.hdoes#include <_needsbt.h>, whichstatic_assertsENABLE_CLASSIC. Only the board's Bluetoothipbtstackmenu entries set that macro (-DENABLE_CLASSIC=1 -DENABLE_BLE=1 ...).arduino-cli (it preprocesses) and PlatformIO
chain(it does not scan every TU of a dependency library) would not selectBTstackLibhere.Confirmed directly. Removing only the
#include <BTstackLib.h>line from the project'sble_rp.cpp.hpp(with the selection cache cleared) makes the unfixed build pass.Fix
Arduino-Pico marks every Bluetooth-only library with
#include <_needsbt.h>. Picking one of those by inference whenENABLE_CLASSICis unset can never produce a working build. The newrp2040/bluetooth_libs.rsremoves these libraries from the RP2040 framework-library candidates unless one of the following holds:ENABLE_CLASSICis truthy, from the board menu defines or from the user'sbuild_flags, orlib_depsnames the library. An explicit declaration still wins, and the framework's own error then explains the missing menu.Generic selection semantics are unchanged.
fbuild_library_select::declared_dep_namebecomespubso thelib_depsmatching is reused rather than duplicated. A short note was added todocs/architecture/library-selection.md.Tests
crates/fbuild-build-arm/src/rp2040/bluetooth_libs.rs. RED against a pass-through stub:drops_bluetooth_library_when_bluetooth_is_disabledanddrops_bluetooth_library_when_enable_classic_is_zerofailed. GREEN after the fix: all 5 pass. They cover the menu enabling Bluetooth, alib_depsdeclaration, and a commented-out include.soldr cargo test -p fbuild-build-arm -p fbuild-library-select: all pass (233 + 32 + ...).soldr cargo clippy -p fbuild-build-arm -p fbuild-library-select --all-targets -- -D warnings: clean.End-to-end (locally built
FBUILD_DEV_MODE=1 target/debug/fbuild build <proj> -e <env> --clean)BTstackLib.cpp→_needsbt.hstatic assertionbuild succeeded in 36.2s (flash: 618464 bytes, ram: 60168 bytes). Daemon log showsskipping framework library ... BTstackLib(plus SerialBT, HID_Bluetooth, BluetoothHIDMaster, ...)board_build.ipbtstack = ipv4btcble,lib_deps = BTstackLib, HTTPUpdate)build succeeded in 42.8s,BTstackLibstill selectedRelated, not fixed here
The library-select cache key hashes seed (TU) contents and each library's canonical header, but not the project headers the walk reaches. Editing only
ble_rp.cpp.hpptherefore produced a cache hit with the same key and the stale selection. That made a "remove the include and rebuild" experiment look like the include was not the cause.--cleandoes not clear~/.fbuild/<mode>/cache/library-selection. This deserves its own issue.