Improve static Qt startup symbol handling
ober
2c6fd249592b0ab1147ce87f1e0da693bee518e2
--- a/build-binary-qt.ss +++ b/build-binary-qt.ss @@ -354,6 +354,16 @@ ;; Static: generate + compile foreign symbol registration table ;; (dlopen(NULL) is a stub in musl static builds, so we use Sforeign_symbol instead) + +;; jsh FFI shim. Compile this before generating the static symbol table so +;; the generator can register every exported ffi_* entry from the object. +(let* ((jsh-root (path-parent jsh-dir)) + (cmd (format "gcc -c -O2 -o jemacs-qt-jsh-ffi.o ~a/ffi-shim.c -Wall 2>&1" + jsh-root))) + (unless (= 0 (system cmd)) + (display "Error: jsh ffi-shim.c compilation failed\n") + (exit 1))) + (when jemacs-static? ;; scheme.h lives in chez-dir (same dir as libkernel.a) (let* ((ffi-path @@ -382,7 +392,9 @@ sed 's/;;.*//' | grep -oE '(foreign-procedure|foreign-entry\\?) \"[^\"]*\"' | se find ~a -name '*.sls' -o -name '*.ss' | \ xargs cat 2>/dev/null | tr '\\n' ' ' | \ grep -oE 'define-foreign [^ ]+ +\"[^\"]+\"' | \ - sed 's/.*define-foreign [^ ]* *\"//;s/\".*//'; } | \ + sed 's/.*define-foreign [^ ]* *\"//;s/\".*//'; \ +nm -g jemacs-qt-jsh-ffi.o 2>/dev/null | \ + awk '$2 == \"T\" || $2 == \"t\" { print $NF }'; } | \ sort -u | grep -v '^$' | grep -E '^[A-Za-z_][A-Za-z0-9_]*$' | 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 '^HMAC$' | \ @@ -429,15 +441,6 @@ echo OK" (display "Error: qt_static_symbols.c compilation failed\n") (exit 1))))) -;; jsh FFI shim. Compile this into every binary so jsh/imported editor -;; modules do not require an external LD_PRELOAD just to resolve ffi_* symbols. -(let* ((jsh-root (path-parent jsh-dir)) - (cmd (format "gcc -c -O2 -o jemacs-qt-jsh-ffi.o ~a/ffi-shim.c -Wall 2>&1" - jsh-root))) - (unless (= 0 (system cmd)) - (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? --- a/src/jerboa-emacs/core.ss +++ b/src/jerboa-emacs/core.ss @@ -298,12 +298,7 @@ (def (default-lsp-server-command) (or (getenv "JERBOA_LSP_COMMAND" #f) - (let* ((vendor-dir (or (getenv "JEMACS_VENDOR_DIR" #f) - (string-append (current-directory) "/vendor"))) - (candidate (string-append vendor-dir "/jerboa-lsp/scripts/jerboa-lsp"))) - (if (file-exists? candidate) - candidate - "jerboa-lsp")))) + "jerboa-lsp")) (def *lsp-server-command* (default-lsp-server-command))