Skip to content

fix GMSSL_DIR platform link libs, drop the stale submodule, release 0.2.0 - #3

Open
jeromexiong wants to merge 3 commits into
GmSSL:mainfrom
jeromexiong:fix/gmssl-dir-platform-libs-and-release-0.2.0
Open

jeromexiong wants to merge 3 commits into
GmSSL:mainfrom
jeromexiong:fix/gmssl-dir-platform-libs-and-release-0.2.0

Conversation

@jeromexiong

Copy link
Copy Markdown

摘要

  1. fix:GMSSL_DIR 路径漏发平台链接库 —— 预装 GmSSL 在 macOS/Windows 上链接失败
  2. chore:删除已不被构建读取、且版本号自相矛盾的 GmSSL 子模块
  3. release:两 crate 升 0.2.0,便于发布到 crates.io —— 下游不再只能靠 git pin 拿到 Windows 修复

背景

crates.io 上仍是 2026-05-31 发布的 gmssl-rs 0.1.1 / gmssl-rs-sys 0.1.0,早于 main 上的 Windows/MSVC 修复合入。下游要拿到能用的 Windows 构建,只能用 [patch.crates-io] 钉住一份回移补丁的 fork,外加在自己 build.rs 里加 /FORCE:UNRESOLVED 绕过那对已发布 crate 自身的不自洽(0.1.1 声明了 GmSSL 3.1.1 没有的 x509_key_cleanup / zuc256_generate_keystream)。发一版 0.2.0 即可让这些临时改动全部退役。

改动明细

1. fix(sys): GMSSL_DIR 路径也发平台链接库

GMSSL_DIR 提前返回分支只发了 link-search + gmssl,漏了 from-source 路径发的平台库:

  • macOS:framework=Security(rand_apple.c 需要)
  • Windows:advapi32 / bcrypt / ncrypt(rand_win.c 的 CryptoAPI)

两条路径现在共用 emit_platform_link_libs()。

复现与验证(macOS x86_64 + 本机安装的 GmSSL 3.2.0 静态库):

  • 修复前:GMSSL_DIR=<prefix> cargo test → Undefined symbols for architecture x86_64: "_SecRandomCopyBytes"
  • 修复后:同一命令 46 passed / 0 failed

2. chore: 删除过期子模块

locate_gmssl_source() 早已改为下载 release tarball、不再读 gmssl-sys/GmSSL,但 gitlink 仍指 d655c06b(GmSSL v3.1.1),与 GMSSL_RELEASE_TAG(v3.2.0)矛盾;且 cargo 对 git 依赖会递归拉子模块 —— 每个 git 下游都白拉一棵错版本的树。一并清理 CI 的 submodules: recursive、.gitignore 条目与 README 的 --recursive 说明/目录树。

3. release: 0.2.0

  • C 库 3.1.1 → 3.2.0(main 既有状态,随本次发布整体生效)
  • gmssl-rs-sys FFI 重命名 pbkdf2_hmac_sm3_genkey → sm3_pbkdf2 ⇒ 破坏性变更
  • gmssl-rs 公共 API 相对 0.1.1 无变化(git diff 无 pub fn 签名变化)
  • README 依赖示例 0.1 → 0.2

发布顺序:先 cargo publish -p gmssl-rs-sys,再 cargo publish -p gmssl-rs(后者在 sys 0.2.0 上架前无法完成 cargo package,属预期)。

验证清单

  • macOS 本机 from-source:cargo test 46 passed / 13 ignored(13 个为历史 #[ignore] 的 SM9 测试,与本 PR 无关)
  • macOS 本机 GMSSL_DIR 路径:修复前链接失败 → 修复后 46 passed
  • cargo package -p gmssl-rs-sys(含 verify 构建)通过 —— 打包不依赖子模块
  • CI 三平台全绿:Linux (x86_64) / Windows (x86_64 MSVC) / macOS (ARM64) — run 37870336218

jerome and others added 3 commits October 9, 2026 09:31
The GMSSL_DIR early-return emitted only link-search + gmssl, so a
prebuilt static libgmssl failed to link: on macOS, `_SecRandomCopyBytes`
(Security.framework, used by rand_apple.c); on Windows, the CryptoAPI
symbols used by rand_win.c. Both the GMSSL_DIR and the from-source path
now share emit_platform_link_libs().

Reproduced on macOS/x86_64 with a GmSSL 3.2.0 install prefix:
`GMSSL_DIR=... cargo test` failed with
`Undefined symbols: _SecRandomCopyBytes` before this change and passes
after it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
locate_gmssl_source() downloads the release tarball and no longer reads
gmssl-sys/GmSSL, yet the gitlink still points at d655c06b (GmSSL
v3.1.1) while GMSSL_RELEASE_TAG is v3.2.0 — the contradiction misleads
readers, and cargo fetches submodules of git dependencies, so every
downstream git build pulled an unused tree at the wrong version.

Drop .gitmodules and the gitlink, the CI checkout flags, the .gitignore
entry, and the README text that still documented `--recursive` cloning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
crates.io still serves gmssl-rs 0.1.1 / gmssl-rs-sys 0.1.0 (published
2026-05-31), both predating the Windows/MSVC fixes on main, so
downstream crates cannot get a working Windows build without pinning
this repository via [patch.crates-io].

0.2.0 because the released pair moves the bundled C library from GmSSL
3.1.1 to 3.2.0 and gmssl-rs-sys renames its pbkdf2 binding
(pbkdf2_hmac_sm3_genkey -> sm3_pbkdf2). The gmssl-rs public API is
unchanged relative to 0.1.1 (no `pub fn` signature diff).

Publish order: gmssl-rs-sys first, then gmssl-rs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jeromexiong

Copy link
Copy Markdown
Author

CI 说明:首次贡献者的 workflow run 需要维护者批准才会运行(当前 run 状态 action_required)。同一分支、同一提交在 fork 上的 CI 已 3/3 全绿(Linux x86_64 / Windows x86_64 MSVC / macOS ARM64):https://github.com/jeromexiong/gmssl-rs/actions/runs/37870336218 —— workflow 文件与本 PR 完全一致。

jeromexiong pushed a commit to jeromexiong/gmssl-rs-patched that referenced this pull request Oct 9, 2026
All three nits are now reported/fixed upstream: GmSSL/gmssl-rs#3
(GMSSL_DIR platform link libs fix, stale submodule removal, 0.2.0
release prep), pending merge and cargo publish.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jeromexiong pushed a commit to jeromexiong/gmssl-fast that referenced this pull request Oct 9, 2026
上游 PR 内容:GMSSL_DIR 平台链接修复 + 删除过期子模块 + 0.2.0
发版准备;合并并发版后按注释指引撤除 [patch] 段。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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