Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
Description
Traditionally, MariaDB links C and C++ runtimes statically , with /MT compiler option.
The upside of it is that mariadb server linked this way can run anywhere, and does not need C runtime to be installed on the box .
The problem with static linking
The downside is large package size, servicing and security. In case of a security bug in CRT, users would need executables that are recompiled with the CRT versions that contain fixes (contrast with dynamic linking, where CRT security fixes would be delivered by the Windows update)
Another downside is that static linking requires careful considerations when programming, e.g 2 different DLLs cannot use each other's CRT objects. Which means, file descriptors or FILE* cannot be passed around between mysqld.exe and plugins, memory allocated with malloc() from one DLL can only be free()d in the same dll and so on.
The task
is to change our build to use dynamic C runtime linking. This means CRT needs to be installed on the target computer, but this is likely already be the case since Windows 10 already includes Universal CRT (UCRT) as part of OS, and on downlevel OSes it comes as part of popular packages
probably interesting how Microsoft itself handles this for dotnet core
https://github.com/dotnet/coreclr/pull/4381/commits/7902a3a3eee17378a61ef6817af5e73dc3050cfc
the avoid dependency of compiler runtime (link with /MT), but force shared UCRT dependency. (/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib)
Seems smart and something we could do in the future. At least on Win10, this means code do not have "libc" compiled in, only compiler dependency, which is tiny (exception handler mostly)