Skip to content

Trim DelayLoadDLLs to DLLs actually imported (fix LNK4199)#3619

Open
dimension-zero wants to merge 1 commit into
ventoy:masterfrom
dimension-zero:delayload-dlls-trim
Open

Trim DelayLoadDLLs to DLLs actually imported (fix LNK4199)#3619
dimension-zero wants to merge 1 commit into
ventoy:masterfrom
dimension-zero:delayload-dlls-trim

Conversation

@dimension-zero

Copy link
Copy Markdown

Summary

Both `Ventoy2Disk.vcxproj` and `VentoyPlugson.vcxproj` list 10 DLLs in ``, but the code only actually delay-loads a subset. MSVC emits LNK4199 for each name on the list that the linker can't find an import for ("delay-loaded DLL X had no imports").

Trims the list to the DLLs that are genuinely imported in each project:

Project Before (10 DLLs) After
Ventoy2Disk gdi32, winspool, comdlg32, advapi32, shell32, ole32, oleaut32, uuid, odbc32, odbccp32 gdi32, advapi32, shell32, ole32
VentoyPlugson (same 10) shell32, ole32

Impact

  • Eliminates 14 LNK4199 warnings across Win32/x64 Release builds of both projects
  • No runtime change — the dropped DLLs were never being loaded delayed because they weren't imported in the first place. The delay-load runtime never touched them.

Files touched

  • `Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.vcxproj` — 8 `` blocks (Win32/ARM/ARM64/x64 × Debug/Release)
  • `Plugson/vs/VentoyPlugson/VentoyPlugson/VentoyPlugson.vcxproj` — 4 blocks (Win32/x64 × Debug/Release)

Stats

  • 2 files changed: +12 / −12

Test plan

  • `Ventoy2Disk.vcxproj` builds Win32 + x64 Release with 0 LNK4199 warnings
  • `VentoyPlugson.vcxproj` builds Win32 + x64 Release with 0 LNK4199 warnings
  • Produced `.exe` is bit-identical in behavior (same delay-load behavior since the dropped DLLs were already not imported)

Both Ventoy2Disk.vcxproj and VentoyPlugson.vcxproj listed 10 DLLs in
<DelayLoadDLLs>, but the code only actually delay-loads a subset. MSVC
emits LNK4199 for each name on the list that the linker can't find an
import for ("delay-loaded DLL X had no imports").

Reduced to the DLLs that are genuinely imported:

  Ventoy2Disk:    gdi32.dll;advapi32.dll;shell32.dll;ole32.dll
  VentoyPlugson:  shell32.dll;ole32.dll

This eliminates 14 LNK4199 warnings across the Win32/x64 Release builds
of both projects, with no runtime change — the dropped DLLs were never
being loaded delayed because they weren't imported in the first place.

Affects 8 ItemDefinitionGroup blocks in Ventoy2Disk.vcxproj (Win32/Arm/
Arm64/x64 × Debug/Release) and 4 in VentoyPlugson.vcxproj.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant