Skip to content

One runner that loads an app's libapp.so - #8

Open
colemancda wants to merge 36 commits into
masterfrom
feature/runner
Open

colemancda wants to merge 36 commits into
masterfrom
feature/runner

Conversation

@colemancda

Copy link
Copy Markdown
Member

linux-app-host becomes the one program every app runs in. It loads the app's libapp.so from its bundle (AppRuntime's DynamicRuntime.md §7.5, §7.6) and links no app. Installing an app now copies files: no SwiftPM, compiler or linker on the device. The runner and the OS can update on their own while the app's ABI stays put.

The runner (LinuxHostApp, LinuxHost's AppLibrary and InstalledApps)

  • linux-app-host [--bundle] App.app | IDENTIFIER [[--open] URL]. An identifier is found at <prefix>/lib/linux-app/<id>.app in ~/.local, the runner's own prefix, /usr/local and /usr (LINUXAPPRUNTIME_PREFIXES replaces the list). With no argument it uses App.app next to the executable, as a PortMaster port has it.
  • It exports rt.h through a dynamic list (Sources/LinuxAppHost/exports.list), which keeps the functions though nothing in the runner calls them. nm -D shows all 13 functions RuntimeNative defines, plus rt_gl_context_generation.
  • At every launch it checks:
    • the app's ABI and contracts;
    • lib/<target>/libapp.so against _CodeSignature/CodeResources. The file is opened once, hashed, and loaded through /proc/self/fd, so the bytes checked are the bytes loaded.
  • It loads libGLESv2.so.2 into the global scope first for an app whose contracts include Surface.
  • dlopen binds every symbol as the library loads, so a symbol the runner lacks refuses the app, by name.
  • The process is named after the app (PR_SET_NAME, CFBundleExecutable), so ps shows ExampleModel and not linux-app-host.
  • CLinuxHost defines and exports arc4random_buf where libc lacks it: musl, and glibc before 2.36.

The packager

  • install and package validate, then thin the bundle to Info.plist, resources/, the icon, _CodeSignature/ and the target's libapp.so, at lib/linux-app/<id>.app. They write a desktop entry with Exec=<runner> <id> %u. Nothing is built; the generated per-app host package is gone.
  • Validation requires a signature and checks the library is a shared library for the target's machine and word size.
  • run checks a bundle and runs it in the runner as it is.
  • The runner comes from --runner, LINUXAPPRUNTIME_RUNNER, beside linux-app, or PATH.
  • No wasm2c engine: it needs a C compiler, and AppRuntime's shim makes only a libapp.a.

PortMaster ports carry the runner, built once per architecture and named after the app, beside App.app thinned to lib/linux-arm64/libapp.so and lib/linux-armv7/libapp.so. Nothing in this repository links libapp.a now.

Tests, all passing on Debian 13 in Docker:

  • AppLibraryTests compiles libraries with the toolchain's clang into signed bundles. It checks that they load and their exports are called, and that they're refused when unsigned, changed, or unlisted. It checks that a missing symbol is named, and that a missing preload fails.
  • The packager's tests cover thinning, installing for the runner, finding the runner, validating libapp.so, and ports carrying each architecture's library.

End to end on Debian 13 (arm64), with bundles from AppRuntime master's guest.py:

  • ExampleUI and ExampleGL ran from their bundles. ExampleGL drew its triangle with GLES preloaded.
  • ExampleModel was installed with linux-app install, launched by its identifier, and refused once its library was changed after install.

Not verified:

  • x86_64 and armv7 runners;
  • musl, where only the arc4random_buf condition changed;
  • a PortMaster port build, whose images weren't rebuilt here.

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.

1 participant