Skip to content

feat(pkgs): add Eigen 5.0.1 (compat, header-only) + CN mirror#50

Merged
Sunrisepeak merged 2 commits into
mainfrom
feat/eigen
Jun 28, 2026
Merged

feat(pkgs): add Eigen 5.0.1 (compat, header-only) + CN mirror#50
Sunrisepeak merged 2 commits into
mainfrom
feat/eigen

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

参考 #48,收录最新 Eigen 5.0.1(libeigen/eigen,GitLab,已跨入 5.x 大版本)为 compat 包,并补 GitCode CN 镜像。

改动

  • pkgs/c/compat.eigen.lua — Eigen 5.0.1,header-onlyinclude_dirs={"*"} 暴露源码根目录,
    #include <Eigen/Dense> 开箱即用;trivial anchor TU 提供可构建的 lib 目标(同 compat.opengl/compat.khrplatform)。
    稳定 Eigen/ 与实验 unsupported/Eigen/ 模块均从同一根目录可达(实测 MatrixFunctions + AutoDiff 可编)。
  • CN 镜像 mcpp-res/eigen(GitCode)— 与 GitLab 归档 byte-identical(sha256 e9c326dc…,http 200)。
  • tests/examples/eigen/ — 最小工程(2×2 线代往返:A*x / determinant / dot / QR solve),接入按改动库选跑 CI。
  • README — 「第三方 C/C++ 库」表新增 eigen

关于 feature 机制(用户要求评估)

经核实 mcpp 0.0.68 源码:包描述符的 features只能门控 sources。Eigen 是 header-only,
没有可门控的可选源码;其天然可选轴 unsupported/ 与稳定核 同处 tarball 根,任何暴露核的 include path
都会一并暴露它(无法用 sources-only 的 feature 把头藏起来)。其它开关(EIGEN_MPL2_ONLY 等)是编译 define,
feature 表亦不能携带。故本期暴露完整头集、不加 feature,并在 descriptor 注释 + 设计文档完整记录分析;
待 mcpp 支持 define-capable feature 后,mpl2only 是干净接入点。详见
.agents/docs/2026-06-28-add-eigen-plan.md

本地验证(mcpp 0.0.68,与 CI 同版本)

  • MCPP_INDEX_MIRROR=GLOBAL tests/run_example.sh eigeneigen ok=1 y=[3 7] det=-2 dot=5,OK: eigen
  • unsupported/ 可达性:g++ -std=c++23 -I<root><Eigen/Dense> + <unsupported/Eigen/MatrixFunctions> + <AutoDiff> → rc=0。
  • 全量 lint 本地模拟通过;CN/GLOBAL sha 一致、CN 200;GitLab 归档 sha 两次稳定。

- compat.eigen @5.0.1 — latest Eigen (libeigen/eigen on GitLab; 5.x line).
  Header-only: include_dirs={"*"} exposes the source root so `#include
  <Eigen/Dense>` works out of the box; a trivial anchor TU gives mcpp a
  buildable lib target (same shape as compat.opengl/khrplatform). Both the
  stable `Eigen/` modules and the experimental `unsupported/Eigen/` modules
  resolve from the single root (verified: MatrixFunctions + AutoDiff compile).
- CN mirror mcpp-res/eigen (GitCode), byte-identical to the GitLab archive
  (sha256 e9c326dc…, http 200).
- feature mechanism: deliberately NOT used — analysis recorded in the
  descriptor + design doc. mcpp 0.0.68 features gate sources only; Eigen is
  header-only with no gateable source, and `unsupported/` shares the include
  root with core so it can't be hidden behind a sources-only feature. Eigen's
  other knobs (EIGEN_MPL2_ONLY, …) are compile defines the feature table can't
  carry. Documented for a future define-capable feature gate.
- tests/examples/eigen/ minimal project (2x2 linear-algebra round-trip), wired
  into the per-package CI selector (detect → smoke-examples (eigen)).

Verified locally on mcpp 0.0.68 (CI version, MCPP_INDEX_MIRROR=GLOBAL):
`tests/run_example.sh eigen` → `eigen ok=1 y=[3 7] det=-2 dot=5`.

Design: .agents/docs/2026-06-28-add-eigen-plan.md
Correcting the earlier "BLAS needs Fortran, too heavy → no feature" call: it
was wrong. Eigen's `eigen_blas` library (blas/CMakeLists.txt EigenBlas_SRCS)
builds from blas/*.cpp (5 files) + blas/f2c/*.c (18 f2c-translated C files);
the only .f files live under blas/testing/ (the test suite) and are NOT part
of the library. So it compiles with a plain C/C++ toolchain and fits mcpp's
sources-only feature gate exactly like compat.cjson's `utils`.

- compat.eigen: add `features = { blas = { sources = {"*/blas/*.cpp",
  "*/blas/f2c/*.c"} } }`. Off by default; `features = ["blas"]` compiles
  Eigen's reference BLAS into the eigen lib, exposing the standard Fortran-ABI
  symbols (sgemm_/dgemm_/ddot_/…).
- example now opts into `blas` and calls dgemm_ to exercise the feature in CI
  alongside the header-only core path.

Verified on mcpp 0.0.68:
- with feature: `eigen ok=1 core=1 blas(dgemm)=1 C=[1 3 2 4]`.
- without feature (negative): `undefined reference to 'dgemm_'` — gate works.

Descriptor comment + design doc updated with the corrected analysis.
@Sunrisepeak Sunrisepeak merged commit a240c7f into main Jun 28, 2026
6 checks passed
Sunrisepeak added a commit that referenced this pull request Jun 28, 2026
Codifies the full process used for cjson/nlohmann/eigen into a reusable skill
under .agents/skills/add-mcpp-index-package/:
- SKILL.md — 12-step SOP, the sources-only feature gate (+ mandatory negative
  test), version-matched local verification, red-flags/common mistakes.
- package-types.md — descriptor templates for the four shapes (C-source
  compat / header-only / C++23 module via generated wrapper / external Form-A
  module repo), each with real sample paths.
- cn-mirror.md — gtc/gitcode mcpp-res mirror closed loop + every known gotcha.
- references.md — repo layout, descriptor schema cheat-sheet, validate.yml CI
  behavior, one-shot local lint, real worked examples (#48 / #50).
Sunrisepeak added a commit that referenced this pull request Jun 28, 2026
Codifies the full process used for cjson/nlohmann/eigen into a reusable skill
under .agents/skills/add-mcpp-index-package/:
- SKILL.md — 12-step SOP, the sources-only feature gate (+ mandatory negative
  test), version-matched local verification, red-flags/common mistakes.
- package-types.md — descriptor templates for the four shapes (C-source
  compat / header-only / C++23 module via generated wrapper / external Form-A
  module repo), each with real sample paths.
- cn-mirror.md — gtc/gitcode mcpp-res mirror closed loop + every known gotcha.
- references.md — repo layout, descriptor schema cheat-sheet, validate.yml CI
  behavior, one-shot local lint, real worked examples (#48 / #50).
Sunrisepeak added a commit that referenced this pull request Jun 28, 2026
* docs(skills): add `add-mcpp-index-package` agent skill (SOP)

Codifies the full process used for cjson/nlohmann/eigen into a reusable skill
under .agents/skills/add-mcpp-index-package/:
- SKILL.md — 12-step SOP, the sources-only feature gate (+ mandatory negative
  test), version-matched local verification, red-flags/common mistakes.
- package-types.md — descriptor templates for the four shapes (C-source
  compat / header-only / C++23 module via generated wrapper / external Form-A
  module repo), each with real sample paths.
- cn-mirror.md — gtc/gitcode mcpp-res mirror closed loop + every known gotcha.
- references.md — repo layout, descriptor schema cheat-sheet, validate.yml CI
  behavior, one-shot local lint, real worked examples (#48 / #50).

* docs(readme): slim down to intro + usage + contribution + links

Drop the package tables/dependency tree/smoke breakdown/Form-A-B examples from
the index README — the browsable site (mcpplibs.github.io/mcpp-index) is the
package list, and the how-to detail lives in the add-mcpp-index-package skill.
README now = what it is, mcpp add/build usage, the two package categories
(native module libs / third-party compat) with a pointer to the skill, and
related tools / community.

* docs: add docs/, README example table + agent prompt; skill mirror fallback

- Move the skill's reference files into a human-facing docs/ folder (single
  source): package-types.md, cn-mirror.md, repository-and-schema.md (+ index
  docs/README.md). SKILL.md now links to ../../../docs/*; the skill dir keeps
  just SKILL.md (the agent SOP).
- README: add a "参考示例" table linking typical descriptors by shape
  (Form-A module / C-source compat / header-only / module wrapper), a
  copy-paste agent prompt that drives the skill end-to-end, and links to docs/.
- skill + docs: document the no-`mcpp-res`-permission fallback — use a
  plain-string upstream `url` (lint forbids a {GLOBAL,CN} table whose CN isn't
  gitcode/mcpp-res; plain strings are unconstrained). Real precedent:
  pkgs/t/tensorvia-cpu.lua.
- skill step 1 now distinguishes the two sources: a third-party upstream lib
  vs. the user's own mcpp-based library (Form A, lighter research).

* docs: rewrite README/docs/skill in a formal declarative register

Rewrite all prose across README.md, docs/*, and the add-mcpp-index-package
skill into declarative, academic-style Chinese: remove colloquial terms
(一把梭 / 踩坑 / 丢给 / 硬凑 / 藏不住 …) and decorative emoji (⚠️✅❌📘✓),
and reformulate fragments as complete declarative sentences. The red-flag
table becomes a "错误做法 / 正确做法" table; section headings are normalized
(e.g. "本地 lint 一把梭" → "本地 lint 复现(等价于 CI lint job)",
"踩坑" → "注意事项", "CI 兜底" → "CI 保障"). Technical content, commands,
code samples, and links are unchanged.
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.

1 participant