Skip to content

Commit 72cea0e

Browse files
committed
fix(compat.opencl): name the Windows import libraries MSVC would have auto-linked
The first Windows section carried upstream's two link libraries and nothing else, because that is all upstream's CMakeLists names. MSVC never has to name the rest: its SDK headers pull the default import libraries in through `#pragma comment(lib, ...)`. mcpp links with lld and does not inherit that. The build compiled cleanly and failed at link with nine undefined symbols -- eight registry and process-token calls and `StringFromGUID2` -- so advapi32 and ole32 are named here. Measured on this repository's Windows job, which is the only Windows this change has. The compile was never the criterion.
1 parent 63f50d6 commit 72cea0e

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

‎pkgs/c/compat.opencl.lua‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,28 @@ package = {
201201
"*/loader/windows/icd_windows_library.c",
202202
},
203203
-- Upstream's `target_link_libraries(OpenCL PRIVATE cfgmgr32.lib
204-
-- runtimeobject.lib)`, in the spelling this index uses for a
205-
-- Windows system library. cfgmgr32 is the device enumeration the
206-
-- DXGK path walks; runtimeobject is WinRT, which the app-package
207-
-- scan calls into.
208-
ldflags = { "-lcfgmgr32", "-lruntimeobject" },
204+
-- runtimeobject.lib)` -- and four more that upstream never has to
205+
-- name. cfgmgr32 is the device enumeration the DXGK path walks;
206+
-- runtimeobject is WinRT, which the app-package scan calls into.
207+
--
208+
-- WHY UPSTREAM'S TWO ARE NOT ENOUGH HERE. MSVC pulls the default
209+
-- Windows import libraries in through `#pragma comment(lib, ...)`
210+
-- in its own SDK headers, so a CMake build never writes advapi32
211+
-- or ole32 down. mcpp links with lld and does not inherit that, and
212+
-- the build compiled cleanly and then failed at link with nine
213+
-- undefined symbols -- eight registry and token calls
214+
-- (`RegOpenKeyExA`, `OpenProcessToken`, `GetSidSubAuthority`, ...)
215+
-- and `StringFromGUID2`.
216+
--
217+
-- Measured on this index's own Windows job, which is the only
218+
-- Windows the change had: the compile is not the criterion, the
219+
-- link is.
220+
ldflags = {
221+
"-lcfgmgr32", -- CM_Get_Device_ID_List, the DXGK adapter walk
222+
"-lruntimeobject", -- WinRT, for the app-package scan
223+
"-ladvapi32", -- registry + process token
224+
"-lole32", -- StringFromGUID2
225+
},
209226
runtime = { capabilities = { "opencl.icd.driver" } },
210227
},
211228
},

0 commit comments

Comments
 (0)