feat: parameterize BMI paths for Clang module pipeline parity#34
Merged
Conversation
Introduce BmiTraits abstraction (model.cppm) that encapsulates the
differences between GCC and Clang module compilation:
- BMI directory name (gcm.cache vs pcm.cache)
- BMI file extension (.gcm vs .pcm)
- Whether -fmodule-output= is needed (Clang: yes)
- Whether -fprebuilt-module-path= is needed (Clang: yes)
- Whether -fmodules is needed for P1689 scan (GCC: yes, Clang: no)
Changes across the pipeline:
- ninja_backend: remove is_gcc gate on dyndep, parameterize bmi_path
lambda, add -fmodule-output=$bmi_out for Clang in cxx_module rule,
conditionally emit -fmodules in cxx_scan, pass --bmi-dir/--bmi-ext
to cxx_dyndep and cxx_collect rules
- flags: add -fprebuilt-module-path=<bmiDir> for Clang
- dyndep: add DyndepOptions, parameterize bmi_basename extension and
directory in emit_dyndep/emit_dyndep_single/emit_dyndep_from_files
- cli: cmd_dyndep parses --bmi-dir/--bmi-ext and passes DyndepOptions
Rename gcmFiles→bmiFiles, gcmDir()→bmiDir(), add bmiDirName/manifestTag fields to CacheKey. Manifest format now uses the tag from CacheKey (gcm: or pcm:) and parsing accepts both prefixes for forward compat. Callers set bmiDirName/manifestTag via BmiTraits from PR1.
- Restore is_gcc gate on dyndep (Clang lacks -fdeps-format=p1689r5; needs clang-scan-deps for P1689, future work) - Fix static-deps path: use implicit output (|) for BMI files so $out only contains the .o file; set $bmi_out for all compilers (GCC ignores it, Clang uses it for -fmodule-output) - Add E2E test 38_llvm_modules.sh: multi-module Clang project with export module + cross-module import, verifying pcm.cache/ layout
Clang lacks GCC's -fdeps-format=p1689r5 compiler flag but ships
clang-scan-deps which produces identical P1689 JSON output per-file.
Changes:
- plan.cppm: add scanDepsPath field to BuildPlan
- clang.cppm: add find_scan_deps() helper
- cli.cppm: discover clang-scan-deps in compiler's bin/ directory
- ninja_backend.cppm: enable dyndep when scanDepsPath is available,
emit Clang-specific cxx_scan rule using clang-scan-deps with
-format=p1689 and stdout redirection to .ddi file
This gives Clang the same per-file incremental rebuild capability
that GCC has had via the dyndep pipeline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BmiTraitsabstraction inmodel.cppmthat encapsulates GCC vs Clang module compilation differences (BMI dir/ext, flags needed)is_gccgate on dyndep — Clang 18+ supports P1689 with the same flagsbmi_pathlambda,bmi_basename(), and dyndep emit functions to useBmiTraitsinstead of hardcodedgcm.cache/*.gcm-fmodule-output=$bmi_outtocxx_modulerule for Clang (GCC writes BMI implicitly, Clang needs explicit flag)-fprebuilt-module-path=<bmiDir>to cxxflags for Clang--bmi-dir/--bmi-extthroughcxx_dyndep/cxx_collectNinja rules tomcpp dyndepsubcommandThis is the first of 3 PRs to bring Clang module support to GCC parity on Linux. Design doc:
.agents/docs/2026-05-15-clang-parity-and-toolchain-abstraction.mdTest plan
mcpp buildcompiles successfullymcpp test— all 12 test suites, 104 tests pass