Skip to content

exports: restore or explain the remaining names of #2; check the reachable export set in CI - #11

Merged
ZheFeng7110 merged 3 commits into
mcpplibs:mainfrom
ZheFeng7110:fix/reachable-exports
Nov 29, 2026
Merged

ZheFeng7110 merged 3 commits into
mcpplibs:mainfrom
ZheFeng7110:fix/reachable-exports

Conversation

@ZheFeng7110

Copy link
Copy Markdown
Collaborator

Closes #2. Follows #9 and #10: the third and fourth acceptance criteria, i.e. the small groups that were not analysed and the reachable-export check in verify-scripts.

Problem

Measured per module against 99533232 (main before #1), 72 (module, name) pairs (37 names) outside the three detail groups of #10 were still lost at the modules they came from: #2's small groups, plus nine names #5 lost afterwards with verify-scripts green (boost::size, three of cobalt's main.hpp, five of geometry's boost_fusion.hpp).

Most of them have one cause. The pre-#1 generator keyed entities by libclang USR, and a specialization named in a signature has its own USR (function<int(int)> is c:@N@boost@S@function>#FI(#I), the primary is c:@N@boost@ST>1#T@function), so it was taken for an unclaimed entity and its name was exported again. I confirmed this by running the old closure_from on a synthetic TU. Since #1 a name belongs to the first module that claims it, and the accidental duplicates are gone. The question per name is therefore who should own it and whether the module's dependency on it is real.

Criterion 3: each small group

names lost by result
boost::function functional (and accumulators, bimap, multi_array, numeric through it) restored: functional imports function
assignable_archetype, copy_constructible_archetype, null_archetype regex restored: concept_check owns boost/concept_archetype.hpp
boost::call_traits wave restored: utility owns boost/call_traits.hpp; variant imports utility
boost::mpl ×14, mpl::aux ×2 13 modules explained
boost::parameter ×4 accumulators, graph, heap, lockfree explained
fusion::deque hana explained
container::(make_)transform_iterator interprocess explained
cobalt::main, main_promise, signal_helper cobalt explained (documented in usage.md §6 already, but not in skipped.txt)
fusion_adapt_detail ×3, mpl::count_if, mpl::aux::next_if geometry explained (same)
boost::size core was already a drop, now recorded as boost::size instead of std::size
  • Restored names are documented API of a library that has a module. overloaded_function's constructor takes boost::function; the archetypes are Boost.ConceptCheck's and call_traits is Boost.Utility's, and those two modules did not export them at all, because the first library to include the header (iterator, variant) claimed them. Upstream's CMake links functional → function and variant → utility as well.
  • MPL, Parameter and Fusion are include-only (usage.md §2.3), so no module owns their names. I searched all of libs/<lib> (documentation, examples, tests) of the official 1.92.0 archive (pinned SHA-256) for each of these 56 pairs. Two matched: accumulators' reference shows parameter::keyword as the type of static members, and hana's Fusion example, which includes <boost/fusion/...> itself.
  • Two statements in 生成器:using namespace 注入收窄后,boost::dll::fs 等名称对模块使用者不可达 #2 are out of date: mpl::aux::template_arity and mpl::order_impl have no skipped.txt entry, and flyweight's drop of the parameter names does not explain why heap, lockfree and graph lost them.

The explanations are a new policy rule, [[unreachable]] (reason, names = {name = [module, ...]}). It only writes <lib> unreachable <name> -- <reason> lines to skipped.txt.

Criterion 4: tools/ci/check_reachable.py

verify_generated.py runs it after gen_exports.py --check, on all three hosts. It compares what each module's importers reach (its own .inc plus everything it export imports) with two baselines: 99533232, and the CI base (merge base of a pull request, previous head of a push), so a name added after #1 is protected as well. A lost name must be explained in skipped.txt:

  • Matched per (module, name). An entry speaks for its own module only. A module that exported the name itself, or that stopped importing a module that still has it, needs its own entry. One that only inherited the loss is covered by the module it came from.
  • skip-directive covers only the spelling through the directive: <ns>::X may go only while <target>::X is still reachable. skipped.txt names the target for this.
  • A stale unreachable entry (the module does reach the name) is an error, and so is a module that disappeared.

Not seen by the check: names declared in src/*.cppm itself, what is behind a name, and the #if around an export (guards have their own skipped.txt lines).

Output

No module loses a name compared with main. 74 archetype names move from iterator to concept_check, 3 from variant to utility. New edges: functional → function, variant/bimap/serialization → utility. mcpp.toml implies follows. algorithm.deps loses its direct function edge, which is now transitive (range → functional); its facade still imports function.

Rejected

  • A drop no longer claims names no library owns (flyweight's drop keeps boost::parameter names out of every later module). I generated it: heap gets its three names back, lockfree and graph still cannot reach them, and heap and statechart additionally export 57 implementation details.
  • Exempting boost::mpl / boost::parameter by namespace: the next loss there would be silent again.

More in the design record, .agents/docs/2026-11-29-reachable-exports-design.md.

Side finding (not addressed)

The include edges do not read a library's own detail/ headers. Going by the transitive closure, 56 such edges are in no .deps (e.g. numeric → units, gil → filesystem). Whether an importer needs each one has to be looked at separately.

Verified locally

  • tools/ci/verify_generated.py end to end (patch replay, gen_exports.py --check with every library regenerated, the new check, gen_features.py --check, the audits).
  • tools/tests: 76 tests, 19 new.
  • mcpp test with group A's features: gcc@16.1.0 417/417, llvm@22.1.8 417/417.
  • New assertions in tests/{functional,concept_check,utility}.cpp and tests/regex/smoke.cpp fail to compile against main's exports (llvm); the one in tests/variant.cpp passes on both and keeps call_traits reachable after the move.
  • The check's failing paths on copies of the real tree: a removed export import, a removed dll::fs name, a removed unreachable line, the removed core drop, a stale entry, ublas::matrix removed from numeric, a removed module. Each is reported at the right module. On Module test hardening: tests/<lib>/ suites, conversion module, export fixes #5's tree it reports 912 unexplained losses.
  • Not run locally: group B's feature set, tests/dll and tests/test/utf, Windows and macOS (CI).

…chable

Restored:
- functional imports function: overloaded_function takes its targets as
  boost::function. The edge was invisible to the generator (partial
  specializations, includes inside the library's own detail/ headers).
- concept_check owns boost/concept_archetype.hpp (regex reaches the
  archetypes again; concept_check exports them for the first time).
- utility owns boost/call_traits.hpp (wave reaches call_traits again); variant
  imports utility for it.

Declared, with the reason, by the new policy rule [[unreachable]] and listed
in skipped.txt: names of include-only libraries (MPL, Parameter, Fusion) that
the pre-#1 generator listed again for every specialization it met, two
Container implementation details, and the names of the headers cobalt and
geometry leave out.

skipped.txt also names the target of each skip-directive, and a drop by the
spelling an importer loses (boost::size, not std::size).
…reason

gen_exports.py --check proves the committed lists are what the generator
writes; it cannot see that they lost names (mcpplibs#5 lost nine with verify-scripts
green). check_reachable.py compares what each module's importers reach with
9953323 (main before #1) and with the CI base. A lost (module, name) pair
must be explained in skipped.txt by the module it went from: a drop, an
unreachable, or a skip-directive whose target still has the name. An entry for
a name the module does reach is an error. verify_generated.py runs it.
@ZheFeng7110
ZheFeng7110 merged commit 27b135c into mcpplibs:main Nov 29, 2026
20 checks passed
@ZheFeng7110
ZheFeng7110 deleted the fix/reachable-exports branch November 29, 2026 14:09
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.

生成器:using namespace 注入收窄后,boost::dll::fs 等名称对模块使用者不可达

1 participant