Skip to content

Add initial FreeBSD support - #20480

Merged
SomeoneToIgnore merged 2 commits into
zed-industries:mainfrom
CalebHeydon:main
Nov 11, 2024
Merged

Add initial FreeBSD support#20480
SomeoneToIgnore merged 2 commits into
zed-industries:mainfrom
CalebHeydon:main

Conversation

@CalebHeydon

@CalebHeydon CalebHeydon commented Nov 10, 2024

Copy link
Copy Markdown
Contributor

This PR adds initial support for FreeBSD (#15309). While there is still work left to be done, it seems to be usable. As discussed by @syobocat (#10247), the changes were just adding target_os = "freebsd" to wherever it checks if the OS is Linux.

image

Needs to be build with RUSTFLAGS="-C link-dead-code"

Known Issues:

  • There's an issue in crates/project/src/environment.rs where a command fails because /bin/sh on FreeBSD doesn't support the -l option.
    image
  • The file/folder choosers provided by the ashpd crate don't work on FreeBSD (at least with KDE). This isn't that bad since a fallback dialog is used.
    image
  • Moving to trash won't work.
  • Numerous tests fail (when running on FreeBSD). While I haven't looked into this much, it appears that the corresponding features seem to work fine.

Release Notes:

  • Added initial support for FreeBSD

@cla-bot

cla-bot Bot commented Nov 10, 2024

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @CalebHeydon on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@CalebHeydon

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Nov 10, 2024
@cla-bot

cla-bot Bot commented Nov 10, 2024

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@zed-industries-bot

zed-industries-bot commented Nov 10, 2024

Copy link
Copy Markdown
Contributor
Messages
📖

This PR includes links to the following GitHub Issues: #15309
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against b9b8dae

@SomeoneToIgnore SomeoneToIgnore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

context.set("os", "macos");
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
context.set("os", "linux");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and another place below with Self::Linux looks quite odd, so welcome to fix in in the future PRs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out. It probably is correct to set the context to linux, but I'll need to prevent it from setting it to unknown.

@SomeoneToIgnore SomeoneToIgnore self-assigned this Nov 11, 2024
@SomeoneToIgnore
SomeoneToIgnore merged commit a47759f into zed-industries:main Nov 11, 2024
@bsdlme

bsdlme commented Nov 22, 2024

Copy link
Copy Markdown
  • There's an issue in crates/project/src/environment.rs where a command fails because /bin/sh on FreeBSD doesn't support the -l option.

sh -l Option was added to FreeBSD HEAD this week: https://cgit.freebsd.org/src/commit/?id=65f5dd42f11cdcb7716e6cdd09fac2314c144c1f

MFC'ed after a week unfortunately it won't land in the upcoming 14.2-RELEASE. Until then, you can use /usr/local/bin/bash -l.

@chiefMarlin

Copy link
Copy Markdown

Hey,
Great job on the PR!
Are there any instructions on how it can be used at this moment ?

Thanks

@christianbaptista

christianbaptista commented Jan 16, 2025

Copy link
Copy Markdown

I have mini gist with basic to install.

@chiefMarlin

Copy link
Copy Markdown

I have mini gist with basic to install.

Thats perfect! i will try it

@chiefMarlin

Copy link
Copy Markdown

I had tried building on FreeBSD 15, following these instructions

pkg install -y ca_root_nss protobuf cmake alsa-lib
git clone https://github.com/zed-industries/zed.git && cd zed
export RUSTFLAGS="-C link-dead-code"
cargo build --release

However now it seems to be stuck at missing webrtc deps, what am i missing, i didnt see any mentions of having to install alsa/webrtc

error: failed to run custom build command for `webrtc-sys v0.3.5 (https://github.com/zed-industries/livekit-rust-sdks?rev=060964da10574cd9bf06463a53bf6e0769c5c45e#060964da)`

Caused by:
  process didn't exit successfully: `/home/q/zed/target/release/build/webrtc-sys-acfb0aa9d2637c60/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LK_DEBUG_WEBRTC
  cargo:rerun-if-env-changed=LK_CUSTOM_WEBRTC
  cargo:CXXBRIDGE_PREFIX=webrtc-sys
  cargo:CXXBRIDGE_DIR0=/home/q/zed/target/release/build/webrtc-sys-15803e940b18f682/out/cxxbridge/include
  cargo:CXXBRIDGE_DIR1=/home/q/zed/target/release/build/webrtc-sys-15803e940b18f682/out/cxxbridge/crate

  --- stderr

  CXX include path:
    /home/q/zed/target/release/build/webrtc-sys-15803e940b18f682/out/cxxbridge/include
    /home/q/zed/target/release/build/webrtc-sys-15803e940b18f682/out/cxxbridge/crate
  thread 'main' panicked at /home/q/.cargo/git/checkouts/livekit-rust-sdks-171a3090be725d50/060964d/webrtc-sys/build.rs:85:45:
  called `Result::unwrap()` on an `Err` value: "failed to download webrtc from https://github.com/livekit/client-sdk-rust/releases/download/webrtc-dac8015-6/webrtc-freebsd-x64-release.zip: 404 Not Found"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

@christianbaptista

Copy link
Copy Markdown

i don't know if with alsa wrtc works, I'm FreeBSD 14.1 and pulseaudio wrtc-audio (I prefer oss), but I don't know works fine in 15-current. If not works try other old commit.
zed-freebsd
I'm sorry per my dwm vanilla...

@notpeter

Copy link
Copy Markdown
Contributor

@chiefMarlin

Copy link
Copy Markdown

Oddly enough this was not the error i was seeing yesterday and it seemed that commit bf569d7 worked yesterday. However today when i was trying to narrow down what commit broke the current build i started running into the 404 error that you mention.

@silent-at-gh

Copy link
Copy Markdown

hi,

The file/folder choosers provided by the ashpd crate don't work on FreeBSD (at least with KDE). This isn't that bad since a fallback dialog is used.
this one starts to work once the following pkgs are installed:

xdg-desktop-portal
xdg-desktop-portal-lxqt # <- this one is most likely redundant unless the one is lxqt user

i.e. the outcome after the installation of those is that native "open file" dialog window starts to appear and seems functions properly. Unfortunately once installed it substantially increases cpu usage by zed to the point that laptop's fan never stops. And such nasty behavior is observed even when zed is simply started (no editing work is done, nothing is opened).

@silent-at-gh

Copy link
Copy Markdown

I have mini gist with basic to install.

Hi,
great work! It works flawlessly. Meaning at least v0.164.2 is successfully built. However it looks like it is the last version that can be built on FreeBSD. Any attempt to build higher versions (v0.166.x+) fails (see error in #23247). I believe this is due to changes introduced here.

Or am I wrong and smb. was lucky and was able to build >=v0.166+ on FreeBSD?

@christianbaptista

Copy link
Copy Markdown

I have mini gist with basic to install.

Hi, great work! It works flawlessly. Meaning at least v0.164.2 is successfully built. However it looks like it is the last version that can be built on FreeBSD. Any attempt to build higher versions (v0.166.x+) fails (see error in #23247). I believe this is due to changes introduced here.

Or am I wrong and smb. was lucky and was able to build >=v0.166+ on FreeBSD?

Thanks! I have not success with recent builds, but I'm trying to compile rust-sdks and client its.

@notpeter

Copy link
Copy Markdown
Contributor

@G36maid Can you please start a clean discussion thread rather than commenting here. Merged PRs are not a place for new discussion. I believe what you are seeing is related to this:

notpeter added a commit that referenced this pull request Jun 22, 2025
This PR contains a set of changes for improving FreeBSD support (#15309,
#29550) and is a kind of follow up to the PR #20480 which added an
initial support for FreeBSD.

A summary of changes is as follows:
- Add some more freebsd conditionals which seem missing in the previous
PR.
- Implement `anonymous_fd()` and `current_path()` functions for FreeBSD.
- Improve detection of FreeBSD in telemetry and GPU detection.
- Temporarily disable LiveKit/WebRTC support to make build succeed.
- Remove support for flatpak since it is Linux-only packaging format.

Adding `RUSTFLAGS="-C link-dead-code"` does not seem necessary anymore.
It builds fine without the flag.

Known issues:
- Integrated terminal is painfully laggy and virtually unusable in my
environment. This might be specific to my setup.
- I cannot input Japanese using IME. When I type characters, they appear
on the screen. But when I hit return key, they disappears. Seems the
same issue as #15409.

My environment is MATE desktop on X11 on FreeBSD 14.2 on Intel Core
i5-7260U integrated graphics.

P.S. For those who might be interested, a work-in-progress FreeBSD port
and binary packages are available at
https://github.com/tagattie/FreeBSD-Zed

Release Notes:

- N/A

---------

Co-authored-by: Peter Tripp <peter@zed.dev>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
This PR adds initial support for FreeBSD
(zed-industries#15309). While there is
still work left to be done, it seems to be usable. As discussed by
@syobocat (zed-industries#10247), the
changes were just adding ```target_os = "freebsd"``` to wherever it
checks if the OS is Linux.


![image](https://github.com/user-attachments/assets/80ea5b29-047f-4cbd-8263-42e5fa6c94b7)

Needs to be build with ```RUSTFLAGS="-C link-dead-code"```

Known Issues:
- There's an issue in ```crates/project/src/environment.rs``` where a
command fails because ```/bin/sh``` on FreeBSD doesn't support the
```-l``` option.

![image](https://github.com/user-attachments/assets/c3c38633-160f-4f47-8840-e3da67f6ebc8)
- The file/folder choosers provided by the ```ashpd``` crate don't work
on FreeBSD (at least with KDE). This isn't that bad since a fallback
dialog is used.

![image](https://github.com/user-attachments/assets/29373006-1eb9-4ed0-bd52-2d0047fab418)
 - Moving to trash won't work.
- Numerous tests fail (when running on FreeBSD). While I haven't looked
into this much, it appears that the corresponding features seem to work
fine.

Release Notes:

- Added initial support for FreeBSD
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
This PR contains a set of changes for improving FreeBSD support (zed-industries#15309,
zed-industries#29550) and is a kind of follow up to the PR zed-industries#20480 which added an
initial support for FreeBSD.

A summary of changes is as follows:
- Add some more freebsd conditionals which seem missing in the previous
PR.
- Implement `anonymous_fd()` and `current_path()` functions for FreeBSD.
- Improve detection of FreeBSD in telemetry and GPU detection.
- Temporarily disable LiveKit/WebRTC support to make build succeed.
- Remove support for flatpak since it is Linux-only packaging format.

Adding `RUSTFLAGS="-C link-dead-code"` does not seem necessary anymore.
It builds fine without the flag.

Known issues:
- Integrated terminal is painfully laggy and virtually unusable in my
environment. This might be specific to my setup.
- I cannot input Japanese using IME. When I type characters, they appear
on the screen. But when I hit return key, they disappears. Seems the
same issue as zed-industries#15409.

My environment is MATE desktop on X11 on FreeBSD 14.2 on Intel Core
i5-7260U integrated graphics.

P.S. For those who might be interested, a work-in-progress FreeBSD port
and binary packages are available at
https://github.com/tagattie/FreeBSD-Zed

Release Notes:

- N/A

---------

Co-authored-by: Peter Tripp <peter@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants