Skip to content

feat(pkgs): add compat.spdlog 1.17.0 (header-only + declarative compi…#72

Merged
Sunrisepeak merged 2 commits into
mcpplibs:mainfrom
1115040131:feat/add-spdlog
Jul 15, 2026
Merged

feat(pkgs): add compat.spdlog 1.17.0 (header-only + declarative compi…#72
Sunrisepeak merged 2 commits into
mcpplibs:mainfrom
1115040131:feat/add-spdlog

Conversation

@1115040131

Copy link
Copy Markdown
Contributor

形态

header-only + source-gated feature(与 compat.eigen 同类)。spdlog 双模态:

  • 默认 header-only:自包含 —— bundled fmt 走 FMT_HEADER_ONLY,无需外部 fmt 依赖。
    common.h 在未定义 SPDLOG_COMPILED_LIB 时打开 SPDLOG_HEADER_ONLY,头文件末尾
    #include "*-inl.h" 把实现内联。
  • 预编译模态:compiled feature 声明 sources = {"*/src/*.cpp"} +
    SPDLOG_COMPILED_LIB interface define(该宏须同时到达库源与消费者头)。

mcpp 0.0.91 引擎限制(如实记录)

依赖包被激活 feature 的 sources 当前不编译,三重佐证:

实验 feature 现象
本包 compiled src/*.cpp 未编译 → 大量 undefined reference
compat.cjson utils cJSON_Utils.c 未编译 → undefined reference to cJSONUtils_*
compat.eigen eigen_blas blas/*.cpp 未编译 → undefined reference to dgemm_

feature 的 defines 确实传播到消费者(实测 -DSPDLOG_COMPILED_LIB 出现在消费者
TU 编译行)。故本 PR 的 CI 只断言 header-only 模态;compiled feature 待引擎支持
"编译并链接 feature sources"后无需改描述符即可生效(与 eigen_blas 同一 follow-up)。

feature 评估

未为 tweakme.h 的编译期开关(SPDLOG_USE_STD_FORMATSPDLOG_NO_SOURCE_LOC 等)
新增 feature:header-only 模态下 spdlog 全在头文件里随消费者 TU 编译,消费者可在自己的
mcpp.tomldefines/cxxflags 直接注入(更灵活,还能带值),做成 feature 属冗余。
唯一"消费者 -D 够不着、必须包侧统一注入"的是 SPDLOG_COMPILED_LIB,已由 compiled
feature 承载。详见设计文档。

CN 镜像

mcpp-res 写权限(本环境无 gitcode token),按 docs/cn-mirror.md 回退方案:
三平台 url 用纯字符串上游 GitHub release,lint 对纯字符串 url 不施加镜像约束。
先例:pkgs/t/tensorvia-cpu.lua。后续可由维护者补充 { GLOBAL, CN } 镜像表(sha256 不变)。

验证(mcpp 0.0.91,GLOBAL)

  • mcpp xpkg parse pkgs/c/compat.spdlog.luaparse OK(strict floor/grammar)
  • workspace 成员 mcpp test -p spdlogtest result ok. 1 passed
  • 全量本地 lint(等价 CI lint job)→ ALL LINT PASS
  • 负向语义:header-only 默认构建仅 spdlog_anchor.o(src 未默认编入);compiled 请求时
    消费者带 -DSPDLOG_COMPILED_LIB(define 门控生效)

设计文档:.agents/docs/2026-07-15-add-spdlog-plan.md

Test plan

  • CI lint 通过
  • CI workspace (linux/macos/windows) 的 spdlog 成员通过
  • mirror-cn-reachable 通过(spdlog 无需校验的 CN url)

1115040131 and others added 2 commits July 15, 2026 16:02
…led feature)

spdlog is dual-modal: default header-only (self-contained via bundled fmt in
FMT_HEADER_ONLY mode, no external fmt dep) and a precompiled mode gated on
SPDLOG_COMPILED_LIB. The `compiled` feature declares the correct intent
(sources = src/*.cpp + the SPDLOG_COMPILED_LIB interface define), but mcpp
0.0.91 does not yet compile a dependency's feature-gated sources — verified
three ways (this package, compat.cjson's utils, compat.eigen's eigen_blas all
leave feature sources uncompiled → link-time undefined reference). The feature's
`defines` DO propagate to the consumer. So CI asserts the fully-working
header-only mode; the compiled feature works unchanged once the engine links
feature sources (same follow-up as eigen_blas).

No CN mirror (no mcpp-res write access): plain-string upstream url per the
docs/cn-mirror.md fallback (tensorvia-cpu precedent).

Verified on mcpp 0.0.91 (GLOBAL): xpkg parse OK, `mcpp test -p spdlog` passes.
初版把「feature sources 不编译」判为引擎级限制,是**误判**:该 bug 只影响
`mcpp test` 路径,`mcpp build` 一直是好的(7 个 src TU 全进 build.ninja、
二进制真跑)。三重佐证(spdlog/cjson/eigen)现象属实,但三次都只走了 test
一条路径 —— 本仓 CI 是 workspace/test 模型。

真因(mcpp/src/build/prepare.cppm):feature 源集解析被整段门在
`!includeDevDeps`,test 模式跳过 → 激活 feature 的 sources 从不加回构建图;
叠加 xpkg 的 `features.X.sources` 只落进 featureSources、从不进 base sources。
已由 mcpp#218 修复并发布 0.0.94(drop 仍只在 build 模式,add 两模式都做+去重)。

- 描述符 Lua **一行未改** —— `compiled` feature 的建模本来就是对的;
  只把注释从「引擎不支持、请用 header-only」改为如实的「test 下需 ≥0.0.94」。
- 新增 workspace 成员 `tests/examples/spdlog-compiled/`:**compiled 模态进 CI**。
  静态断言 SPDLOG_COMPILED_LIB 已定义 + SPDLOG_HEADER_ONLY 未定义(退化回
  inline 路径是编译错误而非静默通过),再跑行为断言 —— 调用解析到
  default_logger_raw / log_msg ctor / logger::log_it_ / bundled fmt vformat
  等非 inline 符号,正是 feature sources 没编译时链不上的那批。
- CI pin 0.0.91 → 0.0.94;index floor `min_mcpp` 不动(它追踪描述符**语法**,
  本描述符在 0.0.87 上就能解析;header-only 模态任何版本都可用)。
- 修 `tests/examples/spdlog/mcpp.toml` 里 `pkgs/s/` 陈旧路径 → `pkgs/c/`。
@Sunrisepeak Sunrisepeak merged commit af923e5 into mcpplibs:main Jul 15, 2026
6 checks passed
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.

3 participants