Skip to content

Modernization Phase 2.6: Part 2 closeout — consolidation memo, NDK r29 modules experiment [androidbuild] - #34

Merged
ptesavol merged 7 commits into
mainfrom
modernize/2.6-part2-closeout
Jul 4, 2026
Merged

ptesavol merged 7 commits into
mainfrom
modernize/2.6-part2-closeout

Conversation

@ptesavol

@ptesavol ptesavol commented Jul 3, 2026 •

Copy link
Copy Markdown
Collaborator

Closeout of Part 2 — and the consolidation decision, which is yours to make. (This PR grew one substantive fix along the way: the Android modules blocker turned out not to be a blocker at all — see below.)

The Android resolution (found while closing out)

The Phase 2.5 Android failure (import streamr.json → every imported name "undeclared") was not an NDK-clang capability gap. Reproducing the CI build locally against NDK r27/r28/r29 showed all three raw compilers (clang 18/19/21) build and import the façade modules correctly. The real cause, always truncated out of the CI annotation tail: a -pthread BMI configuration mismatch — test TUs compile with -pthread (inherited from GTest's Threads::Threads), the module libraries' BMIs were built without it, and on Android clang validates that language option when loading a module file (-Wmodule-file-config-mismatch), so the BMI silently fails to load and every imported name cascades to "undeclared". Only the thread-less leaf packages (json, eventemitter) could mismatch — the folly-linking packages already inherited -pthread into their BMIs.

Fixes in this PR:

  • StreamrModules.cmake helpers make -pthread a PUBLIC compile option on Android (genexpr; no-op elsewhere) so BMIs and importers always agree.
  • The Android STREAMR_MODULES_SUPPORTED floor drops from clang 21 to clang 18 (= NDK r27, oldest verified); textual fallback below that.
  • protobuf-streamr-plugin (host codegen tooling) gets its own NOT CMAKE_CROSSCOMPILING guard — it was only ever skipped on Android as a side effect of the modules gate being OFF.
  • The Android workflow keeps building with the runner's latest stable NDK (r29 = clang 21) — hygiene, no longer a modules requirement.

Result: the androidbuild leg on this PR builds the full monorepo — all 7 module packages, tests included — for arm64-android with modules ON. Android is no longer a consolidation blocker.

The decision memo (now in MODERNIZATION.md)

The planned Phase 2.6 — move all code into module purview, delete every internal header — remains gated by two preconditions (the third is resolved above):

  1. A modules-capable NDK on Android RESOLVED in this PR.
  2. clangd can lint purview code (today it can't — and consolidated code would have no header fallback for the linter, so coverage would regress from full to none).
  3. dht's include cycles become a partition DAG.

Recommendation: defer, and treat the façade stage as the stable resting point — now purely on lint-coverage grounds (2) plus the dht untangling (3). Nothing rots by waiting: headers stay the linted source of truth on every platform, and consolidation resumes leaf-first (eventemitter canary, measured per package) when clangd's modules support matures. If you'd rather trade lint coverage for the incremental-build wins now, say so and I'll re-plan.

Also in this PR

  • Final ClangBuildAnalyzer trace — the third success metric is met: DhtRpc.pb.h fell from First test of CI #1 (96 s, 33 inclusions) to Module1 #9 (15.7 s, 6 inclusions); SLogger.hpp/Logger.hpp left the expensive-headers list entirely; the new First test of CI #1 is gtest.h, which stays #include by design. Total frontend parse CPU: 859 s → 723 s (−16 %) even with the module units added.
  • README: developer documentation for the modules (import rules, the sibling-import rule, the direct-link rule, the Android -pthread note).
  • The stale "No C++ modules in the codebase yet" comments updated in all 9 CMakeLists (comment-only).
  • The 2.5 section's Android record corrected honestly (what we believed then vs. what was true).

Part 2 final scorecard

Success metric Verdict
Clean build −25 % ✅ −24 % (effectively met)
Expensive headers: pb.h/folly leave the top ✅ met decisively
Incremental −40 % ❌ requires consolidation (quantified why)

Part 1 (toolchain) + Part 2 façade stage are complete: LLVM 22 + libc++ everywhere, vcpkg 2026.06, iOS 26 device-verified, 7 packages shipping modules on macOS/Linux/iOS and Android, 250+ tests through import, all four platform gates green, and a measured, honest record of every decision in MODERNIZATION.md.

🤖 Generated with Claude Code

…s, final trace

- MODERNIZATION.md: Phase 2.6 rewritten as a DECISION MEMO. The planned
  consolidation (code into purview, internal headers deleted) is BLOCKED
  by the 2.5 Android finding: the NDK's clang cannot build the modules
  and Android compiles the libraries textually from exactly the headers
  consolidation would delete. Preconditions documented (NDK clang >= 22
  or Android parked; clangd purview-lint maturity; dht partition DAG),
  along with what consolidation buys (the unmet incremental targets) and
  the recommended leaf-first measured path when unblocked. The facade
  stage is a stable resting point.
- Final ClangBuildAnalyzer trace recorded: DhtRpc.pb.h fell from #1
  (96s, 33x) to #9 (15.7s, 6x); SLogger/Logger left the expensive list
  entirely; new #1 is gtest.h (stays #include by design); total parse
  CPU 859s -> 723s. The third success metric is met.
- README: C++ named modules developer documentation (import rules,
  sibling-import rule, direct-link rule, Android exception).
- Stale 'No C++ modules in the codebase yet' comments updated in all 9
  CMakeLists.
- 2.5 section extended with the Android saga (folly supports overlay;
  STREAMR_MODULES_SUPPORTED fallback; Android workflow lint removal).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… (androidbuild)

Owner review catch: the 2.5 Android modules failure was on the CI
runner's DEFAULT NDK r27.3 (clang 18.0.2), not the latest stable. NDK
r29 (Oct 2025) ships clang 21, whose modules support should handle the
facades. The Android workflow now selects ANDROID_NDK_LATEST_HOME (r29,
preinstalled on macos-26 runners), and STREAMR_MODULES_SUPPORTED on
Android is version-gated (NDK clang >= 21 -> modules ON, incl. building
the import-using test targets as a compile smoke; older NDKs fall back
to the textual build). This PR's androidbuild leg is the validation run;
if green, the consolidation memo's Android precondition is already
satisfiable today.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the ci Pull requests that update Continuous Integration build label Jul 3, 2026
@ptesavol ptesavol changed the title Modernization Phase 2.6: Part 2 closeout — consolidation decision memo, modules docs, final trace Modernization Phase 2.6: Part 2 closeout — consolidation memo, NDK r29 modules experiment [androidbuild] Jul 3, 2026
ptesavol and others added 3 commits July 4, 2026 00:59
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… (androidbuild)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Phase 2.5 Android failure (import streamr.json -> every imported
name "undeclared") was root-caused by reproducing the CI build locally
against NDK r27/r28/r29: the import-using test TUs compile with
-pthread (inherited from GTest's Threads::Threads) while the module
libraries' BMIs were built without it. On Android -pthread toggles a
language option clang validates when loading a module file
(-Wmodule-file-config-mismatch), so the BMI silently fails to load and
every imported name cascades to "use of undeclared identifier". The
raw NDK compilers (clang 18/19/21) all build and import the facade
modules correctly.

- StreamrModules.cmake helpers: make -pthread a PUBLIC compile option
  on Android (genexpr, no-op elsewhere) so BMIs and importers agree.
- Lower the Android STREAMR_MODULES_SUPPORTED floor from clang 21 to
  clang 18 (= NDK r27, oldest verified); textual fallback below that.
- Verified locally: streamr-json + streamr-eventemitter full package
  builds (tests + examples) green for arm64-android on NDK r27 and r29.
- validateandroid.yml: keep the latest-stable-NDK step (hygiene, no
  longer a modules requirement); comment updated.
- MODERNIZATION.md: 2.5 record corrected, 2.6 memo precondition 1
  marked RESOLVED; README Android note updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 3, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

With Android modules enabled, the proto-rpc test/example block now runs
on Android builds and exposed protobuf-streamr-plugin: it links
protobuf::libprotoc, which vcpkg does not provide for cross targets.
The plugin is host tooling (proto.sh codegen) and was only ever skipped
on Android as a side effect of the modules gate being OFF there. Give
it its own cross-compile guard, independent of modules support.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 3, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@ptesavol
ptesavol merged commit 6e6eeaf into main Jul 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Pull requests that update Continuous Integration build dht docs logger network proto-rpc utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant