On Windows the smallest exe can be achieved by writing in assembly and compiling as .com executable. These literally just contain the compiled assembly and are usually used on, for example, the 4k demoscene. 1k with rust is certainly a nice squeeze.
Show HN: Tiny 1k Rust binary on Windows
11–20 of 66 posts
Re: Show HN: Tiny 1k Rust binary on Windows
#12I have found this https://github.com/HugoPlatzer/tiny-rust-binaries . Can you test it and see how it behaves with msvc toolchain?
That contains a lot of platform-specific build instructions for Linux (and for the ELF file format used on Linux but not Windows), so it's never going to work with the msvc toolchain.
My bad everyone, my bad!
Re: Show HN: Tiny 1k Rust binary on Windows
#13 int main(void) {
puts("Hello World!");
return 0;
}
The Rust version is a mess [0][0] https://github.com/mcountryman/min-sized-rust-windows/blob/m...
Re: Show HN: Tiny 1k Rust binary on Windows
#14[0] https://github.com/mcountryman/min-sized-rust-windows/commit...
Re: Show HN: Tiny 1k Rust binary on Windows
#15I'm disappointed. In C I can get a 1k Hello Word binary simply be writing int main(void) { puts("Hello World!"); return 0; } The Rust version is a mess [0] [0] https://github.com/mcountryman/min-sized-rust-windows/blob/m...
Re: Show HN: Tiny 1k Rust binary on Windows
#16I'm disappointed. In C I can get a 1k Hello Word binary simply be writing int main(void) { puts("Hello World!"); return 0; } The Rust version is a mess [0] [0] https://github.com/mcountryman/min-sized-rust-windows/blob/m...
#include
int _start() {
const char str[] = "Hello world!\n";
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD written;
WriteFile(stdout, str, sizeof(str), &written, NULL);
ExitProcess(12);
return 0;
}https://stackoverflow.com/a/42536990
Which is similar to what the Rust program does. The result should be significantly less than 1k
Re: Show HN: Tiny 1k Rust binary on Windows
#17I'm disappointed. In C I can get a 1k Hello Word binary simply be writing int main(void) { puts("Hello World!"); return 0; } The Rust version is a mess [0] [0] https://github.com/mcountryman/min-sized-rust-windows/blob/m...
Compiling that source on Windows using visual studio produces a 98K executable.
Re: Show HN: Tiny 1k Rust binary on Windows
#18I think (?) its compiler sort-of implements a more advanced version of Unix strip.
Andrew Kelley could probably chime in more on it.
Re: Show HN: Tiny 1k Rust binary on Windows
#19I notice you moved from asm! to llvm_asm! [0]. Since the commit message doesn't explain why, would you be able to do so here? (Purely for my own curiosity) [0] https://github.com/mcountryman/min-sized-rust-windows/commit...
Re: Show HN: Tiny 1k Rust binary on Windows
#20Earlier quoted context omitted.
That contains a lot of platform-specific build instructions for Linux (and for the ELF file format used on Linux but not Windows), so it's never going to work with the msvc toolchain.
For some reason, I saw ELF as EXE! hahaha ^_^ My bad everyone, my bad!