fix(build): unbreak ESP32 sketch builds — gcc cwd/-o path consistency (closes #282)#283
Conversation
…ject_dir #282: every ESP32 sketch build on main has been failing in CI with `HWCDC.cpp: fatal error: opening dependency file tests/platform/esp32dev/.fbuild/build/esp32dev/quick/core/HWCDC_57cf.cpp.d: No such file or directory`. Root cause was a latent asymmetry in `compile_source`: when the CLI is invoked with a relative `project_dir` (which CI does -- `fbuild build tests/platform/esp32dev ...`), the relative output reaches `compile_source` and hits `zccache::compile_cwd_from_output` (which canonicalizes the workspace to absolute) paired with `zccache::path_arg_for_compile_cwd` (which short-circuits on relative paths and returns the raw relative string). gcc then ran with `cwd = absolute project_dir` plus a relative `-o`, resolving to a doubled path (`/.../fbuild/tests/platform/esp32dev/tests/platform/esp32dev/.fbuild/...`) whose `core/` parent was never `create_dir_all`'d -- so `-MMD -MF` failed. The bug landed weeks ago in #191/#193 but stayed hidden because the soldr build-cache restored `.o` files on every CI run, skipping the cold-compile dispatch path. The `setup-soldr@v0` floating tag picking up soldr 0.7.33 -> 0.7.42 changed the toolchain-cache hash, invalidated every prior `.o`, and the latent bug surfaced on every cold core/ source. Fix: at the top of `compile_source`, promote `source` and `output` to absolute paths via a small `absolute_from_cwd` helper (equivalent in intent to `std::path::absolute`, written by hand for the workspace MSRV that `clippy.toml` enforces at 1.75 -- the function is stable since 1.79). With absolute inputs, `compile_cwd_from_output` and `path_arg_for_compile_cwd` produce a consistent (cwd, `-o`) pair that joins back to the original physical file. Added unit tests: - `absolute_from_cwd_is_identity_on_absolute_paths` -- sanity. - `absolute_from_cwd_promotes_relative_paths` -- sanity. - `compile_path_contract_pairs_cwd_and_output_arg_for_282` -- the post-fix invariant: `cwd.join(out_arg)` resolves to the absolute output for any workspace under a `.fbuild` directory. End-to-end verification: the failing CI workflows (`Build ESP32 Dev`, ESP32-S3/S2/P4/C3/H2 and friends) exercise the relative-project_dir path on every push -- once green on this PR, that's the regression guarantee for the scenario. Closes #282. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR fixes build failures in cold-cache ESP32 compilation when ChangesCompilation Path Normalization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Two CI failures on PR #283 needed fixing: 1. `Reject .rs files over 1000 LOC` -- compiler.rs was at 1064, over the 1000-LOC repo gate. Extracted the entire `mod tests { ... }` block to a sibling `compiler_tests.rs` and wired it back via `#[cfg(test)] #[path = "compiler_tests.rs"] mod tests;`. compiler.rs drops to 668 LOC; tests file is 418 LOC. No behavior change. 2. `Check (macos-latest)` and `(windows-latest)` failed on the new `compile_path_contract_pairs_cwd_and_output_arg_for_282` regression test. Cause: `compile_cwd_from_output` canonicalizes its result (resolving `/var` -> `/private/var` on macOS, and adding then stripping the `\?\` extended-length prefix on Windows). The test's `abs_output` was built from the raw `tempfile::tempdir()` path, which differs from the canonicalized form -- so the final equality assertion compared two spellings of the same physical file. Fixed by normalizing the tempdir base up front: canonicalize, then strip the Windows `\?\` prefix, so both sides of the assertion stay on the same form `compile_cwd_from_output` produces. Local: `soldr cargo test -p fbuild-build --lib` -- 543 passed. Refs #282. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Every ESP32 sketch build on
mainhas been failing in CI since 2026-05-28 withHWCDC.cpp: fatal error: opening dependency file tests/platform/esp32dev/.fbuild/build/esp32dev/quick/core/HWCDC_57cf.cpp.d: No such file or directory(and the same forColorFormat.cand other frameworkcore/sources). Closes #282.Root cause: latent asymmetry in
compile_source. When the CLI is invoked with a relativeproject_dir(which CI does —fbuild build tests/platform/esp32dev ...), the relative output reachescompile_sourceand hitszccache::compile_cwd_from_output(which canonicalizes the workspace to absolute) paired withzccache::path_arg_for_compile_cwd(which short-circuits on relative paths and returns the raw relative string). gcc then ran with absolute CWD plus a relative-o, resolving to a doubled path (/.../fbuild/tests/platform/esp32dev/tests/platform/esp32dev/.fbuild/...) whosecore/parent was nevercreate_dir_all'd.The bug landed weeks ago (#191/#193) but stayed hidden because the soldr build cache restored
.ofiles on every CI run, skipping the cold-compile dispatch. Thesetup-soldr@v0floating tag picking up soldr 0.7.33 → 0.7.42 changed the toolchain-cache hash, invalidated every prior.o, and the latent bug surfaced on every cold frameworkcore/source.Fix
Promote
sourceandoutputto absolute paths at the top ofcompile_sourcevia a smallabsolute_from_cwdhelper (equivalent in intent tostd::path::absolute, hand-written because clippy enforces MSRV 1.75 and that function is stable since 1.79). With absolute inputs,compile_cwd_from_outputandpath_arg_for_compile_cwdproduce a consistent(cwd, -o)pair that joins back to the original physical file.Test plan
soldr cargo test -p fbuild-build --lib compiler::— 97 passed, 0 failed, including 3 new tests:absolute_from_cwd_is_identity_on_absolute_pathsabsolute_from_cwd_promotes_relative_pathscompile_path_contract_pairs_cwd_and_output_arg_for_282soldr cargo test -p fbuild-build --lib— 543 passed, 0 failed (no regressions).Build ESP32 Dev(and the other 5 currently-red ESP32 board workflows) pass on this PR — this is the regression guarantee for the actual CI scenario; once green, ESP32 sketch builds fail when project_dir is relative —compile_cwdvs-opath mismatch (missingcore/parent dir) #282 is verified end-to-end.Does NOT require pinning
zackees/setup-soldr— soldr can keep floating onv0.🤖 Generated with Claude Code
Summary by CodeRabbit