Skip to content

build: per-sanitizer build dirs to avoid reconfigure churn#22

Closed
battlesnake wants to merge 1 commit into
RedFox20:masterfrom
battlesnake:feat/sanitizer-build-dirs
Closed

build: per-sanitizer build dirs to avoid reconfigure churn#22
battlesnake wants to merge 1 commit into
RedFox20:masterfrom
battlesnake:feat/sanitizer-build-dirs

Conversation

@battlesnake
Copy link
Copy Markdown
Collaborator

Problem

All sanitizer flavors write to the same platform build dir (packages/<pkg>/linux, windows, …). self.sanitize isn't part of the build path, so switching between asan / tsan / ubsan / none reuses one dir with a different sanitizer than it was configured for. run_config() then sees the sanitizer marker changed and forces a full CMake reconfigure every switch — slow, and occasionally a stale-mix build failure.

Fix

Suffix the build dir per sanitizer, reusing the existing CLI short tokens:

--sanitize dir
(none) linux (unchanged)
address linux-asan
thread linux-tsan
undefined linux-ubsan
leak linux-lsan

(and the same for every platform: windows-asan, android-tsan, …)

One build_dir_suffix() helper, applied in the two places that pick the per-platform name: platform_build_dir_name() and dependency_chain._save_mama_cmake's get_build_dir_defines (kept in sync per the existing WARNING comment, so dependency mama.cmake include paths match the suffixed dep dirs). No sanitizer ⇒ no suffix ⇒ existing caches stay valid. Each flavor now keeps its own dir + CMakeCache.txt, so switching between already-built flavors no longer reconfigures.

Verification

Added tests/test_build_dir/ asserting the per-sanitizer names and that no-sanitizer is unchanged. Full existing suite (85 tests) green.

Ran the patched mama against a throwaway CMake project: build asan then build tsan create separate linux-asan / linux-tsan dirs with the right enabled_sanitizers; re-running each already-built flavor skips CMake configure (no churn); plain build still uses linux.

Back-compat note

First build of each sanitizer flavor after upgrading mama configures once into its new suffixed dir (the old shared linux dir keeps the no-sanitizer build). Expected, one-time.

All sanitizer flavors shared one platform build dir (eg 'linux'), so
switching asan<->tsan<->none forced a full CMake reconfigure (and the
occasional stale-mix build failure). Suffix the build dir per sanitizer
('linux-asan', 'linux-tsan', 'linux-ubsan', 'linux-lsan') in the two
funnels that pick it. No sanitizer keeps the old name, so existing
caches stay valid; first build of each flavor after upgrade configures
once into its new dir.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@battlesnake
Copy link
Copy Markdown
Collaborator Author

Superseded by #23 — moved off the fork to a branch on this repo, and adds coverage build-dir separation.

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