-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Load-time dynamic linking on Windows #11575
Comments
It looks like LLVM's CMakeLists.txt doesn't support It does have a |
Related: #9278 |
#13436 will provide us a way to implement our own RPATH-style custom DLL searching, by calling
The top question is still figuring out how to distribute the static libraries and the DLL import libraries side-by-side. Generating import libraries from the DLLs themselves and placing them in the cache directory is probably not a viable option. |
Idea: if Lines 1 to 4 in 98c091e
In the future this would become After #13436 we will perform an actual library search anyway, because we need to open the library files to search for the DLL imports. Two consequences are that we don't even need to pass |
We have fully switched to dynamic linking and I think we could consider this issue finished once the following TODO is also addressed: crystal/src/compiler/crystal/loader/msvc.cr Lines 158 to 161 in cdd9ccf
|
We already have two use cases for load-time dynamic linking on Windows: distributing the LLVM libraries, and linking to MPIR without license issues. (Run-time dynamic linking would be equivalent to porting
Crystal::Loader
to Windows.) #11573 shows that this is indeed possible, but we are still far from supporting it in the compiler itself. Here are some thoughts:$ORIGIN\lib
is already used for the static libraries, we might need to find a different place for the import libraries, and the@[Link]
annotations would have to be adjusted only on Windows depending onflag?(:static)
.%PATH%
, so are the DLLs, but we might want to have more control over the DLL search order./MD
as well, or it can choose not to care with/Zl
, which should be fine as our preludes already provide eitherlibcmt
ormsvcrt
. On the contrary, DLLs should not link to the CRT statically. This means there are at least 3 flavors of linking:/MT
(this is the current situation, and will likely be what is implied by the--static
compiler flag eventually)/MD
/MD
(this is what-Dpreview_dll
implies)/MD
scenario we should have a separate CI job that builds everything. A complete Crystal distribution, however, will probably include both static and dynamic libraries.The text was updated successfully, but these errors were encountered: