Skip to content

Commit ffb96cf

Browse files
committed
fix(random): LINK.EXE reads -lbcrypt as an option named l
The MSVC conformance row still failed after the last commit named the library, because it named it in the other side's spelling. `ldflags` reaches the command line verbatim, and the two rows this predicate selects do not drive the same program: LINK : warning LNK4044: unrecognized option '/lbcrypt'; ignored random.obj : error LNK2019: unresolved external symbol __imp_BCryptGenRandom clang drives lld-link and translates GNU spellings for it; `msvc@system` drives LINK.EXE directly, and LINK reads `-` and `/` as the same option prefix. One spelling serves both. Measured, rather than assumed, before changing the row that was already green: clang --target=x86_64-pc-windows-msvc -fuse-ld=lld -### t.c bcrypt.lib → 'bcrypt.lib' clang --target=x86_64-pc-windows-msvc -fuse-ld=lld -### t.c -lbcrypt → "bcrypt.lib" The clang link line is byte-identical under both, so this cannot regress the row it is not aimed at.
1 parent 2aee72e commit ffb96cf

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

mcpp.toml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,24 @@ ldflags = ["-lntdll", "-lsynchronization", "-lshell32", "-lkernel32", "-lbcrypt"
6666
# ⚠️ The predicate above is `not(env = "msvc")`, so neither row saw the entry
6767
# there. The library is named once per side because the two sides spell a
6868
# library differently and share no list.
69+
#
70+
# ⭐ AND THE SPELLING HERE IS `bcrypt.lib`, NOT `-lbcrypt`. `ldflags` reaches
71+
# the command line verbatim; mcpp's dialect abstraction covers the flags it
72+
# generates itself, not the ones a manifest writes. The two rows this
73+
# predicate selects do not drive the same program: clang drives lld-link and
74+
# translates for it, while `msvc@system` drives LINK.EXE directly, and LINK
75+
# reads `-` and `/` as the same prefix — so `-lbcrypt` arrives as an option
76+
# named `l`:
77+
#
78+
# LINK : warning LNK4044: unrecognized option '/lbcrypt'; ignored
79+
# random.obj : error LNK2019: unresolved external symbol __imp_BCryptGenRandom
80+
#
81+
# One spelling serves both, which is why this stays a single entry. Measured
82+
# with `clang --target=x86_64-pc-windows-msvc -### … -fuse-ld=lld`: the driver
83+
# emits `bcrypt.lib` to lld-link for `-lbcrypt` and for `bcrypt.lib` alike, so
84+
# the clang link line is unchanged by this and only LINK.EXE sees a difference.
6985
[target.'cfg(all(windows, env = "msvc"))'.build]
70-
ldflags = ["-lbcrypt"]
86+
ldflags = ["bcrypt.lib"]
7187

7288
# Exceptions and run-time type information, on the one ABI where their absence
7389
# is asserted.

0 commit comments

Comments
 (0)