Skip to content

fix(build-engine): reroot lowercases source spelling on macOS (2 full/macos tests red) #2048

Closed

Description

@zackees

full / macos / Check and full / macos / Test fail on every PR branch that has
merged current main, because a macOS-only case-folding bug in the merged
compile-database code emits a source spelling that is not the one on disk.

Evidence

Job full / macos / Test (macos-15) on run 44048154994 (branch
feat/ape-host-tools, head aa4f35fc, i.e. main 9b0892fd merged in — the
branch does not touch fbuild-build-engine):

compile_database::merge::merge_tests::reroot_spells_sources_relative_to_the_project
  assertion `left == right` failed
  left:  [..., "../opt/idf/components/freertos/freertos-kernel/tasks.c", ...]
  right: [..., "../opt/idf/components/freertos/FreeRTOS-Kernel/tasks.c", ...]

compile_database::merge::merge_tests::merge_adds_framework_entries_only_idf_compiled
  missing delegated entry ../opt/idf/components/freertos/FreeRTOS-Kernel/tasks.c

test result: FAILED. 572 passed; 2 failed

Linux is green at the same commit, so the test only diverges where the
filesystem is case-insensitive.

Root cause

crates/fbuild-build-engine/src/compile_database/merge.rs, relative_spelling:

let path_key = normalize_for_key(path);   // = platform::fs::comparison_key(normalize(path))
let base_key = normalize_for_key(base);
...
parts.extend(path[common..].iter().map(|c| c.as_os_str().to_string_lossy().into_owned()));

The relative path is built out of the case-folded comparison keys, so the
emitted file/output spelling inherits the folded case. On macOS/Windows
comparison_key lowercases, so FreeRTOS-Kernel/tasks.c is written out as
freertos-kernel/tasks.c. The key is right; the spelling is wrong, and a
compile database is read by tooling (IDE indexers, replay) that opens those
paths — on a case-sensitive APFS volume it would not resolve at all.

Fix sketch

Keep two parallel component vectors — the key components for prefix matching
and the original components for emission — and join the original spelling of
path[common..]. Same for base.len() - common (only the .. count is used,
so that half is already spelling-independent). Add a unit test that pins the
spelling: assert reroot never changes the case of a component it did not
resolve.

Filed from the steward tick that resolved PR #1633's merge conflict; this is
the only thing keeping that branch's macOS cells red.

Activity

  1. added
    bug
    priority: p2
    priority: p1
    and removed
    priority: p2
    on Nov 17, 2026
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

    bugpriority: p1

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions