index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2023-06-07 21:35:50.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2023-06-07 22:00:49.0 +00:00:00
commit
fa0cca564a78d30c18d01030beebde59f6872618 [patch]
tree
57259bf31228320f6fc782dc5baa64de851c4272
parent
d5279fffdd954364c26e6137810d44a9f5bdb672
download
fa0cca564a78d30c18d01030beebde59f6872618.tar.gz

refactor: statically link the c runtime on windows msvc x86_64

now the resulting EXE (x86_64-pc-windows-msvc) will not depend on the VCRUNTIME140.dll

before:
ldd target/release/static-web-server.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff9bdeb0000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff9bc210000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff9bb640000)
        advapi32.dll => /c/Windows/System32/advapi32.dll (0x7ff9bc510000)
        msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ff9bddd0000)
        sechost.dll => /c/Windows/System32/sechost.dll (0x7ff9bdb80000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ff9bcb40000)
        ws2_32.dll => /c/Windows/System32/ws2_32.dll (0x7ff9bdb10000)
        bcrypt.dll => /c/Windows/System32/bcrypt.dll (0x7ff9bbde0000)
        ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7ff9bbb30000)
        VCRUNTIME140.dll => /c/Windows/SYSTEM32/VCRUNTIME140.dll (0x7ff9b29a0000)
        CRYPTBASE.DLL => /c/Windows/SYSTEM32/CRYPTBASE.DLL (0x7ff9bae70000)

after:
ldd static-web-server.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff9bdeb0000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff9bc210000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff9bb640000)
        advapi32.dll => /c/Windows/System32/advapi32.dll (0x7ff9bc510000)
        msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ff9bddd0000)
        sechost.dll => /c/Windows/System32/sechost.dll (0x7ff9bdb80000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ff9bcb40000)
        ws2_32.dll => /c/Windows/System32/ws2_32.dll (0x7ff9bdb10000)
        bcrypt.dll => /c/Windows/System32/bcrypt.dll (0x7ff9bbde0000)
        CRYPTBASE.DLL => /c/Windows/SYSTEM32/CRYPTBASE.DLL (0x7ff9bae70000)

Diff

 .cargo/config.toml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 0000000..cbe2504
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,7 @@
[registries.crates-io]
protocol = "sparse"

# Statically link the C runtime on Windows MSVC x86_64,
# so that the resulting EXE doesn't depend on the VCRUNTIME140.dll.
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]