chore(terminal): add build script for lem-terminal native helper#2182
Merged
theangelperalta merged 1 commit intoMay 30, 2026
Merged
Conversation
Adds scripts/build-terminal.lisp and a `make terminal-lib` target that compiles extensions/terminal/terminal.c into the platform-specific extensions/terminal/lib/<os>/<arch>/terminal.so path that ffi.lisp already expects at runtime. This is the missing build path mentioned in lem-project#1964 and discussion lem-project#2060 so the prebuilt .so binaries can eventually be removed from version control without breaking source installs. The target is optional and standalone: lem-terminal already wraps its foreign-library load in ignore-errors, so platforms without libvterm or a C toolchain continue to work, just without the terminal extension. Respects CC / CFLAGS / LDFLAGS env vars and falls back to deriving architecture from *features* when uiop:architecture returns NIL (older bundled UIOP on Apple Silicon).
Collaborator
|
Do you know the minimal libvterm version? On an old-ish Debian, libvterm-dev 0.1.4-1 may be too old: |
Collaborator
Author
It seems like that version from 2020, can you try updating to at least 3.x @vindarel |
Catsquotl
pushed a commit
to Catsquotl/lem
that referenced
this pull request
May 31, 2026
5 tasks
theangelperalta
added a commit
that referenced
this pull request
Jun 3, 2026
) * chore(terminal): remove committed terminal.so binaries, build from source Removes the three prebuilt terminal.so shared objects from version control and replaces them with a from-source build path, addressing #1964 ("Open source software should, by definition, not be distributing binary files"). The build script and `make terminal-lib` target landed in #2182; this wires them into the editor build and removes the binaries: - git rm the linux/arm64, linux/x64 and macosx/arm64 terminal.so files. - Invoke `terminal-lib` best-effort (`-$(MAKE) terminal-lib`) from the ncurses, sdl2, sdl2-ncurses, webview and webview-ncurses targets so source installs still get a terminal. A missing libvterm/compiler is non-fatal: lem-terminal/ffi.lisp already wraps use-foreign-library in ignore-errors and silently disables itself when the library is absent. - gitignore extensions/terminal/lib/**/*.so so locally-built helpers are never re-committed. - Convert .github/workflows/build-terminal-shared-object.yml from a workflow that recompiled and re-committed terminal.so on every push (which would reintroduce exactly the binaries this removes) into a verify-only CI check that builds terminal.so from source on Linux and macOS and fails if the build breaks. Refs #1964, #2060, #2182. * chore(terminal): exit explicitly and verify artifact in build script build-terminal.lisp dropped into the SBCL REPL after a successful build (exiting only on stdin EOF) and trusted the compiler's exit code without checking that terminal.so was actually written. - Quit 0 after a successful build so `sbcl --load` never blocks on stdin. - Delete any stale .so before compiling, then assert the artifact exists afterwards, so a compiler that exits 0 without producing the file is treated as a failure instead of a silent no-op. - Factor the failure path into build-failed (stderr + exit 1). * chore(terminal): bundle static terminal.so into release artifacts Release bundles (Linux AppImage, macOS zip) never shipped or loaded terminal.so: ffi.lisp resolves it from the build machine's source tree via asdf:system-relative-pathname, and the macOS deploy library only bundles a foreign library that is loaded at build time -- which failed because the CI runner lacked libvterm. Even when bundled, a dynamic terminal.so referenced Homebrew's libvterm by absolute path and would break on a clean machine. Build a self-contained terminal.so with libvterm statically linked for releases, so the deploy library (macOS) and LD_LIBRARY_PATH=usr/lib (AppImage) can load it with no external libvterm dependency. - build-terminal.lisp: add LEM_TERMINAL_STATIC mode. macOS links libvterm.a directly (prefix via LIBVTERM_PREFIX / brew --prefix); Linux wraps -lvterm in -Wl,-Bstatic. Default stays dynamic for source installs. - macos-deploy.bash + nightly-builds.yml: install libvterm and build the static helper before asdf:make so deploy bundles it; assert it landed in the .app. - Dockerfile-AppImage: install libvterm-dev and build the static helper before asdf:make; make_appdir.sh asserts terminal.so reached usr/lib. No ffi.lisp/core changes: deploy + LD_LIBRARY_PATH handle runtime resolution once a self-contained .so is bundled. Refs #1964, #2060.
theangelperalta
added a commit
that referenced
this pull request
Jun 3, 2026
…urce (#2204) * chore(terminal): remove committed terminal.so binaries, build from source Removes the three prebuilt terminal.so shared objects from version control and replaces them with a from-source build path, addressing #1964 ("Open source software should, by definition, not be distributing binary files"). The build script and `make terminal-lib` target landed in #2182; this wires them into the editor build and removes the binaries: - git rm the linux/arm64, linux/x64 and macosx/arm64 terminal.so files. - Invoke `terminal-lib` best-effort (`-$(MAKE) terminal-lib`) from the ncurses, sdl2, sdl2-ncurses, webview and webview-ncurses targets so source installs still get a terminal. A missing libvterm/compiler is non-fatal: lem-terminal/ffi.lisp already wraps use-foreign-library in ignore-errors and silently disables itself when the library is absent. - gitignore extensions/terminal/lib/**/*.so so locally-built helpers are never re-committed. - Convert .github/workflows/build-terminal-shared-object.yml from a workflow that recompiled and re-committed terminal.so on every push (which would reintroduce exactly the binaries this removes) into a verify-only CI check that builds terminal.so from source on Linux and macOS and fails if the build breaks. Refs #1964, #2060, #2182. * chore(terminal): exit explicitly and verify artifact in build script build-terminal.lisp dropped into the SBCL REPL after a successful build (exiting only on stdin EOF) and trusted the compiler's exit code without checking that terminal.so was actually written. - Quit 0 after a successful build so `sbcl --load` never blocks on stdin. - Delete any stale .so before compiling, then assert the artifact exists afterwards, so a compiler that exits 0 without producing the file is treated as a failure instead of a silent no-op. - Factor the failure path into build-failed (stderr + exit 1).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
scripts/build-terminal.lispand amake terminal-libtarget that compilesextensions/terminal/terminal.cinto the platform-specific pathextensions/terminal/lib/<os>/<arch>/terminal.so— the same pathextensions/terminal/ffi.lispalready pushes ontocffi:*foreign-library-directories*at runtime.This is the missing build path discussed in #1964 and #2060, so the prebuilt
.sobinaries can eventually be removed from version control without breaking source installs.Why this scope
The target is optional and standalone:
lem-terminal/ffi.lispalready wrapscffi:use-foreign-libraryinignore-errors, so platforms without libvterm or a C toolchain continue to work — they just don't get the terminal extension.make sdl2/make ncurses/make webviewtargets are unchanged, so this doesn't add a hard libvterm dependency to normal builds..sobinaries are not removed in this PR. Removing them can be done in a follow-up (or by reopening Remove binary files #1964) once CI is verified producing them.Details
CC,CFLAGS,LDFLAGSenv vars for cross-distro / Nix / Guix friendliness.-lutilon Linux forforkpty; macOS uses Homebrew's-I/opt/homebrew/include -L/opt/homebrew/lib.*features*whenuiop:architecturereturnsNIL(older bundled UIOP on Apple Silicon).Test plan
make terminal-libon macOS arm64 (Homebrew libvterm) produces a workingextensions/terminal/lib/macosx/arm64/terminal.so(byte-identical size to the committed one).make terminal-libon Linux x64 with libvterm + libutil.make terminal-libon a host without libvterm — exits non-zero with the install hint, does not corrupt the tree.make sdl2/make ncurses/make webviewstill build without touching the terminal helper.lem-terminalloads the freshly-built.soat runtime by opening a*terminal*buffer.Refs #1964, #2060.