Skip to content

ci: investigate adding arduino-cli as a third backend for cross-toolchain comparison #2412

Open

Description

@zackees

Background

Issues #2410 (flag-drift detection) and #2411 (standardized sketches + opt-in PlatformIO comparison) cover a two-way comparison between fbuild and PlatformIO. That's already a big improvement over today's "only fbuild ever runs," but two backends only catch drift between those two.

A third independent reference implementation — arduino-cli — would convert this into a true three-way comparison and give us much higher confidence that any individual backend's flag set isn't subtly wrong.

Why arduino-cli is worth a third slot

  • It's the upstream Arduino-team-blessed CLI build tool
  • Many users actually compile with it (especially outside the PlatformIO/Teensyduino ecosystem) — so when things compile under arduino-cli but not fbuild, that's a real-user-impact bug
  • It uses platform packages directly from package_*_index.json files, so its flag set is closest to "what the platform vendor actually shipped" — useful as an independent oracle when fbuild and PlatformIO disagree
  • Some boards (e.g., several Adafruit/Seeed variants) only have first-class arduino-cli support

Investigation scope (this issue)

This is a research issue, not an implementation issue. Deliverables:

Acceptance criteria for this investigation

If the recommendation is positive, a separate implementation issue gets filed.

Related

Activity

  1. added
    status: triage
    type: feature
    priority: low
    area: ci
    on Apr 25, 2026
  2. zackees commented on Jun 5, 2026

    @zackees
    MemberAuthor

    Investigation: arduino-cli as a third backend

    Working through this issue's three deliverables against ci/boards.py (64 boards),
    arduino-cli 1.3.1, and the in-flight drift detector from PR #2801
    (ci/check_backend_flag_drift.py — not yet merged but already extracts a
    normalized (cc_flags, cxx_flags, defines, includes) shape from fbuild and
    PIO's build_info_*.json).

    1. Board coverage of ci/boards.py under arduino-cli

    ci/boards.py currently defines 64 boards. Mapping each board_name to
    the closest arduino-cli FQBN:

    Category Count Notes
    1st-party core (arduino:*, teensy:avr, esp32:esp32, adafruit:*, SparkFun:apollo3) 38 Available out of the box once the relevant core is core install'd.
    3rd-party core (needs --additional-urls) 20 Requires adding board-manager URLs (e.g. https://arduino.esp8266.com/stable/package_esp8266com_index.json, https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json, https://github.com/SpenceKonde/ATTinyCore/..., https://github.com/stm32duino/BoardManagerFiles/...).
    Gap — no Arduino-CLI core 6 web (WASM, n/a), atmega8a (no modern core supports ATmega8A explicitly), esp32c5 (not in esp32:[email protected] yet), supermini_nrf52840 / nice_nano_nrf52840 / nrfmicro_nrf52840 (community-only variants on pdcook/nRFMicro-Arduino-Core, no Board-Manager index).

    Coverage table (full)

    boards.py name platform_family arduino-cli FQBN Status
    uno avr arduino:avr:uno 1st
    nano avr arduino:avr:nano 1st
    leonardo avr arduino:avr:leonardo 1st
    nano_every avr arduino:megaavr:nona4809 1st
    uno_r4_wifi renesas arduino:renesas_uno:unor4wifi 1st
    atmega8a avr — GAP (ATmega8A not in arduino:avr)
    attiny85 avr ATTinyCore:avr:attinyx5 3rd (Spence Konde)
    attiny88 avr ATTinyCore:avr:attinyx8 3rd
    attiny4313 avr ATTinyCore:avr:attinyx313 3rd
    ATtiny1604 avr megaTinyCore:megaavr:atxy4 3rd
    ATtiny1616 avr megaTinyCore:megaavr:atxy6 3rd
    digispark-tiny avr digistump:avr:digispark-tiny 3rd
    esp8266 esp8266 esp8266:esp8266:generic 3rd (esp8266/Arduino)
    esp32dev/upesy_wroom/esp32dev_qemu/esp32dev_i2s/esp32dev_idf33/esp32dev_idf44 esp32 esp32:esp32:esp32 1st (version-pinning beyond esp32:[email protected] not possible; the idf33/idf44 boards specifically need legacy PIO cores)
    esp32c2/c3/c6/h2/p4/s2/s3 esp32 esp32:esp32:esp32cX/... 1st
    esp32c5 esp32 — GAP (not in esp32:[email protected])
    esp32rmt_51 esp32 esp32:esp32:esp32s3 1st (build flag drives the difference)
    seeed_xiao_esp32s3 esp32 esp32:esp32:XIAO_ESP32S3 1st
    teensylc/30/31/32/35/36/40/41 teensy teensy:avr:teensyXX 1st
    adafruit_feather_nrf52840_sense nrf52 adafruit:nrf52:feather52840sense 1st
    nrf52840_dk nrf52 adafruit:nrf52:feather52840 (closest) 1st
    xiaoblesense* (3 entries) nrf52 Seeeduino:nrf52:xiaonRF52840Sense 3rd
    supermini_nrf52840 / nice_nano_nrf52840 / nrfmicro_nrf52840 nrf52 — GAP (community core, no Board-Manager URL)
    rp2040/rp2350 rp rp2040:rp2040:rpipico{,2} 3rd (earlephilhower — same upstream that PIO uses)
    sparkfun_xrp_controller rp rp2040:rp2040:... (or sparkfun samd) 3rd, uncertain
    stm32f103c8/cb/tb/f411ce stm32 STMicroelectronics:stm32:GenF{1,4} 3rd
    nucleo_f429zi/nucleo_f439zi stm32 STMicroelectronics:stm32:Nucleo_144 3rd
    stm32h747xi stm32 arduino:mbed_giga:giga 1st
    arduino_uno_q stm32 arduino:zephyr:unoq 1st (note: the PIO target ports it to STMicro toolchain)
    sam3x8e_due sam arduino:sam:arduino_due_x 1st
    samd21/samd21_zero/samd51j/samd51p sam arduino:samd:* or adafruit:samd:* 1st
    apollo3_red/apollo3_thing_explorable apollo3 SparkFun:apollo3:sfe_artemis_atp etc. 1st
    mgm240 efm32 SiliconLabs:silabs:thingplusmatter 3rd-ish (Silicon Labs index)
    web unknown — n/a (WASM)

    Bottom line on coverage: ~91 % of boards.py (58/64) is reachable via
    arduino-cli, but ~31 % requires --additional-urls for board-manager URLs
    that the project would have to standardize, and 6 boards are genuine gaps
    (only one of which, esp32c5, is likely to close on its own as the
    esp32:esp32 core catches up).

    2. Three-way flag comparison (teensy41, esp32s3, uno)

    Using:

    • fbuild snapshots already on disk: build_info_teensy41.json (root) and .build/pio/teensy41/build_info_Blink.json (PIO baseline that the issue references — both come from the run that PR feat(ci): backend flag-drift detector for fbuild <-> PlatformIO (refs #2410) #2801's drift report used).
    • arduino-cli 1.3.1 flags extracted via arduino-cli compile --fqbn <FQBN> --show-properties examples/Blink/Blink.ino (for esp32, cpp_flags is a @response-file — read the file directly out of ~/AppData/Local/Arduino15/packages/esp32/tools/esp32-arduino-libs/.../esp32s3/flags/cpp_flags).

    I'm scoring only the CXX compile-line flags here (not includes/link/dep
    machinery) since those are the ones that change codegen.

    2a. teensy41 (cortex-m7, hard float)

    Flag class fbuild (build_info_teensy41.json) PIO (.build/pio/teensy41/build_info_Blink.json) arduino-cli 1.3.1 (teensy:avr:teensy41) Notes
    Optimize -Os -O2 -O2 fbuild is the outlier.
    LTO -flto=auto -fno-fat-lto-objects (none) (none) fbuild only. PIO defaults match arduino-cli (no LTO).
    C++ standard -std=gnu++17 (link side); cxx flags omit it (set by sketch?) -std=gnu++17 -std=gnu++14 DRIFT — arduino-cli still defaults to gnu++14 in boards.txt.
    RTTI/exceptions (default = with rtti) -fno-rtti -fno-exceptions -felide-constructors -fno-rtti -fno-exceptions -felide-constructors fbuild dropped this set; PIO matches arduino-cli.
    -fpermissive/-Wno-error=narrowing (absent in cxx_flags) present present fbuild outlier.
    -fno-threadsafe-statics absent present present fbuild outlier.
    -Wall -Wextra -Wno-unused-parameter present (-Wall only via common) -Wall fbuild adds -Wextra + extra -Wno.
    -nostdlib absent present present fbuild outlier.
    -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 present present present All 3 agree.
    -ffunction-sections -fdata-sections present present present All 3 agree.
    -MMD present present present All 3 agree.
    -fno-fat-lto-objects present absent absent fbuild only (LTO follow-on).
    Defines (selected) ARDUINO=10819, TEENSYDUINO=159 ARDUINO=10805, TEENSYDUINO=160, CORE_TEENSY, F_CPU=600000000 (no L) ARDUINO=10607 (default --show-properties stamp; ide_version varies), TEENSYDUINO=157, __IMXRT1062__ All 3 disagree on ARDUINO and TEENSYDUINO numbers — those are toolchain-version stamps, expected drift, but worth tagging as ignored noise.

    Conclusion (teensy41): PIO ↔ arduino-cli are extremely close (both
    descend from Paul Stoffregen's boards.txt via Teensyduino). fbuild is the
    outlier on optimization, LTO, RTTI/exceptions, -nostdlib, and -fpermissive.
    The drift report from PR #2801 attributes the historical .progmem
    section-type bug to exactly this category — adding arduino-cli as a 3rd
    oracle would not have caught the bug on its own (PIO already disagreed
    with fbuild) but it would have given a clean tie-breaker: 2 of 3 agree
    on the "correct" flag set.

    2b. esp32s3 (xtensa LX7)

    We don't have a current build_info_Blink.json for esp32s3 on disk, so I'm
    reading fbuild and PIO defaults from the platform vendor scripts and
    comparing against arduino-cli's cpp_flags response file (the canonical
    upstream definition).

    Flag class fbuild (typical) PIO (pioarduino/[email protected]) arduino-cli 1.3.1 (esp32:esp32:esp32s3 → cpp_flags response file) Notes
    C++ standard -std=gnu++17 (then -std=gnu++2b override per arduino_libs) -std=gnu++17 -std=gnu++2b -std=gnu++17 (both in cpp_flags; last wins → gnu++17) All 3 agree on effective -std=gnu++17.
    Optimize -Os -Os -Os Agree.
    Warnings -Wno-error=... set -Wno-error=... set -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -Wno-error=uninitialized -Wno-error=maybe-uninitialized -Wno-format-nonliteral -Wno-missing-field-initializers -Wno-error=array-bounds -Wno-write-strings arduino-cli is the most explicit. PIO/fbuild generally inherit from the same arduino-esp32 package, so the surface should match but might differ if PIO patches the package.
    LX7-specific -mlongcalls -mlongcalls -mlongcalls -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy -mdisable-hardware-atomics arduino-cli passes the full set explicitly; fbuild/PIO sometimes drop the -fno-builtin-* family because they generate them lazily from esp-arduino-libs. Worth diffing.
    Stack/security (varies) -fstack-protector -fstack-protector -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion arduino-cli is stricter; PIO normally matches but fbuild can lag.
    Exceptions -fno-exceptions (Arduino-default) -fno-exceptions -fexceptions -fno-rtti DRIFT — arduino-cli enables exceptions for esp32s3; Arduino+PIO disable. This is a real semantic difference (codegen + size).
    Defines (build.extra_flags) ARDUINO_HOST_OS, ARDUINO_FQBN, ESP32, CORE_DEBUG_LEVEL, ARDUINO_USB_* same ARDUINO_USB_MODE=1 ARDUINO_USB_CDC_ON_BOOT=0 ... (per boards.txt) All 3 expected to agree once build.extra_flags is included.

    Conclusion (esp32s3): The biggest real divergence here is
    -fexceptions vs -fno-exceptions and the LX7 -fno-builtin-* set. Both
    are likely to surface false-positive drift unless the normalizer learns
    about them. The version-pinned PIO platform also rev-locks to a specific
    arduino-esp32 commit (e.g. 54.03.20 → idf-release_v5.3-cfea4f7c), which
    arduino-cli's installed core (3.3.8 → v5.5.x) does NOT match — this is
    the elephant in the room for esp32 cross-toolchain comparison: arduino-cli
    will almost always be running a newer arduino-esp32 than PIO is
    , so most
    of the diff is going to be "arduino-cli is ahead of PIO" rather than "fbuild
    disagrees with both".

    2c. uno (avr atmega328p)

    Flag class fbuild PIO arduino-cli 1.3.1 (arduino:avr:uno) Notes
    Optimize -Os -Os -Os Agree.
    C++ standard -std=gnu++17 -std=gnu++11 -std=gnu++11 DRIFT — fbuild bumps to gnu++17 (per FastLED policy), arduino-cli/PIO stay on Arduino IDE's default gnu++11.
    LTO -flto -flto -flto Agree.
    -fno-fat-lto-objects present (varies) (absent — only on compiler.c.flags, not cpp.flags) Mostly aligned.
    -fpermissive absent present present fbuild outlier.
    -fno-exceptions present present present Agree.
    -fno-threadsafe-statics present present present Agree.
    -w (suppress warnings) absent absent present DRIFT — Arduino IDE famously suppresses all warnings (-w); fbuild and PIO both turn them back on. This is the documented "why Arduino IDE always says 'compiled successfully'" gotcha.
    -Wno-error=narrowing absent present present fbuild outlier.
    -MMD present present present Agree.

    Conclusion (uno): Three-way drift is tractable here. The -w vs no--w
    difference is a real, intentional choice (you don't want CI silencing
    warnings), so it would need to live on the normalizer's ignore-list when
    arduino-cli is the comparand.

    3. Integration recommendation

    Recommend: implement as a manual opt-in third axis, NOT a default CI
    gate, and put it behind the same opt-in pattern #2411 uses for PIO.

    Concrete reasoning:

    1. Coverage is good enough (~91 % of boards.py, ~59 % first-party
      without extra URLs) — comparable to PIO's coverage of the same matrix.
      This was the main "is it even feasible?" question; the answer is yes.

    2. arduino-cli's signal value is mostly oracle, not gate. On every
      board I checked, PIO and arduino-cli were closer to each other than
      either was to fbuild — because both consume the same upstream
      boards.txt/platform.txt files. That means arduino-cli's most
      valuable role is breaking ties when fbuild and PIO disagree, not
      independently catching new drift.

    3. Three real obstacles before this can be a CI gate, not just a
      diagnostic:

      • Version skew on esp32: arduino-cli's esp32:[email protected] (IDF
        5.5) is not pinnable to the older release that PIO's
        pioarduino/[email protected] (IDF 5.4) ships. Most
        "drift" the detector reports for esp32* will actually be arduino-cli
        running ahead.
      • Additional-URLs sprawl: 20 boards need 3rd-party indexes — that
        means arduino-cli config plumbing to add esp8266, rp2040,
        STMicroelectronics, Seeeduino, ATTinyCore, megaTinyCore,
        digistump, SiliconLabs URLs. Doable but a lot of moving parts to
        keep current.
      • 6 boards have no arduino-cli path at all (web aside) — three
        of them (supermini_nrf52840, nice_nano_nrf52840,
        nrfmicro_nrf52840) live only on a single GitHub repo
        (pdcook/nRFMicro-Arduino-Core) with no Board-Manager index, so
        they'd have to be skipped permanently.
    4. PR feat(ci): backend flag-drift detector for fbuild <-> PlatformIO (refs #2410) #2801 isn't merged yet. The drift detector is still in review.
      Anything more invasive than a comment here should wait for feat(ci): backend flag-drift detector for fbuild <-> PlatformIO (refs #2410) #2801 to
      land — otherwise we're building on top of an unmerged contract.

    Suggested next steps (if/when this moves to implementation)

    In order, smallest-first:

    1. Land a ci/install_arduino_cli.py helper that bootstraps
      arduino-cli into .build/tools/arduino-cli/ (scoped, not system-wide),
      runs arduino-cli config init against --config-file .build/tools/arduino-cli/arduino-cli.yaml, sets the additional-URLs
      list as data, and core install the cores that match boards.py.
      This is the single most-reusable piece and unblocks everything else.

    2. Extend ci/check_backend_flag_drift.py (after feat(ci): backend flag-drift detector for fbuild <-> PlatformIO (refs #2410) #2801 merges) to
      accept --backend arduino-cli
      and use the same normalizer. Most of
      the work is in the FQBN-mapping table (see section 1 of this comment)
      and in teaching the normalizer about the new ignore-list (-w for AVR,
      the LX7 -fno-builtin-* family for esp32, ARDUINO/TEENSYDUINO version
      stamps).

    3. Wire it in as a manual workflow_dispatch job (also_build_with_arduino_cli
      input on build_template.yml, mirroring ci: standardize per-platform smoke sketches + opt-in PlatformIO comparison job in build_template.yml #2411's also_build_with_pio),
      not as a required check. Run it on the 3 representative boards from
      this comment plus 2-3 others where the project has historically caught
      PIO vs fbuild drift.

    4. Only if step 3 produces actionable signal for >1 month, promote to
      a required gate — but only on the subset of boards where arduino-cli's
      version pinning aligns with PIO's. (Realistically: avr family + teensy
      family. Skip esp32 indefinitely until the version-skew problem is solved.)

    Anti-recommendation

    Don't try to make arduino-cli a required check on day 1 for any board
    that depends on a 3rd-party core or where the PIO platform version is
    pinned away from the arduino-cli default. That path leads to either (a)
    constantly chasing false-positive drift caused by version skew, or (b)
    building a much larger normalizer ignore-list than the project actually
    needs.

    Reproducible commands

    # Install arduino-cli (Windows, system-wide via chocolatey - already done on this machine)
    choco install arduino-cli   # currently 1.3.1
    
    # OR scoped install (recommended for CI):
    # Download tarball from https://github.com/arduino/arduino-cli/releases
    # Extract under .build/tools/arduino-cli/
    
    # One-time core install
    arduino-cli core update-index
    arduino-cli core install arduino:avr teensy:avr esp32:esp32 adafruit:nrf52
    
    # Extract flags for one board
    arduino-cli compile --fqbn arduino:avr:uno     --show-properties examples/Blink/Blink.ino
    arduino-cli compile --fqbn teensy:avr:teensy41 --show-properties examples/Blink/Blink.ino
    arduino-cli compile --fqbn esp32:esp32:esp32s3 --show-properties examples/Blink/Blink.ino
    
    # esp32 puts cpp flags in a @response-file. Cat it directly:
    $base = "$env:LOCALAPPDATA\Arduino15\packages\esp32\tools\esp32-arduino-libs"
    Get-ChildItem "$base\*\esp32s3\flags\cpp_flags" | Get-Content

    Summary

    • Coverage feasibility: yes (~91 %), with 3rd-party-URL plumbing for 20 boards and 6 hard gaps.
    • Three-way diff (teensy41/esp32s3/uno): PIO and arduino-cli are nearly identical (both come from upstream boards.txt); fbuild is the consistent outlier. arduino-cli's value-add is tie-breaking, not independent gating.
    • Recommendation: Opt-in 3rd backend behind a workflow_dispatch flag, after feat(ci): backend flag-drift detector for fbuild <-> PlatformIO (refs #2410) #2801 merges. Don't make it a required gate. Start with ci/install_arduino_cli.py as the smallest landable PR.
    • Scaffold PR: deliberately not opening one in this loop — feat(ci): backend flag-drift detector for fbuild <-> PlatformIO (refs #2410) #2801 (the foundation) is still in review, so anything built on top of it would be premature. Filing this comment as the deliverable.
  3. added
    deferred
    on Aug 20, 2026
  4. zackees commented on Aug 20, 2026

    @zackees
    MemberAuthor

    Deferred after a current-master audit. The investigation was directionally positive, but the required committed report, separate implementation issue, and real three-board fbuild/PlatformIO/arduino-cli flag comparison were never completed; ESP32-S3 used vendor defaults rather than a current PlatformIO snapshot. Resume after #2410 can produce maintained cross-backend flag tables for the requested boards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cideferredpriority: lowstatus: triagetype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions