Skip to content

Commit 16ae67b

Browse files
committed
docs: the first diagnosis read mingw's contents, and mingw is not part of this
⚠️ 我判断 `ProcessPrng` 不可用的依据是 `/usr/x86_64-w64-mingw32/lib` 里 没有它。**那个参照物是错的** —— mingw 不属于这套体系,它正是 `build.mcpp` 开头那段注释所说、这个包写出来就是为了不再依赖的东西: > files that exist on a machine with mingw installed and nowhere else … > a green that came from history the new machine does not have 本后端链接的要么是厂商 SDK(Windows 宿主),要么是本包从 `port/*.def` 自己生成的(交叉时),**从来不是第三方的**。 结论仍然成立,理由换成对的:Windows SDK 出 `bcrypt.lib` 而**不出** `bcryptprimitives.dll` 的导入库 —— `ProcessPrng` 文档化了却没有 `.lib`。 `BCryptGenRandom` 由 `bcrypt.lib` 列出,两条路都能解析。
1 parent 3dea09d commit 16ae67b

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

port/bcrypt.def

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
; handle would give openkal.random an initialisation order it does not have.
66
;
77
; ⚠️ `ProcessPrng` (bcryptprimitives.dll) was tried first: fewer moving parts,
8-
; and what Chromium and Rust use. It fails on a WINDOWS HOST, where this file's
9-
; generated import libraries are not built at all --- `build.mcpp` returns
10-
; immediately there, a real SDK being present --- and no SDK in either toolchain
11-
; exports that name. `libbcrypt.a` exports the name below on both.
8+
; and what Chromium and Rust use. It fails on a WINDOWS HOST, where these
9+
; generated libraries are not built at all --- `build.mcpp` returns immediately
10+
; there, the vendor's own being present and complete --- and the Windows SDK
11+
; ships no import library for `bcryptprimitives.dll`. The name below is listed
12+
; by `bcrypt.lib`, so it resolves through the vendor's libraries and through
13+
; this file alike.
1214
;
1315
; Generated into an import library by build.mcpp; see port/README.md.
1416
LIBRARY bcrypt.dll

src/random.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,28 @@
99
// takes a null handle, which is exactly what is wanted here.
1010
//
1111
// ⚠️ AND NOT `ProcessPrng`, WHICH WAS TRIED FIRST AND FAILS ON A WINDOWS HOST.
12-
// That name lives in `bcryptprimitives.dll` and no import library in either
13-
// toolchain exports it: mingw ships `libbcrypt.a` and not the primitives, and
14-
// this package generates its own import libraries only when cross-compiling
15-
// (`build.mcpp` returns immediately on a Windows host, where a real SDK is
16-
// present). Measured — the cross build linked and the native one did not:
1712
//
1813
// lld-link: error: undefined symbol: __declspec(dllimport) ProcessPrng
1914
//
15+
// The cross build linked and the native one did not, and the asymmetry is in
16+
// where the import library comes from. Cross-compiling, this package generates
17+
// its own from `port/*.def` — a list of names, so a name it lists is a name it
18+
// has. On a Windows host `build.mcpp` returns immediately and the VENDOR's
19+
// import libraries are used, because they are present and complete; and the
20+
// Windows SDK ships `bcrypt.lib` but no import library for
21+
// `bcryptprimitives.dll`. `ProcessPrng` is documented and has no `.lib`.
22+
//
2023
// ⭐ A backend that links on one host and not another is not a backend. The
21-
// name below is in `libbcrypt.a` on both.
24+
// name below is exported by `bcrypt.dll` and listed by `bcrypt.lib`, so it
25+
// resolves through the vendor's libraries and through this package's generated
26+
// one alike.
27+
//
28+
// ⚠️ THE FIRST DIAGNOSIS OF THIS WAS WRONG AND IS RECORDED SO IT IS NOT REPEATED:
29+
// it read `/usr/x86_64-w64-mingw32/lib` and concluded from mingw's contents.
30+
// mingw is not part of this ecosystem — it is the very thing `build.mcpp`
31+
// exists to stop depending on, as the note at the top of that file says. What
32+
// this backend links against is either the vendor's SDK or this package's own
33+
// generated libraries, and never a third party's.
2234
#include "win.h"
2335
#include <openkal/random.h>
2436

0 commit comments

Comments
 (0)