Skip to content

Remove binary files#1964

Closed
mldulaney wants to merge 1 commit into
lem-project:mainfrom
mldulaney:main
Closed

Remove binary files#1964
mldulaney wants to merge 1 commit into
lem-project:mainfrom
mldulaney:main

Conversation

@mldulaney
Copy link
Copy Markdown

Open source software should, by definition, not be distributing binary files. Given the xz backdoor, these increase distrust.

Signed-off-by: Mairi Savanna Dulaney <mairi@seattlebus.space>
@psionic-k
Copy link
Copy Markdown
Contributor

Hello there, fellow Gentoo stage 1 user?

@vindarel
Copy link
Copy Markdown
Collaborator

thanks, we will merge this.

I'll wait a bit and look at our options to automate the build.

(Anyone is welcome to help)

@mldulaney
Copy link
Copy Markdown
Author

thanks, we will merge this.

I'll wait a bit and look at our options to automate the build.

(Anyone is welcome to help)

hi, how are these binaries built? i'd be happy to help set them up to build with the rest of lem at build time

@vindarel
Copy link
Copy Markdown
Collaborator

@mldulaney hey thanks for proposing.

Here's a lisp snippet that builds the binary:

;; thanks to April & May on Discord
(let* ((source (asdf:system-relative-pathname :lem-terminal "terminal.c"))
       (lib (asdf:system-relative-pathname
             :lem-terminal (format nil
                                   "~(lib/~A/~A/terminal.so~)"
                                   (uiop:operating-system)
                                   (uiop:architecture)))))
  (unless (probe-file lib)
    (ensure-directories-exist lib)
    #+darwin
    (uiop:run-program (format nil "cc ~A -I/opt/homebrew/include -L/opt/homebrew/lib -lvterm -o ~A -shared -fPIC" 
                              source lib))
    #-darwin
    (uiop:run-program (format nil "cc ~A -lvterm -o ~A -shared -fPIC" source lib))))

(it fails on my machine so it's a bit more difficult to test for me)

Example invocation:

cc /home/vindarel/lisp-projects/lem/extensions/terminal/terminal.c -lvterm -o /home/vindarel/lisp-projects/lem/extensions/terminal/lib/linux/x64/terminal.so -shared -fPIC

terminal.c:297:34: error: ‘VTermScreenCellAttrs’ has no member named ‘conceal’
  297 |   return terminal->lastCell.attrs.conceal;
[…]

@jgarte
Copy link
Copy Markdown
Contributor

jgarte commented Dec 24, 2025

Here's some other relevant building code for this:

be73d0d#commitcomment-173429479

https://codeberg.org/guix/guix/src/commit/1434b4e6c78cf47ae0611a079098ef392cc2ea92/gnu/packages/text-editors.scm#L287

(invoke #$(cc-for-target)
                        "extensions/terminal/terminal.c"
                        "-L"
                        lib-dir
                        "-lvterm"
                        "-Wl,-Bdynamic"
                        "-o"
                        shared-lib
                        "-shared"
                        "-fPIC"
                        "-lutil"))

@jgarte
Copy link
Copy Markdown
Contributor

jgarte commented Dec 24, 2025

Here's a lisp snippet that builds the binary:

@vindarel Should your build script example be added to the scripts directory, not unlike scripts/build-legit.lisp and then a top-level Makefile target added?

https://github.com/lem-project/lem/blob/main/Makefile#L44

@vindarel
Copy link
Copy Markdown
Collaborator

@jgarte mmh maybe it could, so one could run this build step on its own; but most importantly the build step that builds Lem on the CI should run it and include the final .so in the bundle. I also think building this .so is optional and shouldn't make all the build fail.

also the snippet is courtesy of a helping hand on Discord

@ra-id-j
Copy link
Copy Markdown

ra-id-j commented Dec 24, 2025

Comment on the build snippet:
#2060 (comment)
I will collect all comments in the discussion thread linked above.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been inactive for {days} days. If there is no activity within the next 7 days, it will be automatically closed. Please comment or push new commits to keep it open.

@github-actions github-actions Bot added the stale label Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Closing this pull request due to inactivity. Please reopen it if you want to continue working on it.

@github-actions github-actions Bot closed this Apr 7, 2026
@vindarel vindarel reopened this Apr 8, 2026
@code-contractor-app
Copy link
Copy Markdown
Contributor

⚠️ Code Contractor: Contract File Not Found

Code Contractor could not find contract.yml.

How to set up:

  1. Create contract.yml in your repository
    View documentation

  2. Or configure in the dashboard
    Open repository settings and select lem-project/lem

💡 Tip: Use "Generate with AI" in the dashboard to create a contract tailored to your project.

📚 About Code Contractor

Declarative Code Standards That Learn and Improve

Define domain-specific validation rules in YAML.
Your contracts document team knowledge and evolve into more accurate AI enforcement.

Want this for your repo?
Install Code Contractor

@github-actions github-actions Bot removed the stale label Apr 8, 2026
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).
@theangelperalta
Copy link
Copy Markdown
Collaborator

Closing since this now handled by #2206 #2205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants