-
Notifications
You must be signed in to change notification settings - Fork 27
Description
See #114 for the initial information. A Windows built Rust binary (executable) needs a C RunTime (CRT). By default, the CRT is dynamically linked to the executable, which keeps the executable size smaller. As of Rust v1.19, it is possible to statically link the CRT. This results in a slightly larger executable, but eliminates distribution of a dependency and/or eliminates installation of a prerequisite for running the Windows-built Rust binary.
In the case of the default, where the CRT is dynamically linked and not included in the executable, a CRT can be added to the MSI using the Merge
WiX Toolset tag, or needs to be installed separately before running the Rust binary on Windows.
In the case of statically linking the CRT with the Rust executable, a rustflag
can be defined in a environment variable, project configuration (Cargo.toml) or developer's Cargo configuration.
Adding static linking of the CRT is a simpler solution and recommended, but there are tradeoffs and developers may not be aware of this issue for their users since most Rust developers will have the required CRT already installed. Thus, some details and possible solutions based on these options should be added to the documentation.
A side thought, is it possible to detect from the cargo-metadata crate if static linking of the CRT is enabled? Maybe a warning should be printed if dynamic linking is being used and the CRT is not included in the WXS file? Or, is it possible to detect if dynamic linking is enabled at the time of the cargo wix init
command and the template automatically adds the CRT to the installer? This would take the CRT version of the developer's computer. For now, a simple configuration in a project's Cargo.toml file handles all of this, but it is something to think about. I do recognize this is probably what #114 was asking to implement. It just took me a moment.