fix: dont register jsh coreutils weak stubs with Sforeign_symbol on FreeBSD #85
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/freebsd-coreutils-weak-stubs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
On FreeBSD, every coreutils command (ls, cat, cp, hostname, etc.) fails with:
This happens both when running
jsh -c "ls"on the FreeBSD host directly and when connecting viassh biggus.Root Cause
The (jsh coreutils) module registers ~90 coreutils commands as shell builtins via register-coreutils!, which guards each registration with (when (cdr entry) ...) — checking whether the FFI function binding is non-#f. The define-coreutil-ffi macro binds to (and (foreign-entry? symbol) (foreign-procedure symbol ...)), so if foreign-entry? returns true, the binding is valid.
On FreeBSD, the Rust uutils library (libjsh_coreutils.a) is not linked. The jsh_* symbols (jsh_ls, jsh_cat, etc.) are emitted as attribute((weak)) C stubs that print [freebsd-main-weak] jsh_ls and return 0. But they are also registered with Sforeign_symbol in all three FreeBSD build files, causing foreign-entry? to return true. The builtin handler then calls the stub instead of falling through to the system /bin/ls.
Fix
Move the jsh_* coreutils symbols out of the Sforeign_symbol-registered symbol lists into a separate coreutils-weak-symbols list. The weak C stubs remain (required for linker resolution), but they are not registered with Chez's Sforeign_symbol, so foreign-entry? returns false. register-coreutils! skips them, and commands fall through to the normal PATH-based execution via which()/execute-external().
Files changed
Verification