Skip to content

feat(pkg): 新增 compat.gmp —— GNU GMP 6.3.0 静态库(install() 驱动,linux/macOS) - #194

Merged
Sunrisepeak merged 3 commits into
mcpplibs:mainfrom
wellwei:codex/gmp
Aug 9, 2026
Merged

feat(pkg): 新增 compat.gmp —— GNU GMP 6.3.0 静态库(install() 驱动,linux/macOS)#194
Sunrisepeak merged 3 commits into
mcpplibs:mainfrom
wellwei:codex/gmp

Conversation

@wellwei

@wellwei wellwei commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Closes #171

变更内容

  • pkgs/c/compat.gmp.lua —— 新增 compat.gmp(GNU GMP 6.3.0):C 源码库走 xpkg install() 钩子模式(同 compat.openssl/compat.openblas),钩子内跑上游 configure && make && make install 产出静态 libgmp.a + include/gmp.h
  • tests/examples/gmp/ —— 消费成员:mpz(100! / 2^1000 mod 12345 / gcd)+ mpq(1/2+1/3)+ mpf(sqrt2)断言,参考值由 Python 独立预计算;cfg(linux)/cfg(macos) 门控,其他平台 no-op main。
  • mcpp.toml 注册成员;README(EN/ZH)参考示例表补充;设计文档 .agents/docs/2026-08-09-add-gmp-plan.md

关键决策

  • configure 参数:--disable-shared --enable-static --disable-assembly(可移植通用 C 内核);--libdir 为绝对路径(GMP configure 拒绝相对值)。
  • 编译器用宿主 cc:linux /usr/bin/gcc、macOS /usr/bin/cc。GMP 的 configure 会编译并运行 ABI 探针、make 要运行 gen-* 构建工具,链接到 xim glibc payload 的这类可执行文件无法在本钩子环境运行(linux CI 首轮实测 could not find a working compiler);静态库的 glibc/libm 符号由消费端工具链更新的 payload glibc 在最终链接时满足。
  • 平台:linux + macOS;Windows 推迟(GMP 无 MSVC 构建路径,与 compat.openssl 现状一致)。
  • 镜像:暂无 mcpp-res 写权限 → 纯字符串上游 url(ftp.gnu.org 权威 tarball),lint 合规,维护者后续可补 CN。
  • 许可证:LGPL-3.0-or-later(GMP 双许可取宽松侧)。

验证

wellwei added 3 commits August 9, 2026 14:30
- pkgs/c/compat.gmp.lua:xpkg install() 钩子跑上游 configure && make && make install,
  产出 libgmp.a + include/gmp.h(--disable-assembly 通用 C 内核,--libdir 绝对路径)。
- tests/examples/gmp/:mpz/mpq/mpf 三层算术断言,cfg(linux)/cfg(macos) 门控,其他平台 no-op。
- windows 推迟:GMP 无 MSVC 构建路径;镜像待 mcpp-res 权限后补,当前纯字符串上游 url。
- 本地验证:mcpp 2026.8.8.2 macOS arm64 冷启动全流程通过;lint 8 项全过。
- 关联 issue mcpplibs#171
linux default 腿 CI 实测失败:configure 报 could not find a working compiler。
GMP 的 configure 会编译并运行 ABI 探针、make 期运行 gen-* 工具,链接到 xim glibc
payload(--sysroot/-B/-L)的这类可执行文件在本钩子环境无法运行;openssl 的
Configure 只写 Makefile 所以无此问题。改 /usr/bin/gcc 后探针/工具跑宿主 glibc,
静态库符号由消费端工具链更新的 payload glibc 在最终链接时满足。
@wellwei
wellwei requested a review from Sunrisepeak August 9, 2026 06:35
@Sunrisepeak
Sunrisepeak merged commit 99e2202 into mcpplibs:main Aug 9, 2026
10 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.

增加libgmp科学库

2 participants