Skip to content

Statically link to Windows C Runtime#1844

Merged
charlespierce merged 1 commit intovolta-cli:mainfrom
charlespierce:static_link_windows
Aug 15, 2024
Merged

Statically link to Windows C Runtime#1844
charlespierce merged 1 commit intovolta-cli:mainfrom
charlespierce:static_link_windows

Conversation

@charlespierce
Copy link
Copy Markdown
Contributor

@charlespierce charlespierce commented Aug 14, 2024

Closes #587

Info

  • By default, apps compiled by Rust on Windows depend on VCRUNTIME140.dll, the Windows Visual C++ Runtime.
  • This is very commonly already installed, but can cause issues on sandboxes or containers, where it isn't pre-installed, causing Volta to not work in those environments.
  • However, it's possible to use a configuration flag to tell rustc to statically link to the C runtime, which removes the need for the VCRUNTIME140.dll dependency.
  • In a local test, that static linking only increased the binary size by ~120 kb (less than 4% of the total binary size)

Changes

  • Added a .cargo/config.toml file and included the settings for statically linking to the C Runtime on Windows (both x64 and ARM)
  • Removed the Redistributable VC++ Runtime from the Windows installer

Tested

  • Ran locally and verified that everything still works.
  • Will need some external testing to make sure things work in a sandbox environment.

@charlespierce charlespierce force-pushed the static_link_windows branch 2 times, most recently from 95080ba to 0ff9226 Compare August 14, 2024 18:44
@charlespierce charlespierce marked this pull request as ready for review August 14, 2024 18:45
@charlespierce charlespierce merged commit db1192f into volta-cli:main Aug 15, 2024
@charlespierce charlespierce deleted the static_link_windows branch August 15, 2024 01:20
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.

Windows: system error if VCRUNTIME140.dll is not previously installed

2 participants