Repository navigation
Generate the module wrapper from clang's JSON AST, with a declarative export policy - #1
Merged
Merged
Conversation
… export policy Follow the mwrap generation principle (.agents/docs/2026-10-28-mwrap-module- wrapper-generation.md): the compiler computes the public surface, the generator only lists it, and nothing edits the result afterwards. - tools/ast_json.py: compile each bundle TU once with `clang++ -fsyntax-only -Xclang -ast-dump=json -Xclang -ast-dump-filter=boost` and stream the dump into a flat declaration table (delta-encoded loc.file tracking, implicit instantiations dropped and aliased to their template). The same compile is the syntax gate; libclang is gone. - tools/gen_exports.py: rebuilt on the JSON model; `--check` regenerates into a scratch copy and compares byte for byte; writes generated/meta/ api-surface.json and skipped.txt; verifies each facade's GMF against its bundle; cache entries survive pass-2 edge merges; --libs runs replay claims. - tools/export_policy.toml replaces the module-side patches, patches/final/, the programmatic .inc guards, tools/curated/ and the GMF/define overrides; every rule carries a reason. - src/*.cppm are hand-maintained facades; tools/apply_patches.py replays only the vendored upstream/boost patches (replaces reapply_hand_edits.py). - CI uses the clang++ pinned in .xlings.json (llvm 23.1.3) instead of a full LLVM archive; mcpp pin aligned to 2026.11.5.1. Validated locally: gen_exports --check clean; gcc 16.1 all-modules build and mcpp test 144/144; LLVM 23.1.3 groups A/B 144/144 each.
Collaborator
Author
代码审查报告(high 级别)共发现 10 个问题,按严重程度排序。审查期间没有构建或运行代码;导出丢失问题已通过对比重新生成的 修复某一项后,请勾选该项前面的复选框表示已解决。
概要
问题列表
更新: 5~8 已在 4ffac21 处修复。 |
…ps edge Generator (tools/gen_exports.py): - A using-declaration written `boost::...` injects its last segment into the enclosing namespace, like the `::` and `std::` forms (boost::range::formatted_range). - Enumerators of an unscoped enum are also indexed under the enclosing scope, so `using algorithm::token_compress_on;` resolves (boost::token_compress_on). - Injection dedup is keyed by (name, target): range's boost::join no longer swallows algorithm's boost::join, a different overload set. - check_facade requires each facade's `export import` block to cover its .deps edges; an edge a facade cannot take is declared in the policy's [<lib>.facade] omit-imports with a reason (range -> regex, scope -> core, sort -> range). Facades: add the 44 facades' missing .deps edges (algorithm regains boost::shared_ptr, boost::bind, ... through smart_ptr/bind/function). Policy: drop the atomic BOOST_HAS_INT128 guards the corrected injected names no longer match. Regenerated generated/. Tests: unit tests for the three generator fixes and the facade check; consumer assertions in tests/algorithm.cpp and tests/range.cpp (they fail on the previous commit).
4 tasks
…een; check for cache drift nightly - apply_patches: a missing git is a failed run, so the patch -p1 fallback is reachable; failures report both tools. - ast_json: while skipping an implicit instantiation, alias only nodes of its "inner" arrays, not the declarations listed in lookups. - gen_exports: gate and skip entries record every file clang read (its -MD dependency list) and are valid only while those files are unchanged; skip entries also record the first-wins ownership they were computed under and are valid only while it still holds. - verify-scripts: nightly cache-drift job compares cached, cold and committed generation, uploads the evidence, saves the cold cache and reports to a cache-drift issue; toolchain setup moves to a shared composite action.
…s on the driver line
- tests.yml: install `mcpp@$MCPP_VERSION` instead of the whole .xlings.json
manifest; its llvm pin is the generator's clang++, which the build legs
never use.
- gen_exports: the {stable key: decl} export index is built once per Model
(export_index) and shared by closure_from and collect_body_edges; the
closure's extra targets stay local to closure_from, so the output is
unchanged (cold --check up to date).
- gen_exports: the skip key hashes the clang driver line, as the gate key
does, so CXX and CLANG_NO_DEFAULT_CONFIG invalidate it.
- gen_exports: the gate key is computed by gate_key(lib, headers, policy), shared by parse_bundle and gen_audit; its value is unchanged. - gen_audit: each library's report and counts are cached in target/gen/exports-cache/<lib>.audit.json, keyed on the gate key, the generator's code and gen_audit.py itself, and valid only while every file clang read for it is unchanged. A hit skips the AST dump, so the audit no longer re-dumps every library after a fully skipped gen_exports --check.
- check_cache_drift: both passes also run gen_audit.py, and the linkage reports of the cached and cold runs must match. The reports are not committed, so a stale replay has nothing to be caught against on pull requests. Drift is reported with its diff and the affected .audit.json entries, and saves the cold cache like export drift does. - verify-scripts: comments name the audit cache.
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
Applies the mwrap generation principle (
.agents/docs/2026-10-28-mwrap-module-wrapper-generation.md): the compiler computes the public surface, the generator only lists it, and nothing edits the result afterwards. Design record:.agents/docs/2026-11-05-json-ast-generation.md.tools/ast_json.pycompiles each bundle TU once withclang++ -fsyntax-only -Xclang -ast-dump=json -Xclang -ast-dump-filter=boostand streams the dump into a flat declaration table. Geometry's filtered dump is 6.8 GB; the reader handles it in about 45 s at roughly 300 MB peak memory. It tracks clang's delta-encodedloc.fileand drops implicit instantiations, aliasing them back to their template. That one compile is also the syntax gate.patches/final/, the programmatic.incguards inreapply_hand_edits.py, andtools/curated/are replaced bytools/export_policy.toml: guard / drop / extra / add / gmf / facade-includes / inline-namespaces / deps rules, each with a written reason.generated/meta/skipped.txtlists every name a rule touches.generated/meta/api-surface.jsonrecords the generator identity (clang release, target, defines) plus per-library GMF, export count and edges.gen_exports.py --checkregenerates into a scratch copy, compares byte for byte, and verifies that each facade's GMF equals the bundle it was generated from. CI uses it instead of agit difforacle.src/*.cppm.tools/apply_patches.pyreplays only the vendoredupstream/boostpatches..xlings.json(llvm 23.1.3, installed by xlings) instead of downloading the LLVM release archive. Thetests.ymlmcpp pin is aligned to2026.11.5.1.Behavior changes
boost::filesystem::{absolute,canonical,equivalent,weakly_canonical}are exported under their documented spelling (previously missing). The same applies tompl_::*fromBOOST_MPL_AUX_ADL_BARRIER_DECL..depsgoes from 608 to 633 edges (no import cycles), and themcpp.tomldefault closure gainsbindandfunction.flyweight.inc,algorithm.inc/.depsandversion.depsare generated from policy rules instead of hand-maintained final forms.export importblocks are unchanged.Validation (local, x86_64 Linux)
gen_exports.py --checkclean;gen_features.py --checkcleanmcpp build --features all-modulesOK;mcpp test --features all-modules144/144mcpp testwith CI groups A and B, 144/144 each (the whole closure hits clang's known source-location limit)test_ast_json.py)🤖 Generated with Claude Code