Skip to content

Modernization Phase 2.1: modules canary — streamr-eventemitter + streamr-json [iosbuild] - #29

Merged
ptesavol merged 1 commit into
mainfrom
modernize/2.1-canary
Jul 3, 2026
Merged

ptesavol merged 1 commit into
mainfrom
modernize/2.1-canary

Conversation

@ptesavol

@ptesavol ptesavol commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

The first C++ named modules in the codebase. Both canary packages now carry the exact façade shape the migration is built on (MODERNIZATION.md Part 2):

  • One .cppm partition per public header: the header is #included in the partition's global module fragment and its public names are re-exported with export using. GMF entities stay attached to the global module, which is what makes import and #include consumers ODR-safe to mix during the whole migration.
  • A primary interface unit (streamr.eventemitter, streamr.json) export imports the partitions — consumers write one import.
  • The packages flip INTERFACE → STATIC via streamr_add_module_library() (module interface units are compiled TUs).
  • The packages' own tests and the json example now use import — 73 of the 307 tests execute through modules. Everything else in the monorepo keeps #include with zero edits, as designed.

Gate results

Gate Result
Standalone package builds (BMIs + archive) ✅
export(TARGETS … CXX_MODULES_DIRECTORY …) smoke test (standalone/vcpkg path) ✅ — no fallback needed
Downstream find_package + #include consumer unchanged (streamr-utils standalone) ✅
Root tree full build + tests ✅ 307/307
clangd/lint canary ✅ — better than planned: clangd 22 lints import-using files via the CMake module maps; the planned lint-exclusion fallback was not needed
iOS cross-build of the module libraries this PR ([iosbuild])

Findings that shape the next phases

  1. import doesn't leak transitive std includes the way textual inclusion did — every flipped TU needs to include what it uses (the eventemitter test needed <list>/<tuple>; the example needed <string>). Each package flip will carry a small include-adding pass. A good hygiene side effect.
  2. One genuine clangd-modules quirk found: the constrained std::string(std::string_view) constructor template isn't resolved in import-using files (the compiler is fine with it; plain constructors work). Sidestepped in the example with the pass-by-value idiom; documented in MODERNIZATION.md as a watch-item.
  3. clangd's secondary diagnostic notes in import-using files can show module-expanded line numbers; primary locations are correct.
  4. Lint posture as planned: .cppm gets clang-format only (canary packages' lint.sh extended); headers remain the fully linted source of truth until consolidation.

Next

Phase 2.2: streamr-logger + streamr-utils — folly enters the global module fragment for the first time, and utils is the folly::coro coroutine canary.

🤖 Generated with Claude Code

…es (iosbuild)

First C++ named modules in the codebase, in the façade shape from
MODERNIZATION.md Part 2: one .cppm partition per public header (header
included in the global module fragment, names re-exported via export
using), a primary interface unit export-importing the partitions,
INTERFACE -> STATIC via streamr_add_module_library(), and the packages'
own tests + example flipped from #include to import.

- export(TARGETS ... CXX_MODULES_DIRECTORY ...) smoke test passed: the
  standalone-package export path carries module info.
- Downstream find_package + #include consumers build unchanged (GMF
  facade is ODR-safe as designed).
- Root tree: 307/307 tests green; 73 of them now execute through import.
- clangd canary better than planned: clangd 22 lints import-using files
  via the CMake module maps; no lint exclusions needed. .cppm files get
  clang-format (package lint.sh extended); one clangd-modules quirk
  (constrained string(string_view) ctor) documented and sidestepped.
- Flipped TUs now include what they use (import does not leak transitive
  std includes).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the docs label Jul 3, 2026
@ptesavol
ptesavol merged commit 71f0c3e into main Jul 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant