Conversation

My afternoon hack project was a Rust hello world app for Windows 95. The really cool part is it's cross-compiled from Linux!! No MSVC involvement whatsoever in producing this .exe!

4
10
2

I discovered that lld has built-in support for emitting PE executables, so all I had to do was extract a bunch of headers and link libraries from the Visual C++ 6 SDK and wrap them up in a tiny Rust crate: https://github.com/haileys/vc6-sys

Then, I just wrote some normal Rust code against the Win32 API, pulled in my vc6-sys crate as a dep, and cross-compiled for Windows it using cargo's build-std feature! Here's the source: https://github.com/haileys/win32-helloworld

3
0
1

you literally don't need any custom toolchain on your computer to compile this, just type `cargo build` and it gives you a working exe that works on win95 and up :)

0
0
0
So cool! Are you planning on doing a write up or posting sources somewhere?
1
0
0

@hailey Caption: screencast of a Windows 95 desktop running in QEMU. A program on the desktop is run by double clicking, which pops up a dialog that says "Hello from Rust!" then another that says "panicked at 'oh no!' at src/main.rs:26:5"

0
0
1

@hailey This is amazing! There's a bunch of people interested in Rust on The Wrong Computers over in https://app.element.io/#/room/#RustRetro:matrix.org.

1
0
0

@hailey also TIL that https://crates.io/crates/cstr is a thing. I've been adding \0 to my C strings and doing run-time checks likes a fool :(

1
0
0

@hailey works on a real PC too (via my VGA capture device...)

0
1
0

this toot blew up over night, got hacker newsed even!

I'm so proud of my little self-hosted-at-home masty instance for serving all those requests for a video toot without having a meltdown :')

1
0
0

hails dot org infra

(all of this just runs in a bunch of nspawn containers on my desktop)

1
0
0
@hailey would be interesting to see safe bindings implemented!

maybe i might give a shot at it?
2
0
0
@hailey ok wow the bindings.rs is 4mb
maybe not ahahaha
0
0
0