Re:Show HN: Tiny 1k Rust binary on Windows
by ChrisSD on Tuesday December 01, 2020 @11:18AM
(#25266511)
I tried your program with MSVC using the following command:
It's 5kb.
[ Parent
| on HN ]
Re:Show HN: Tiny 1k Rust binary on Windows
by slezyr on Tuesday December 01, 2020 @02:45PM
(#25269021)
If I remember correctly you need a /nodefaultlib flag to disable stdlibs
https://docs.microsoft.com/en-us/cpp/build/reference/nodefau...
Re:Show HN: Tiny 1k Rust binary on Windows
by ChrisSD on Tuesday December 01, 2020 @03:31PM
(#25269504)
Ok, I've just tried that but I also needed to add `/force` otherwise it complained about missing symbols. So the full compile line is:
cl small2.c /link /force /nodefaultlib /entry:_start /subsystem:CONSOLE kernel32.lib
This gets it down to 3kb.