Add FreeBSD cargo-zigbuild remote_server support#55388
Conversation
|
Amazing, thank you! It wasn't clear from the report is the libz-sys thing fixable in that crate, or will we have to fork? I assume that the Ubuntu builders we currently use are going to be "similar enough" to the Arch one that we can copy this in. For the crash handler, is that something we could make work, or is that a limitation of mini dump? |
Good news — this is already fixed upstream. libz-sys PR 244 (rust-lang/libz-sys#244) (merged July 2025, available in v1.1.26+) removed the forced static vendored build on cross-compile. The old build.rs had cross_compiling && !apple which forced building zlib from source without -fPIC. That condition is now gone, so newer libz-sys will attempt dynamic linking first. For Zed's current version (1.1.22 per Cargo.lock), we'd either:
There's also an open PR 206
Yes ,they are same.
Not fundamentally limited — just unimplemented. The crash-handler maintainer confirmed (EmbarkStudios/crash-handling#108) that since FreeBSD has ptrace(), adding support "might not be too much work." The dependency chain is: Zed → crash-handler → minidump-writer. Maintainers are receptive to contributions. For the remote server use case, crash reporting is non-essential, so the no-op stubs are fine for now. If Zed wants proper crash reporting on FreeBSD later, the path is contributing a FreeBSD backend to minidump-writer (which would unblock crash-handler and then Zed). |
|
Already bump the libz-sys version, nothing break. Current runable build command CFLAGS_x86_64_unknown_freebsd="\
-fPIC \
-I$HOME/freebsd-sysroot/usr/include \
-L$HOME/freebsd-sysroot/lib \
-L$HOME/freebsd-sysroot/usr/lib" \
RUSTFLAGS="\
-L $HOME/freebsd-sysroot/lib \
-L $HOME/freebsd-sysroot/usr/lib \
-C link-arg=$HOME/freebsd-sysroot/usr/lib/libkvm.so \
-C link-arg=$HOME/freebsd-sysroot/usr/lib/libprocstat.so" \
cargo zigbuild -p remote_server --release --target x86_64-unknown-freebsd |
|
We also need to add a binary download function for freebsd side. |
|
Amazing, thanks! Happy to merge this. I don't see the libz change in the diff though? Once this is merged, are you ok to take a pass at adding a freebsd build to the workflows? Otherwise I can have claude do it when I get some downtime. Once I have something to test, I'll need you to check that the built binary actually works :D |
|
For the And yes, I'd be happy to take a pass at adding the FreeBSD build to the workflows next! I can test the built binary on my end once the CI is set up. |
Gate crash-handler and minidumper behind cfg(not(target_os = "freebsd")) since neither crate supports FreeBSD. Provide no-op stubs in the crashes crate so remote_server compiles and links without them. Add target_os = "freebsd" to gpui queue module cfg gates (same POSIX APIs as Linux). Fix MaybeUninit usage in fs::current_path() for FreeBSD: use zeroed() and assume_init_mut() instead of uninit() + as_mut_ptr() which is UB when accessing fields of uninitialized memory. Release Notes: - N/A
cab9d8b to
dcf38b9
Compare
|
Thanks! Looks like |
4a8a61e to
dcf38b9
Compare
Per review feedback, the original name is clearer since it's the default (non-FreeBSD) implementation.
Add FreeBSD as a recognized remote OS so the Zed client can connect to FreeBSD hosts without requiring a uname wrapper workaround. - Add RemoteOs::FreeBSD variant with "freebsd" identifier - Add "FreeBSD" to parse_platform() uname parsing - Add "unknown-freebsd" target triple mapping - FreeBSD uses PathStyle::Posix (already covered by wildcard arms)
Remove unused cfg-if and release_channel deps from crashes crate Update Cargo.lock
6e11a67 to
487ea9f
Compare
Work-in-progress to enable connecting to FreeBSD remote servers from Zed.
Full details: I've documented everything in a report
https://gist.github.com/G36maid/c2aff8c1561b307f38f9e1b3aff215e1
Summary
Four categories of changes that unblock FreeBSD remote development without affecting existing platforms:
crashescrate: Gatecrash-handler/minidumperbehindcfg(not(target_os = "freebsd"))since neither crate supports FreeBSD. A no-op stub module provides the same public API soremote_servercompiles and links without them.gpui: Addtarget_os = "freebsd"to thequeuemodule cfg gates — FreeBSD has the same POSIX APIs as Linux here.fs: FixMaybeUninitusage incurrent_path()—zeroed()+assume_init_mut()instead ofuninit()+as_mut_ptr(), which is UB when accessing fields of uninitialized memory.remote: AddFreeBSDto theRemoteOsenum andparse_platform()so the Zed client recognizes FreeBSD remotes without requiring aunamewrapper hack. Maps to theunknown-freebsdtarget triple.No behavioral change on any existing platform. All FreeBSD-specific code paths are gated behind
cfg(target_os = "freebsd").Remaining blockers( Already solved )building
prepare commands:
build commands:
Testing
Cross-compiled
remote_serverforx86_64-unknown-freebsdfrom Arch Linux, deployed to FreeBSD 15.0-RELEASE, and verified a successful remote connection from the Zed client.Release Notes: