Skip to content

feat(espidf): opt-in delegating idf.py build producing <build>/idf/ artifacts #1971

Closed

Description

@zackees

Follow-up 2 of 5 from the merged research pass in #1761 (design note: docs/design/bare-idf-component-builds.md).

Why

fbuild compiles every ESP32 environment with the Arduino core against precompiled ESP-IDF .a libraries; there is no CMake and no idf.py (crates/fbuild-build-esp/src/esp32/orchestrator/helpers.rs). A genuine idf_component_register() project therefore cannot be built at all today — and must not be claimed (#1664, #1730).

Scope

Per the recommended hybrid option (option 3 in the note): keep the native Arduino-on-IDF path untouched and add an explicit opt-in delegating path.

Reference spike (measured, esp32s3, 16-vCPU host)

step wall
set-target esp32s3 15.9 s (configure 12.0 s)
cold build 50.3 s (1071 ninja actions, 1064 objects, 108 archives)
no-op build 1.54 s
one-file touch 10.8 s

Artifacts: app bin 208,528 B, elf 3,721,344 B, map 3,108,610 B, bootloader.bin 21,056 B, partition-table.bin 3,072 B, sdkconfig 73,024 B, compile_commands.json 7.39 MB / 959 entries, build/ 144 MB.

Acceptance criteria

  • A real component project (main component with idf_component_register(... REQUIRES ...) plus a second component, app_main() only, sdkconfig.defaults) builds through fbuild and produces all artifacts above.
  • The same project without the opt-in still fails fast with fix(esp32): reject framework = espidf instead of silently building Arduino (#1664) #1730's message (no silent Arduino build).
  • The Arduino-on-IDF path is byte-identical to before for an existing board (build a fixture before/after and compare sizes + flash/RAM numbers).
  • A delegated build that is killed/timed out produces a structured /api failure with both bounded streams and no orphaned children.
  • Tests exercise the real spawn against a fake idf.py (argv, cwd, env, artifact discovery) — plus one ignored end-to-end test gated on a locally installed IDF.

Non-goals

  • No zccache integration in this issue (follow-up 5); no compile-db re-rooting (follow-up 4); no multi-version IDF matrix.

Depends on: #1970 (follow-up 1). Blocks: #1972, #1973, #1974 (follow-ups 3, 4, 5).

Activity

  1. added
    enhancement
    on Nov 9, 2026
  2. zackees commented on Nov 10, 2026

    @zackees
    MemberAuthor

    Prerequisite check from the steward — the pinned release is now installable end to end:

  3. zackees commented on Nov 10, 2026

    @zackees
    MemberAuthor

    The last non-delegation input is now on main: PR #1983 (merged as 94e54ffc) pins and installs CMake 3.30.2 and Ninja 1.12.1 as part of the Esp32S3Only ESP-IDF profile.

    What that means for this issue:

    • EspIdfInstall::install() now returns an environment that can actually configure: tools/idf.py --version prints ESP-IDF v5.5.1 out of the installed tree, and idf.py set-target esp32s3 on a two-component project configures for real (CMAKE_GENERATOR=Ninja, CMAKE_MAKE_PROGRAM = the pinned ninja, compiler = pinned xtensa-esp32s3-elf-gcc).
    • Two behaviours the delegation has to honour, both measured while proving it:
      1. IDF_TOOLS_PATH must be set — not to ~/.espressif, but to the python entry's python_env/, because idf_tools.py::get_constraints(online=False) fatals when espidf.constraints.v5.5.txt is missing there and idf.py --version never starts. InstalledEspIdf::env_vars() already emits it.
      2. The profile's directories must be prepended to the host PATH, never substituted for it: idf.py/CMake shell out to ln and friends, so a tool-dirs-only PATH dies inside mbedtls with Could not create symbolic link.
    • Measured whole release: 1838 MB (target toolchains ~1149 MB, build tools 153.6 MB, source 450 MB, python 85.5 MB). The set-target configure is ~5 s warm on this host; the reference spike's cold build (50.3 s, 1071 ninja actions) is unchanged.

    So AC1 of this issue no longer depends on any host tooling — the remaining work is the delegation itself (<build>/idf/ artifacts, structured failure, fake-idf.py tests, ignored e2e gated on an installed IDF), which is what #1971 asks for.

  4. zackees commented on Nov 10, 2026

    @zackees
    MemberAuthor

    Delivered in #1984 (merged as ed2c845d).

    AC State Evidence
    Real component project builds through fbuild, all artifacts met ignored e2e 1 passed in 129.30s (cold 311 s incl. the release install): component_demo.bin 208,528 / .elf 3,915,304 / .map 3,191,030 / bootloader.bin 21,056 / partition-table.bin 3,072 / sdkconfig 73,024 / compile_commands.json 15,537,131 = 22,949,145 B under <build>/idf/, plus idf-artifacts.json
    Without the opt-in it still fails fast with #1730's message met bare_espidf_framework_is_rejected_before_building (now also names board_build.build_system) + the_delegated_opt_in_permits_a_bare_espidf_project
    Arduino-on-IDF path unchanged met (not re-measured byte-for-byte) no native-path code edited; the branch is guarded by a switch that defaults to native; post-merge main board jobs (ESP32 Dev/S3/C6/P4/H2/S2, Uno, Teensy) are green on the merge commit
    Killed/timed-out build → structured failure, both bounded streams, no orphans met a_wedged_step_times_out_with_both_streams, plus the new subprocess::run_command_reporting cells (timeout keeps pre-deadline output; streams bounded to a 64 KiB tail with totals recorded)
    Real spawn against a fake idf.py (argv, cwd, env, discovery) + one ignored e2e met set_target_then_build_runs_with_the_installed_environment, a_failed_step_reports_stage_exit_code_and_both_streams, 7 artifact tests

    Two findings worth recording for the follow-ups:

    • idf.py writes the generated sdkconfig into the project directory, not the build directory (<build>/config/sdkconfig.json is the resolved copy).
    • The installed release's PATH entries must be prepended to the host PATH (confirmed again here), and IDF_TOOLS_PATH must be the python entry's python_env/.

    Measured env contract for #1972–#1974: with the profile on PATH, idf.py set-target esp32s3 + idf.py build take 311 s cold / ~50 s warm on this 16-vCPU host at loadavg ~30, and the delegated build directory is 163 MB.

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

    enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions