config.toml 1.4 KB

12345678910111213141516171819202122232425
  1. # Enable static linking for C runtime library on Windows.
  2. #
  3. # Rust uses the msvc toolchain on Windows,
  4. # which by default dynamically links the C runtime (CRT) to the binary.
  5. #
  6. # This creates a runtime dependency on the Visual C++ Redistributable (`vcredist`),
  7. # meaning the target machine must have `vcredist` installed for the application to run.
  8. #
  9. # Since `portable` version doesn't have an installer,
  10. # we can't rely on it to install dependencies, so this config.
  11. #
  12. # Basically:
  13. # - The `+crt-static` flag instructs the Rust compiler to statically link the C runtime for Windows builds.\
  14. # - To avoids runtime errors related to missing `vcredist` installations.
  15. # - Results in a larger binary size because the runtime is bundled directly into the executable.
  16. #
  17. # For MSVC targets specifically, it will compile code with `/MT` or static linkage.
  18. # See: - RFC 1721: https://rust-lang.github.io/rfcs/1721-crt-static.html
  19. # - Rust Reference - Runtime: https://doc.rust-lang.org/reference/runtime.html
  20. # - MSVC Linking Options: https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library
  21. # - Rust Issue #37406: https://github.com/rust-lang/rust/issues/37406
  22. # - Tauri Issue #3048: https://github.com/tauri-apps/tauri/issues/3048
  23. # - Rust Linkage: https://doc.rust-lang.org/reference/linkage.html
  24. [target.'cfg(windows)']
  25. rustflags = ["-C", "target-feature=+crt-static"]