Rex 🦖 is a specialized utility designed to transform dynamic Linux executables
into portable, self-contained units. Unlike traditional Flatpaks, AppImages or
containers, Rex targets the binary level by "stitching" the application, its
shared library dependencies (.so), extra helpers, and assets into a single
executable wrapper.
At runtime, Rex identifies its own payload, extracts it to a secure temporary
location, and executes the target using a bundled dynamic loader (glibc or musl).
This bypasses "dependency hell" by ensuring the application always runs against
the exact environment it was packaged with.
-
Ultra-Minimalist 🪶
Total binary footprint of~954.6 KiB. -
Zero External Runtime Deps 🔋
Built with musl for static linking. No ldd or clap required at runtime. -
Deep ELF Inspection 🔍
Automatically resolves shared library trees using internal logic (rldd-rex). -
Universal Compatibility 🌍
Bundles the required dynamic loader to run across different Linux distributions. -
Industrial Grade Compression ⚡
Uses Zstd with Long Distance Matching (LDM) for maximum payload reduction. -
Clean Execution🔒
Automatic cleanup of temporary files upon process exit.
-
main.rs➜ Bootstrap
Detects execution mode (Builder vs. Stub) and handles CLI parsing. -
generator.rs➜ The Packer
Performs staging, dependency resolution, and footer injection. -
runtime.rs➜ The Stub
Performs backwards footer scanning and managed execution via the bundled loader.
Rex uses a Makefile to orchestrate optimized builds.
- 📌 Rust Stable (2024 Edition).
- 📌 Linux environment.
make
# or manually:
cargo build --releaseRex features a custom, lightweight argument parser designed for speed and small binary size.
# Basic packaging
./Rex -t ./my_app
# Full-featured bundle
./Rex \
-t ./my_app \
-L 19 \
-l /usr/lib/custom_lib.so \
-b ./helper_tool \
-f ./config_folder_or_files-
-t <file>: Target binary to bundle (Required). -
-L <num>: Zstd compression level (1–22, default: 5). -
-l <file>: Explicitly include additional shared libraries. -
-b <file>: Extra binaries (Rex will also resolve their dependencies). -
-f <path>: Additional files or directories to include in the bundle root.
Rex ensures portability by managing the Linux dynamic linking process manually:
-
Bundled Loader 📦
The generator locates the system loader (ld-linux-x86-64.so.2orld-musl-x86_64.so.1) and includes it inlibs/. -
Execution Hijacking 🎭
The runtime does not call the binary directly. Instead, it invokes the bundled loader and uses the--library-pathflag to point to the extractedlibs/directory. This ensures the target binary cannot link against incompatible host libraries. -
Path Resolution 🗺️
ThePATHenvironment variable is temporarily prefixed with the internalbins/directory, allowing the target binary to call bundled helper tools seamlessly.
When you execute a generated .Rex bundle:
-
Extraction 📂
The payload is extracted to/tmp. -
Environment Setup 🛠️
PrefixesPATHwith bundled binaries and configures the loader path. -
Managed Run ⚡
Invokes the bundled loader to execute the target binary. -
Cleanup 🧹
Automatically wipes the extraction directory once the app exits.
--rex-extract: Extracts the bundle into the current directory.
The internal structure is optimized for loader resolution:
<target>_bundle/
├─ <target> # Primary executable
├─ bins/ # Helper binaries (-b)
├─ libs/ # Shared libraries + Dynamic Loader (ld-linux/musl) + Extra libraries (-l)
└─ [assets] # Files added via the -f flag
The runtime expects exactly this layout and looks up the active bundle
using the target name provided in the appended metadata.
-
Not an AppImage Alternative 🚫
Rex is not designed to be an "AppImage-like" general-purpose desktop format. It is intended for specific use cases where static compilation is unfeasible or impossible (e.g., closed-source/proprietary libraries or complex C dependencies). -
Native Musl Optimization 💎
Rex is natively configured for thex86_64-unknown-linux-musltarget. Using Rex in a musl-based environment (such as Alpine Linux) to package your apps (-t) yields superior results. Since musl libraries are significantly more lightweight than glibc, the resulting bundled payload is much smaller and the runtime remains completely static with zero reliance on the host. -
Execution Overhead ⏳
Because Rex extracts its payload to a temporary directory at every run, there is a slight startup delay compared to an original static binary. -
No Extra Environment Support 🌐
Support for external environment variables to search for resources or dynamic paths will not be implemented. Rex is built for fixed, reliable execution environments.
-
🐛 Contributions are welcome only for bug fixes and binary size reduction.
-
📉 If you find a lighter
zstdimplementation or crate that reduces the footprint, feel free to submit a PR. -
🛑 Feature creep that increases binary size will be rejected to maintain the sub-1MB goal.
This project is licensed under the MIT License. See the LICENSE file for more details.
Developed with precision in Rust. 🦖
