Skip to content

Commit f07e689

Browse files
authored
fix(compat.glfw, compat.mimalloc, compat.vulkan): Windows links as runtime.libraries, not GNU ldflags (#402)
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.
1 parent e07b3d7 commit f07e689

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

pkgs/c/compat.glfw.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,15 @@ package = {
161161
"src/win32_window.c",
162162
"src/wgl_context.c",
163163
},
164-
ldflags = { "-lgdi32" },
164+
-- DIALECT-NEUTRAL, NOT `ldflags`. `ldflags` reaches the linker
165+
-- verbatim, so `-lgdi32` arrived at link.exe unchanged and was
166+
-- dropped with "LNK4044: unrecognized option '/lgdi32'; ignored"
167+
-- -- the first sign being unresolved externals at the end of a
168+
-- consumer's build. `runtime.libraries` renders as gdi32.lib for
169+
-- MSVC and -lgdi32 for GNU.
170+
runtime = {
171+
libraries = { "gdi32" },
172+
},
165173
},
166174
},
167175
}

pkgs/c/compat.mimalloc.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,15 @@ package = {
103103
windows = {
104104
-- CMakeLists.txt:614 -- psapi/bcrypt for process memory info and
105105
-- the RNG seed, the rest for the Win32 primitives.
106-
ldflags = { "-lpsapi", "-lshell32", "-luser32", "-ladvapi32", "-lbcrypt" },
106+
--
107+
-- `runtime.libraries` rather than `ldflags`: ldflags reach the
108+
-- linker verbatim, and link.exe drops a GNU `-lpsapi` with
109+
-- "LNK4044: unrecognized option; ignored" -- silently, until the
110+
-- consumer's link ends in unresolved externals. This spelling is
111+
-- rendered per dialect (psapi.lib / -lpsapi).
112+
runtime = {
113+
libraries = { "psapi", "shell32", "user32", "advapi32", "bcrypt" },
114+
},
107115
},
108116
},
109117
}

pkgs/c/compat.vulkan.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,15 @@ package = {
438438
-- `-Llib` below misses and the link fails with
439439
-- "LNK1181: cannot open input file 'vulkan-1.lib'".
440440
sources = { "mcpp_generated/vulkan_import_anchor.c" },
441-
ldflags = { "-Llib", "-lvulkan-1" },
442441
runtime = {
442+
-- THE IMPORT LIBRARY, SPELLED FOR BOTH LINKERS. This was
443+
-- `ldflags = { "-Llib", "-lvulkan-1" }`, which reaches the
444+
-- linker verbatim: link.exe drops both with LNK4044 and the
445+
-- consumer's build ends in a hundred unresolved vk* symbols.
446+
-- `link_library_dirs` renders as /LIBPATH: or -L,
447+
-- `libraries` as vulkan-1.lib or -lvulkan-1.
448+
link_library_dirs = { "lib" },
449+
libraries = { "vulkan-1" },
443450
-- THE LOADER TRAVELS WITH THE PROGRAM (1.4.357.3+). mcpp copies
444451
-- every *.dll under a dependency's runtime library_dirs beside the
445452
-- executable it builds -- for transitive dependencies too -- and

0 commit comments

Comments
 (0)