mitchellh / libxev

libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.
MIT License
1.97k stars 65 forks source link

Add FreeBSD support #67

Open iron-udjin opened 12 months ago

iron-udjin commented 12 months ago

Please add FreeBSD support. Currently it doesn't build under FreeBSD 13.2-RELEASE and zig-0.11:

$ zig build
zig build-lib xev Debug native: error: the following command failed with 1 compilation errors:
/usr/local/bin/zig build-lib /tmp/libxev/src/c_api.zig -lc --cache-dir /tmp/libxev/zig-cache --global-cache-dir /home/iron/.cache/zig --name xev -static --listen=- 
zig build-lib xev Debug native: error: the following command failed with 1 compilation errors:
/usr/local/bin/zig build-lib /tmp/libxev/src/c_api.zig --cache-dir /tmp/libxev/zig-cache --global-cache-dir /home/iron/.cache/zig --name xev -dynamic --listen=- 
Build Summary: 2/7 steps succeeded; 2 failed (disable with --summary none)
install transitive failure
├─ install xev transitive failure
│  └─ zig build-lib xev Debug native 1 errors
├─ zig build-lib xev Debug native (reused)
├─ install xev transitive failure
│  └─ zig build-lib xev Debug native 1 errors
└─ zig build-lib xev Debug native (reused)
src/main.zig:43:13: error: no default backend for this target
            @compileError("no default backend for this target");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.zig:6:28: note: called from here
const xev = Backend.default().Api();
            ~~~~~~~~~~~~~~~^~

Compile Log Output:
@as(target.Target.Os, .{.tag = .freebsd, .version_range = .{ .semver = .{.min = .{ ... }, .max = .{ ... }} }})
src/main.zig:43:13: error: no default backend for this target
            @compileError("no default backend for this target");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.zig:6:28: note: called from here
const xev = Backend.default().Api();
            ~~~~~~~~~~~~~~~^~

Compile Log Output:
@as(target.Target.Os, .{.tag = .freebsd, .version_range = .{ .semver = .{.min = .{ ... }, .max = .{ ... }} }})

$ zig version
0.11.0

Thank you!

cryptocode commented 2 months ago

I have a FreeBSD branch of libxev, which constituted most of the work of bringing Ghostty to FreeBSD 14.1.

It's mostly a matter of making the kqueue backend comptime configurable so the MachPort parts can be conditionally included.

I could shape that up for a PR, though a potential sticky point is the GH actions runner situation: https://github.com/actions/runner/issues/385

Should the CI be sorted first? If not, let me know and I can make a PR and discuss from there.

mitchellh commented 2 months ago

I'm happy accepting a PR for libxev without tests. Just note that without automated tests it more likely future work will regress the behavior...