I'm moving parts of my Electron app to Rust. My Windows laptop has no Visual Studio on it, and I didn't want to install several gigabytes of Build Tools (with an admin prompt) just to try it out.
So I used the GNU toolchain instead. After one day, two Rust pieces sit on the main branch: a 590 KB command-line binary and a 56 KB WebAssembly module. Neither needed Visual Studio or a MinGW install.
This is what worked, plus the one wall I hit, and when you really do need MSVC.
Install without admin
rustup-init.exe -y --default-host x86_64-pc-windows-gnu --profile minimal rustup installs into your user folder (%USERPROFILE%\.rustup and .cargo) and adds .cargo\bin to your user PATH, so no admin prompt. --profile minimal gives you rustc, cargo and the standard library. No docs, no clippy, no rustfmt; you can add those later with rustup component add.
What I have now (trimmed):
> rustup show Default host: x86_64-pc-windows-gnu installed targets: wasm32-unknown-unknown x86_64-pc-windows-gnu > rustc -V rustc 1.100.1 (20ddd0171 2026-11-25) About 950 MB on disk, including the WebAssembly target.
One small thing: a terminal or editor that was already open during the install doesn't see the new PATH. My build script checks ~/.cargo/bin directly for that reason.
Why it links without MinGW
The GNU toolchain ships its own linker. Look in lib\rustlib\x86_64-pc-windows-gnu\bin\self-contained and you'll find x86_64-w64-mingw32-gcc.exe, ld.exe and dlltool.exe. Next door, in lib\self-contained, there are 44 files with the C runtime bits and import libraries like libkernel32.a and libws2_32.a. And there's a GCC-WARNING.txt:
gcc.exe contained in this folder cannot be used for compiling C files - it is only used as a linker.
That's the whole deal. Pure Rust builds and links. C code doesn't compile.
The binaries only import system DLLs. My bridge binary pulls in kernel32, ws2_32, ntdll, msvcrt and bcryptprimitives, all of which ship with Windows. There's no libgcc or libwinpthread DLL to bundle.
What builds and what doesn't
I built each of these in an empty project on the same machine (serde_json I didn't need to, the bridge uses it):
| Crate | Result |
|---|---|
serde_json 1 | builds |
socket2 0.5 (pulls windows-sys 0.52) | builds |
portable-pty 0.8 (pulls winapi 0.3) | builds; in a quick spike ConPTY, resize and exit codes worked |
socket2 0.6 (pulls windows-sys 0.61) | fails |
portable-pty 0.9 (pulls windows-sys 0.61) | fails |
anything that compiles C through the cc crate | fails: failed to find tool "gcc.exe" |
The pattern is in the parentheses: windows-sys 0.61 or newer.
The windows-sys 0.61 wall
Here's the first error:
error: error calling dlltool 'dlltool.exe': program not found error: could not compile `windows-sys` (lib) due to 1 previous error dlltool.exe is right there in the self-contained folder, just not on PATH. So I put it on PATH, and got further:
error: dlltool could not create import library with ...\self-contained\dlltool.exe -d ...\kernel32.dll_imports.def -D kernel32.dll ... ...\dlltool.exe: CreateProcess dlltool itself wants to start an assembler, and the toolchain doesn't ship one.
Why only 0.61? Older versions of windows-sys came with prebuilt import libraries through windows-targets (for 0.52 that's the windows_x86_64_gnu crate). 0.61 goes through windows-link instead and declares its imports with raw-dylib. The compiler then generates the import libraries during the build, and on the GNU target it does that with dlltool, which needs as.
On its own that would be a footnote. Then I checked who depends on it. In a fresh project with tokio, notify and reqwest:
> cargo tree -i windows-sys@0.61.2 -e normal --depth 1 windows-sys v0.61.2 ├── mio v1.2.5 ├── notify v9.0.0 ├── rustls-platform-verifier v0.7.1 ├── socket2 v0.6.5 ├── tokio v1.54.1 └── winapi-util v0.1.11 Async, file watching, TLS, and winapi-util (which walkdir uses). That's most of the crates you'd reach for in a real program.
What I do for now: pin versions that still use the old import libraries, and write down why, right in Cargo.toml:
[dependencies] serde_json = { version = "1", features = ["preserve_order"] } # 0.5 instead of 0.6: windows-sys >= 0.61 needs dlltool + an assembler on windows-gnu socket2 = "0.5" And build with --locked, so the build fails instead of quietly resolving something newer than Cargo.lock says.
When you need MSVC after all
- Any dependency on
windows-sys0.61 or newer. Today that includestokio,mio,notifyandsocket20.6. - Any crate that compiles C or C++ code. In my test project,
reqwest0.13 pulled inaws-lc-sys, which builds a C library with CMake. - Anything that has to link against C++ libraries built with MSVC.
You have two ways out. MSVC Build Tools need admin rights and a few GB. A portable MinGW-w64 build (WinLibs, for example) is a zip you unpack and put on PATH, and it brings both gcc and as. I haven't tested either route yet. The next piece I'm moving to Rust will probably need tokio, so I'll find out.
WebAssembly is the easy part
rustup target add wasm32-unknown-unknown This target links with rust-lld, which comes with the toolchain. No Visual Studio, no MinGW, no dlltool. My layout crate has no dependencies and no wasm-bindgen. It exports plain functions and raw pointers, and JavaScript reads the arrays straight out of WebAssembly memory:
#[unsafe(no_mangle)] // edition 2024 wants the unsafe(...) pub extern "C" fn layout_new(n: u32, m: u32) -> *mut Layout { Box::into_raw(Box::new(Layout::new(n as usize, m as usize))) } #[unsafe(no_mangle)] pub unsafe extern "C" fn layout_tick(l: *mut Layout, alpha: f64) { unsafe { (*l).tick(alpha) } } The release build is 57,393 bytes.
Getting it into an Electron app
All of this runs from one script, native/build.mjs, which runs before npm run dev and npm run build. Here's what it does, and why.
No Rust, no problem. If cargo isn't found, it prints a warning and the app uses the old JavaScript versions. Only release builds pass --required and fail hard. Anyone can still clone the repo and run it without installing Rust.
cargo build --release --locked. The release profile has lto = true, codegen-units = 1 and strip = true. A tiny test binary with the default release profile came out at 1.2 MB; the real bridge, with a JSON parser, an HTTP client and an MCP server, is 590 KB.
The binary goes to resources/bin. That folder is gitignored, and electron-builder copies it into the installer:
extraResources: - from: resources/bin to: bin filter: - "*.exe" A running .exe can't be overwritten. If the old binary is still running, the copy fails. Windows does let you rename a running exe, so the script renames it aside (.old-<timestamp>), copies the new one in and cleans up the leftovers on the next build.
The WebAssembly goes in as base64. This one cost me some time. The renderer is loaded from file://, so fetch('./layout.wasm') isn't an option, and Vite's ?inline import for .wasm didn't work inside the worker bundle. So the build script writes a generated TypeScript module, also gitignored:
// generated by native/build.mjs from native/layout export default 'AGFzbQEAAAAB...' The worker imports it with import.meta.glob, which returns an empty object when the file doesn't exist. No Rust means no file, and the worker falls back to the JavaScript layout:
const embedded = import.meta.glob('./wasm.gen.ts', { eager: true, import: 'default' }) as Record<string, string> const b64 = Object.values(embedded)[0] if (!b64 || typeof WebAssembly === 'undefined') return null // → JavaScript engine const bin = atob(b64) const bytes = new Uint8Array(bin.length) for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i) return await WebAssembly.compile(bytes) 57 KB of WebAssembly becomes a 77 KB module. For a single file that's a fair price.
What this doesn't cover
- One Windows 11 laptop, Rust 1.100.1, crate versions as of late November 2026. If the compiler ever stops needing
dlltoolforraw-dylibon the GNU target, the wall goes away. - No C dependencies, no cross-compiling, no code signing.
- I haven't tested the MSVC or WinLibs routes, so I can't tell you which one hurts less.
-
x86_64-pc-windows-msvcis still the default and the best-supported Windows target. GNU works well for small programs with few dependencies. Mine are both like that, on purpose.
Question
How do you build Rust on Windows?
A) MSVC with Visual Studio or the Build Tools
B) the GNU toolchain, like here
C) WSL, and I ship Linux binaries
D) I don't, yet
(I build VibeDesk, a free, open-source Windows desktop for Claude Code. It's an Electron app that I'm moving to Rust one piece at a time. Both pieces from this post are in native/ and ship in version 2.1 on December 13.)


