-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Remove dependency on VC runtime library #614
Comments
Any opinion on this, @ektrah @BurningEnlightenment @evoskuil ? |
The manual installation of the VC++ redistributable is indeed a bit annoying. As far as I know, Windows 10 comes with a "Universal CRT" that replaces the need for installing the redistributable and, unlike a statically linked copy, is kept up to date by Windows Update. It might be worth investigating that. |
Static linkage of MSVCRT for a dynamic link library is not advisable. There is shared state in the runtime that becomes isolated to the DLL. It can appear to work (despite warnings) but can produce insidious failures when other DLLs (or and executable) are linked with either independently-linked copies or (correctly) a dynamically-linked copy. |
@evoskuil, do you have any reference to static linkage not being advisable? I understand that there could be consequences in accessing shared state with different runtime versions, but IMO libsodium has a cleanly defined interface that does not allow/encourage this? @ektrah, I will try to link libsodium with Universal C Runtime and test in a container. |
Just wanted to say a big thank you to all of you for your invaluable help with making libsodium easier to use with Visual Studio! |
It is not that static linkage is a problem, but that static linkage in a dynamic library is a problem. When this occurs you will typically end up with at least two instances of the runtime (not two versions, assuming each inclusion is of the correct version for the compiler). Determining whether it is safe in practice requires openening the black box, which may not only be difficult but would introduce fragility. This comment doesn't fully describe the limitation, but as you can see if static linkage in the DLL was used, all other DLLs linked to the final EXE must do this as well. That implies two versions of each DLL must be available and the correct one chosen to link with any other depending on how the other was linked (which is not what you will find anywhere).
Also:
IMO this is definitely not a road you would want to go down. The VS template that is used in libsodium is specifically designed to ensure that CRT linkage is correct. |
I agree that statically linking CRT to libsodium could present some interesting challenges for users of the library. |
Windows binary is currently dependent on Visual C++ runtime library. This affects deployment of libsodium to containers (additional install slows down the build process) and Windows Nano server (which has no installer support).
I propose to link Windows binary with static runtime library instead. This would increase the x64 libsodium.dll size from 283KB to 363KB (tested with VS 2017). Besides simplifying the deployment process, I believe this would also theoretically improve the security by not depending on external code.
I can provide a PR if this is accepted.
The text was updated successfully, but these errors were encountered: