sunfishcode / origin

Program startup and thread support written in Rust
Other
166 stars 12 forks source link
linux rust

Origin

Program and thread startup and shutdown in Rust

Github Actions CI Status zulip chat crates.io page docs.rs docs

Origin implements program startup and shutdown, as well as thread startup and shutdown, for Linux, implemented in Rust.

Program startup and shutdown for Linux is traditionally implemented in crt1.o, and the libc functions exit, atexit, and _exit. And thread startup and shutdown are traditionally implemented in libpthread functions pthread_create, pthread_join, pthread_detach, and so on. Origin provides its own implementations of this functionality, written in Rust.

For a C-ABI-compatible interface to this functionality, see c-scape.

This is used by Mustang and Eyra in their libc implementations, and in the Origin Studio project in its std implementation, which are three different ways to support building Rust programs written entirely in Rust.

It works with both stable (currently Rust >= 1.78) and nightly Rust. If you're using nightly Rust, enable the feature "nightly" to let origin use nightly-only features, which include proper support for unwinding, better safety checks, and better optimizations.

Example crates

Origin can also be used on its own, in several different configurations:

Fully static linking

The resulting executables in the origin-start, origin-start-no-alloc, and origin-start-lto examples don't depend on any dynamic libraries, however by default they do still depend on a dynamic linker.

For fully static linking, there are two options: