Skip to content

Add launcher binary that allows for debugging missing DLL dependencies at load time #657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jakepetroules
Copy link
Collaborator

Background: on Unix platforms, running a binary with a missing dependent shared library produces a human-readable error message on stderr containing the name of the missing library. On Windows, the loader may show a graphical dialog box with missing the DLL names when a process is run from a UI context, but in most cases the process will simply exit with STATUS_DLL_NOT_FOUND and no other information. This can make debugging missing dependent shared libraries very difficult.

The program in this PR uses Loader Snaps and documented SPI to replicate the Unix experience on Windows, printing nice human readable messages like This application has failed to start because \(missingDLL) was not found. to stderr. It's implemented as a launcher (think ccache), where its arguments are the command line that would be originally executed.

Mostly putting this up to illustrate the technique, not immediately planning to land this. Not sure if this is the right place for it either, or if Swift is even a good choice of implementation language (due to the fact that the launcher itself will have DLL dependences of its own on the Swift runtime).

It also has to be a launcher binary and not a set of helper APIs, since some of the APIs called in here really only make sense in the context of a main executable and not in library code.

Thanks to https://github.com/TimMisiak/LoaderLog/blob/main/LoaderLog.cpp for some learnings behind this.

@jakepetroules jakepetroules force-pushed the eng/PR-windows-launcher branch from 9544fc6 to f9d3e7e Compare July 16, 2025 23:54
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