feat(ffi): enable bun:ffi on FreeBSD - #31528
Conversation
|
Actionable comments posted: 0 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
WalkthroughFreeBSD is removed from TinyCC-disable gating; TinyCC can be enabled on FreeBSD. Build defines add TARGETOS_FreeBSD. LLVM discovery and tool selection are extended for FreeBSD. tcc FFI now emits real extern declarations on FreeBSD instead of stubs. ChangesFreeBSD TinyCC and LLVM support
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
TinyCC's vendored fork already has full FreeBSD ELF support (TARGETOS_FreeBSD, note sections, ld-elf.so.1 interp) but was excluded from the build. Remove the exclusion from three places: - scripts/build/config.ts: build-time tinycc flag - scripts/build/buildOptionsRs.ts: ENABLE_TINYCC constant - src/tcc_sys/tcc.rs: cfg-gated extern stubs Also add FreeBSD LLVM tool resolution (ports use clang21/lld21 naming and /usr/local paths) and wire up ld.lld/strip for the FreeBSD link step. Tested: bun build + bun:ffi dlopen() on FreeBSD 15.0 x86_64.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tcc_sys/tcc.rs`:
- Around line 34-40: The runtime FFI gating is out of sync with tcc_sys: in
mod.rs update the cfg attributes so FreeBSD is treated the same as in
tcc_sys—remove "target_os = \"freebsd\"" from the #[cfg(not(any(...)))] that
wraps the real extern "C" block and from the #[cfg(any(...))] that provides the
tcc_delete unreachable! stub; instead enable the real extern "C" bindings on
FreeBSD and replace the stubbed tcc_delete with the forwarding implementation
that calls into the tcc_sys binding (use the same extern symbol names and the
tcc_delete function identifier) so FreeBSD uses the real TinyCC FFI rather than
panicking.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6af37c84-4a9c-4673-a6ae-8278af584eb9
📒 Files selected for processing (5)
scripts/build/buildOptionsRs.tsscripts/build/config.tsscripts/build/deps/tinycc.tsscripts/build/tools.tssrc/tcc_sys/tcc.rs
💤 Files with no reviewable changes (1)
- scripts/build/buildOptionsRs.ts
Missed a second cfg gate — tcc_delete in runtime/ffi/mod.rs had its own FreeBSD exclusion independent of tcc_sys. Remove it to match the tcc_sys change. Found by CodeRabbit review.
|
Actionable comments posted: 0 |
What does this PR do?
Enable TinyCC and bun:ffi dlopen() on FreeBSD. The vendored TinyCC
fork already has full FreeBSD ELF support (TARGETOS_FreeBSD, note
sections, ld-elf.so.1 interp) but was excluded from the build.
Changes:
wire up ld.lld and strip resolution
How did you verify your code works?
Full build from source on FreeBSD 15.0 x86_64 with LLVM 21.1.8 and
Rust nightly-2026-05-06. bun:ffi dlopen() loads a Zig-compiled .so
and the resulting binary passes the version smoke test.