Skip to content

fix(esp32): keep #include_next headers out of the header farm - #1567

Merged
zackees merged 1 commit into
mainfrom
fix/include-farm-include-next
Sep 29, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/include-farm-include-next

Conversation

@zackees

@zackees zackees commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Fixes #1566, a regression from #1550 found while verifying #1559.

Symptom: on current main, every build on pioarduino arduino-esp32 3.3.11 (IDF 5.5) fails with implicit declaration of function '__assert_func', e.g. tests/platform/esp32s3 -e esp32s3. Replaying the same compile with the original -I list succeeds.

Cause:

  • esp_common/include/esp_assert.h does a quoted #include "assert.h". In the merged farm root, newlib's platform_include/assert.h sits beside it, so GCC finds it relative to the including file. The farm's equivalence check passed because it is the same file the chain found.
  • GCC restarts #include_next for a header found that way. The restarted search finds the farm's assert.h again, and #pragma once drops it, so the toolchain's assert.h never loads.
  • I bisected this with -H traces of both variants: the first divergence is exactly at that #include_next.

Fix: a block directory that holds any header containing #include_next keeps its own -I. Its headers are then always reached via the search chain, exactly as without the farm. FORMAT_VERSION becomes 2, so existing farms are rebuilt.

Test: include_next_header_beside_a_quoted_includer_keeps_its_directory fails without the fix (red check done) and passes with it. All 11 include_farm tests pass.

End-to-end:

project framework result
tests/platform/esp32s3 pioarduino 3.3.11 (369 → 17 -I) builds, 300.52 KB
bench/blink [email protected] 245.88 KB, unchanged
FastLED DemoReel100 [email protected] 692.64 KB, unchanged

Summary by CodeRabbit

  • Bug Fixes
    • Preserved source directories in include paths when their headers use #include_next, avoiding incorrect header lookup through merged directories.

On pioarduino 3.3.x (IDF 5.5) esp_assert.h does `#include "assert.h"`.
In the merged farm root newlib's platform_include/assert.h sits beside
it, so GCC finds it relative to the includer -- and restarts its
`#include_next <assert.h>` from the start of the chain, which lands on
the same header again and `#pragma once` drops it. The toolchain
assert.h never loads and every TU using assert() fails with
`implicit declaration of '__assert_func'`.

A block directory holding any `#include_next` header now keeps its own
-I (found via the search chain, as before the farm). Format version 2
rebuilds existing farms.

Fixes #1566. Part of #1559.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: FastLED/fbuild/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a367e9dc-4522-4ed8-9fa2-2de7450cdf6c

📥 Commits

Reviewing files that changed from the base of the PR and between 8f63d39 and 73eac5d.

📒 Files selected for processing (2)
  • crates/fbuild-build-engine/src/include_farm.rs
  • crates/fbuild-build-engine/src/include_farm_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The include farm now keeps a block directory outside the farm when a listed file contains an #include_next directive. The farm format version increases to 2. A regression test covers a quoted include of a sibling header.

Changes

Include farm planning

Layer / File(s) Summary
Detect and retain include_next directories
crates/fbuild-build-engine/src/include_farm.rs, crates/fbuild-build-engine/src/include_farm_tests.rs
plan_farm checks files in farmed directories for include_next and keeps a matching directory outside the farm. The format version changes from 1 to 2. A regression test checks the directory retention and resulting farm links.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 73eac

The change preserves separate include-search positions for headers using #include_next. No issue requiring a fix before merge was established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 73eac

The change keeps headers that depend on include-search order in their original directories and rebuilds incompatible cached farms. It does not appear to broaden which project or toolchain headers a build can reach. Some unusual cache and file-change conditions remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The established effect is limited to header resolution for the supplied ESP32 SDK include block and the builds that consume it; the source does not establish a broader tenant or service exposure.

Trust Boundaries and Controls

  • inferred — No new route from project-controlled include directories into the farmed SDK block is established: the caller selects the SDK range before adding project paths, and a range mismatch falls back to plain include paths. The trust classification of SDK package contents remains unverified.

Resilience and Maintainability Implications

  • inferred — Version separation and staged publication support recovery for stable inputs. Source mutation during planning or reuse, unreadable headers during scanning, and OS-crash durability remain outside the demonstrated guarantees; no evidence shows this PR newly worsens those conditions.

Hardening Proposals

  • proposed — Consider falling back to plain include paths when a listed header cannot be scanned, rather than treating a read failure as proof that it lacks include_next.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing #include_next headers from being placed in the header farm for ESP32 builds.
Linked Issues check ✅ Passed The PR implements the coding objectives in #1566. FORMAT_VERSION changes from 1 to 2, and the version is part of farm_key, so existing farms do not match and are rebuilt. plan_farm scans block f…
Out of Scope Changes check ✅ Passed The changed files are limited to include-farm planning and its regression tests. The format-version change supports the required farm rebuild. The test directly covers the failure mode in #1566. No un…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

fix(esp32): header farm breaks #include_next headers found beside a quoted include (pioarduino 3.3.x: __assert_func undeclared)

1 participant