Skip to content

Add header dependency tracking to the Makefile - #22

Open
pangin wants to merge 1 commit into
niellun:mainfrom
pangin:fix/makefile-header-deps
Open

Add header dependency tracking to the Makefile#22
pangin wants to merge 1 commit into
niellun:mainfrom
pangin:fix/makefile-header-deps

Conversation

@pangin

@pangin pangin commented Aug 27, 2026

Copy link
Copy Markdown

Bug

The object pattern rule compiles without generating dependency files, so make only knows that each .o depends on its .cpp. Editing a header rebuilds nothing that includes it.

Symptom

After changing a class layout in a header (e.g. adding a member), an incremental build links stale objects compiled against the old layout together with fresh ones using the new layout. The result is silent memory corruption at runtime — we hit it as "stack smashing detected" and random segfaults while porting FastCarPlay to a Raspberry Pi Zero W (ARMv6) head unit, and it was very hard to trace back to the build system. make clean "fixes" it, which is the tell.

Fix

Compile with -MMD -MP so the compiler emits a .d makefile per object listing every header it includes, and -include $(OBJS:.o=.d) to feed those back into make. Touching a header now rebuilds exactly the objects that include it. First builds are unaffected; the .d files live in the existing per-build-type object tree and are removed by clean.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant