Fix make static-qt: add missing link deps for static binary
ober
a733ddd57b1ddb152657b5dd6bc170bbc0a8fa71
--- a/Makefile +++ b/Makefile @@ -423,6 +423,7 @@ build-jemacs-qt-static: check-root cp /src/vendor/jerboa-shell/embed-crypto.c /deps/jsh/ 2>/dev/null; \ cp /src/vendor/jerboa-shell/embed-crypto.h /deps/jsh/ 2>/dev/null; \ cp /src/vendor/jerboa-shell/ffi-shim.c /deps/jsh/ 2>/dev/null; \ + cp /src/vendor/jerboa-shell/libcoreutils.c /deps/jsh/ 2>/dev/null; \ if [ -f /src/vendor/jerboa-shell/crypto_stub.c ]; then \ gcc -c -O2 /src/vendor/jerboa-shell/crypto_stub.c -o /tmp/jemacs-build/crypto_stub.o; \ fi; \ --- a/build-binary-qt.ss +++ b/build-binary-qt.ss @@ -425,7 +425,8 @@ find ~a -name '*.sls' -o -name '*.ss' | \ sort -u | grep -v '^$' | grep -v '^_NSGetExecutablePath$' | grep -v '^io_uring_' | \ grep -v '^jerboa_' | grep -v '^SSL_' | grep -v '^TLS_' | grep -v '^EVP_' | \ grep -v '^CRYPTO_' | grep -v '^PKCS5_' | grep -v '^RAND_' | \ -grep -v '^QRcode_' | grep -v '^embed_encrypt$' | grep -v '^embed_random_bytes$' > /tmp/ffi_syms.txt && \ +grep -v '^QRcode_' | grep -v '^embed_encrypt$' | grep -v '^embed_random_bytes$' | \ +grep -v '^__error$' > /tmp/ffi_syms.txt && \ awk '\ BEGIN{ print \"/* Auto-generated — do not edit */\"; \ print \"#include \\\"scheme.h\\\"\"; print \"\"; } \ @@ -469,6 +470,25 @@ echo OK" (display "Error: jsh ffi-shim.c compilation failed\n") (exit 1)))) +;; libcoreutils.c (coreutils_raw_mode_*, coreutils_terminal_*, etc.) +;; Needed for static builds — provides C symbols referenced by jerboa-coreutils FFI +(when jemacs-static? + (let* ((jsh-root (path-parent jsh-dir)) + (cmd (format "gcc -c -O2 -o jemacs-qt-libcoreutils.o ~a/libcoreutils.c -Wall 2>&1" + jsh-root))) + (unless (= 0 (system cmd)) + (display "Error: libcoreutils.c compilation failed\n") + (exit 1)))) + +;; jsh coreutils stubs (jsh_* Rust uutils symbols — stubs for static binary) +;; The Rust libjsh_coreutils.a is not in the Docker image; these stubs allow linking. +;; At runtime, in-process coreutils commands return an error; vterm PTY is unaffected. +(when jemacs-static? + (let* ((cmd "gcc -c -O2 -o jemacs-qt-jsh-coreutils-stubs.o support/jsh_coreutils_stubs.c -Wall 2>&1")) + (unless (= 0 (system cmd)) + (display "Error: jsh_coreutils_stubs.c compilation failed\n") + (exit 1)))) + ;; jsh embed-crypto (pure C crypto for embed encryption — no external deps) (when (or jemacs-static? macos-build?) (let* ((jsh-root (path-parent jsh-dir)) @@ -651,6 +671,7 @@ grep -v '^$' | grep -v '^register_static_foreign_symbols$'") "/tmp/jemacs-build/crypto_stub.o" "")) (cmd (format "g++ -static -Wl,--export-dynamic -o jemacs-qt \ jemacs-qt-main.o jemacs-qt-chez-shim.o jemacs-qt-pcre2-shim.o jemacs-qt-jsh-ffi.o \ +jemacs-qt-libcoreutils.o jemacs-qt-jsh-coreutils-stubs.o \ jemacs-qt-embed-crypto.o jemacs-qt-ssh-agent-stub.o ~a \ jemacs-qt-pty-shim.o jemacs-qt-vterm-shim.o jemacs-qt-repl-shim.o jemacs-qt-jerboa-landlock.o jemacs-qt-sci-stubs.o \ qt_static_symbols.o \ @@ -711,7 +732,9 @@ jemacs-qt-main.o jemacs-qt-chez-shim.o jemacs-qt-pcre2-shim.o \ "jemacs_qt_scheme_boot.h" "jemacs_qt_jemacs_qt_boot.h" "jemacs-qt-all.so" "qt-main.so" "qt-main.wpo" "jemacs-qt.boot") (if jemacs-static? - '("jemacs-qt-jsh-ffi.o" "jemacs-qt-embed-crypto.o" + '("jemacs-qt-jsh-ffi.o" "jemacs-qt-libcoreutils.o" + "jemacs-qt-jsh-coreutils-stubs.o" + "jemacs-qt-embed-crypto.o" "jemacs-qt-ssh-agent-stub.o" "jemacs-qt-ssh-agent-stub.c" "jemacs-qt-pty-shim.o" "jemacs-qt-vterm-shim.o" "jemacs-qt-jerboa-landlock.o" --- a/lib/jerboa-emacs/async.sls +++ b/lib/jerboa-emacs/async.sls @@ -552,8 +552,8 @@ (let ([v (hashtable-ref cache key - '#{miss i8j2fi1rqgjlhflvdweso8ikz-1})]) - (if (eq? v '#{miss i8j2fi1rqgjlhflvdweso8ikz-2}) + '#{miss n10hyshhs5dvwyk4xet3dh5q9-1})]) + (if (eq? v '#{miss n10hyshhs5dvwyk4xet3dh5q9-2}) (if (null? default) #f (car default)) v))) (def (weak-cache-set! cache key value) new file mode 100644 --- /dev/null +++ b/support/jsh_coreutils_stubs.c @@ -0,0 +1,118 @@ +/* jsh_coreutils_stubs.c — Stubs for Rust uutils coreutils FFI symbols. + * + * In the static jemacs-qt binary, the Rust libjsh_coreutils.a is not available. + * These stubs allow the binary to link; at runtime, coreutils commands invoked + * through the in-process jsh shell will return an error. Commands run via the + * vterm PTY terminal use external binaries and are unaffected. + */ +#include <stdio.h> + +#define JSH_STUB(name) \ + int name(int argc, const char **argv) { \ + fprintf(stderr, #name ": not available in static build\n"); \ + return 1; \ + } + +JSH_STUB(jsh_arch) +JSH_STUB(jsh_b2sum) +JSH_STUB(jsh_base32) +JSH_STUB(jsh_base64) +JSH_STUB(jsh_basename) +JSH_STUB(jsh_basenc) +JSH_STUB(jsh_cat) +JSH_STUB(jsh_chgrp) +JSH_STUB(jsh_chmod) +JSH_STUB(jsh_chown) +JSH_STUB(jsh_chroot) +JSH_STUB(jsh_cksum) +JSH_STUB(jsh_comm) +JSH_STUB(jsh_cp) +JSH_STUB(jsh_csplit) +JSH_STUB(jsh_cu_realpath) +JSH_STUB(jsh_cut) +JSH_STUB(jsh_date) +JSH_STUB(jsh_dd) +JSH_STUB(jsh_df) +JSH_STUB(jsh_dir) +JSH_STUB(jsh_dircolors) +JSH_STUB(jsh_dirname) +JSH_STUB(jsh_du) +JSH_STUB(jsh_echo) +JSH_STUB(jsh_env) +JSH_STUB(jsh_expand) +JSH_STUB(jsh_expr) +JSH_STUB(jsh_factor) +JSH_STUB(jsh_fmt) +JSH_STUB(jsh_fold) +JSH_STUB(jsh_grep) +JSH_STUB(jsh_groups) +JSH_STUB(jsh_head) +JSH_STUB(jsh_hostname) +JSH_STUB(jsh_id) +JSH_STUB(jsh_install) +JSH_STUB(jsh_join) +JSH_STUB(jsh_kill) +JSH_STUB(jsh_link) +JSH_STUB(jsh_ln) +JSH_STUB(jsh_logname) +JSH_STUB(jsh_ls) +JSH_STUB(jsh_md5sum) +JSH_STUB(jsh_mkdir) +JSH_STUB(jsh_mkfifo) +JSH_STUB(jsh_mknod) +JSH_STUB(jsh_mktemp) +JSH_STUB(jsh_mv) +JSH_STUB(jsh_nice) +JSH_STUB(jsh_nl) +JSH_STUB(jsh_nohup) +JSH_STUB(jsh_nproc) +JSH_STUB(jsh_numfmt) +JSH_STUB(jsh_od) +JSH_STUB(jsh_paste) +JSH_STUB(jsh_pathchk) +JSH_STUB(jsh_pr) +JSH_STUB(jsh_printenv) +JSH_STUB(jsh_printf) +JSH_STUB(jsh_ptx) +JSH_STUB(jsh_pwd) +JSH_STUB(jsh_readlink) +JSH_STUB(jsh_rm) +JSH_STUB(jsh_rmdir) +JSH_STUB(jsh_seq) +JSH_STUB(jsh_sha1sum) +JSH_STUB(jsh_sha224sum) +JSH_STUB(jsh_sha256sum) +JSH_STUB(jsh_sha384sum) +JSH_STUB(jsh_sha512sum) +JSH_STUB(jsh_shred) +JSH_STUB(jsh_shuf) +JSH_STUB(jsh_sleep) +JSH_STUB(jsh_sort) +JSH_STUB(jsh_split) +JSH_STUB(jsh_stat) +JSH_STUB(jsh_stty) +JSH_STUB(jsh_sum) +JSH_STUB(jsh_sync) +JSH_STUB(jsh_tac) +JSH_STUB(jsh_tail) +JSH_STUB(jsh_tee) +JSH_STUB(jsh_test) +JSH_STUB(jsh_timeout) +JSH_STUB(jsh_touch) +JSH_STUB(jsh_tr) +JSH_STUB(jsh_truncate) +JSH_STUB(jsh_tsort) +JSH_STUB(jsh_tty) +JSH_STUB(jsh_uname) +JSH_STUB(jsh_unexpand) +JSH_STUB(jsh_uniq) +JSH_STUB(jsh_unlink) +JSH_STUB(jsh_vdir) +JSH_STUB(jsh_wc) +JSH_STUB(jsh_whoami) +JSH_STUB(jsh_yes) +JSH_STUB(jsh_hostid) +JSH_STUB(jsh_pinky) +JSH_STUB(jsh_uptime) +JSH_STUB(jsh_users) +JSH_STUB(jsh_who)