From c07943e98e078dc0c675a76570e1502d6dea6007 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 12 Sep 2026 17:51:06 +0800 Subject: [PATCH] fix(compat.glfw, compat.mimalloc, compat.vulkan): Windows links as `runtime.libraries`, not GNU ldflags All three declared their Windows system libraries as `ldflags` in the GNU spelling. `ldflags` reach the linker verbatim, and link.exe does not reject `-lgdi32` -- it drops it: LNK4044: unrecognized option '/lgdi32'; ignored and carries on, so the first sign is a consumer's link ending in unresolved externals (235 of them on xrgui). Every MSVC consumer has been re-declaring these three packages' libraries in its own manifest to compensate. `runtime.libraries` and `runtime.link_library_dirs` are the dialect-neutral half of a link line: rendered as gdi32.lib / /LIBPATH: for MSVC and -lgdi32 / -L for GNU. compat.libgbm already uses `link_library_dirs` in this form. compat.glfw gdi32 compat.mimalloc psapi shell32 user32 advapi32 bcrypt compat.vulkan vulkan-1, search dir lib/ Linux and macOS sections are unchanged. Payloads are unchanged, so no version moves. Consumer: Sunrisepeak/xrgui#8, which deletes its copies. --- pkgs/c/compat.glfw.lua | 10 +++++++++- pkgs/c/compat.mimalloc.lua | 10 +++++++++- pkgs/c/compat.vulkan.lua | 9 ++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pkgs/c/compat.glfw.lua b/pkgs/c/compat.glfw.lua index 2b4a8362..bfce7a94 100644 --- a/pkgs/c/compat.glfw.lua +++ b/pkgs/c/compat.glfw.lua @@ -161,7 +161,15 @@ package = { "src/win32_window.c", "src/wgl_context.c", }, - ldflags = { "-lgdi32" }, + -- DIALECT-NEUTRAL, NOT `ldflags`. `ldflags` reaches the linker + -- verbatim, so `-lgdi32` arrived at link.exe unchanged and was + -- dropped with "LNK4044: unrecognized option '/lgdi32'; ignored" + -- -- the first sign being unresolved externals at the end of a + -- consumer's build. `runtime.libraries` renders as gdi32.lib for + -- MSVC and -lgdi32 for GNU. + runtime = { + libraries = { "gdi32" }, + }, }, }, } diff --git a/pkgs/c/compat.mimalloc.lua b/pkgs/c/compat.mimalloc.lua index 2148976d..41829663 100644 --- a/pkgs/c/compat.mimalloc.lua +++ b/pkgs/c/compat.mimalloc.lua @@ -103,7 +103,15 @@ package = { windows = { -- CMakeLists.txt:614 -- psapi/bcrypt for process memory info and -- the RNG seed, the rest for the Win32 primitives. - ldflags = { "-lpsapi", "-lshell32", "-luser32", "-ladvapi32", "-lbcrypt" }, + -- + -- `runtime.libraries` rather than `ldflags`: ldflags reach the + -- linker verbatim, and link.exe drops a GNU `-lpsapi` with + -- "LNK4044: unrecognized option; ignored" -- silently, until the + -- consumer's link ends in unresolved externals. This spelling is + -- rendered per dialect (psapi.lib / -lpsapi). + runtime = { + libraries = { "psapi", "shell32", "user32", "advapi32", "bcrypt" }, + }, }, }, } diff --git a/pkgs/c/compat.vulkan.lua b/pkgs/c/compat.vulkan.lua index 03d20c59..3c04aef6 100644 --- a/pkgs/c/compat.vulkan.lua +++ b/pkgs/c/compat.vulkan.lua @@ -438,8 +438,15 @@ package = { -- `-Llib` below misses and the link fails with -- "LNK1181: cannot open input file 'vulkan-1.lib'". sources = { "mcpp_generated/vulkan_import_anchor.c" }, - ldflags = { "-Llib", "-lvulkan-1" }, runtime = { + -- THE IMPORT LIBRARY, SPELLED FOR BOTH LINKERS. This was + -- `ldflags = { "-Llib", "-lvulkan-1" }`, which reaches the + -- linker verbatim: link.exe drops both with LNK4044 and the + -- consumer's build ends in a hundred unresolved vk* symbols. + -- `link_library_dirs` renders as /LIBPATH: or -L, + -- `libraries` as vulkan-1.lib or -lvulkan-1. + link_library_dirs = { "lib" }, + libraries = { "vulkan-1" }, -- THE LOADER TRAVELS WITH THE PROGRAM (1.4.357.3+). mcpp copies -- every *.dll under a dependency's runtime library_dirs beside the -- executable it builds -- for transitive dependencies too -- and