remote: Use cargo-xwin to cross build Windows remote server on Unix system - #64787
lingyaochu wants to merge 1 commit into
Conversation
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Nice idea, thank you, one note.
| ); | ||
| log::info!("building remote binary from source for {triple} with Zig"); | ||
| } | ||
| RemoteServerBuildMode::Xwin => { |
There was a problem hiding this comment.
This branch installs the Rust target and cargo-xwin, but does not check the required native tools.
The documented macOS development setup does not require full LLVM, and the repository’s minimal Rust toolchain does not include llvm-tools.
Meanwhile, cargo-xwin sets the target archiver to llvm-lib, with a fallback that depends on Rust’s optional LLVM tools.
Let's add an actionable prerequisite check and setup instructions, analogous to the existing Zig check, rather than proceeding with an incomplete toolchain.
|
The automatic installation/invocation also needs an explicit policy decision. |
Summary
When running the dev version of Zed and trying to connect to a remote server, Zed triggers a local build of
remote_serverand uploads it to the remote. When the local host is different from the remote, Zed usescargo-zigbuildto cross-build theremote_serverbinary. When the local host is Windows and the remote is a Unix system, it just works, but in reverse, it does not.The truth is, I have never been able to cross-build the Windows
remote_serverbinary on my Linux machine; it always throws an error in the linking stage. Apart from that, even when using some dirty hacks, I can have the binary built and uploaded, but there are still two problems:remote_serverbinary size is very big, larger than 1.0 GBzed/crates/remote/src/transport.rs
Lines 293 to 307 in e52ab15
So in the past, to test if a remote fix works, I needed to first push the fix, ssh to the remote Windows server, pull the changes, and build the
remote_serverdirectly on that Windows machine, then manually copy the binary to the directory where Zed stores remote servers. Not a fan of this at all anymore.So here, instead of using
cargo-zigbuildto cross-build the Windowsremote_serveron Unix-like platforms, we change tocargo-xwin, which is designed to cross-build the msvc version of Windows programs from Unix-like systems. From my local test, it can do the work perfectly, and the produced binary size is about 200 MB, the same as the binary built directly on a Windows machine, and more importantly, it is very stable, with no dropped connections or crashes.I suspect there are some concerns:
cargo xwin, some Windows-sdk files are downloaded and cached.cargo-xwin, we need to accept the Microsoft license: https://go.microsoft.com/fwlink/?LinkId=2086102Testing
You can just run the following commands on a Linux or Mac machine to test the
cargo-xwinbuild ofremote_server:Self-review
Release Notes: