index : static-web-server.git

ascending towards madness

author Jose Quintana <1700322+joseluisq@users.noreply.github.com> 2023-11-13 1:27:07.0 +00:00:00
committer GitHub <noreply@github.com> 2023-11-13 1:27:07.0 +00:00:00
commit
f4e914250e222ad1593968ba60aefa83120da190 [patch]
tree
281f58d1e9be3e34b582eb1155d1918ee8908e32
parent
3099dba4d3bdc7faf55a7dded27fcd6d02a8b4f7
download
f4e914250e222ad1593968ba60aefa83120da190.tar.gz

fix: arm64 binary does not run due to some missing windows dlls (#290)

This happens for example in fresh installs so now the Windows MSVC C
runtime is statically linked to solve the issue.

$ ldd static-web-server.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffc41ff0000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ffc408d0000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ffc3d9b0000)
        advapi32.dll => /c/Windows/System32/advapi32.dll (0x7ffc406b0000)
        msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ffc3f930000)
        sechost.dll => /c/Windows/System32/sechost.dll (0x7ffc3fe60000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ffc3e5e0000)
        ws2_32.dll => /c/Windows/System32/ws2_32.dll (0x7ffc40800000)
        ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7ffc3e1e0000)
        bcrypt.dll => /c/Windows/SYSTEM32/bcrypt.dll (0x7ffc3c7f0000)
        VCRUNTIME140.dll => not found
        api-ms-win-crt-math-l1-1-0.dll => not found
        api-ms-win-crt-string-l1-1-0.dll => not found
        api-ms-win-crt-heap-l1-1-0.dll => not found
        api-ms-win-crt-runtime-l1-1-0.dll => not found
        api-ms-win-crt-stdio-l1-1-0.dll => not found
        api-ms-win-crt-locale-l1-1-0.dll => not found

ARM64 (after)
$ ldd static-web-server.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffc41ff0000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ffc408d0000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ffc3d9b0000)
        advapi32.dll => /c/Windows/System32/advapi32.dll (0x7ffc406b0000)
        msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ffc3f930000)
        sechost.dll => /c/Windows/System32/sechost.dll (0x7ffc3fe60000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ffc3e5e0000)
        ws2_32.dll => /c/Windows/System32/ws2_32.dll (0x7ffc40800000)
        bcrypt.dll => /c/Windows/SYSTEM32/bcrypt.dll (0x7ffc3c7f0000)
        CRYPTBASE.DLL => /c/Windows/SYSTEM32/CRYPTBASE.DLL (0x7ffc3c550000)

Diff

 .cargo/config.toml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.cargo/config.toml b/.cargo/config.toml
index cbe2504..ce61f87 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -1,7 +1,9 @@
[registries.crates-io]
protocol = "sparse"

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