#linux #thread #startup #origin #std #locking

yanked origin-stduio

Program startup and thread support written in Rust

0.1.0 Aug 26, 2023

#29 in #origin

Apache-2.0…

225KB
4K SLoC

origin-studio

An alternative `std`-like implementation built on origin

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

origin-stdio is an alternative std-like implementation built on origin.

At this time, it only works on Linux, requires Rust nightly, lacks full std compatibility, and is overall experimental. But it supports threads and stuff.

Quick start:

In an empty directory, on Linux, with Rust nightly, run these commands:

cargo init
cargo add origin_studio
cargo add compiler_builtins --features=mem
echo 'fn main() { println!("cargo:rustc-link-arg=-nostartfiles"); }' > build.rs
sed -i '1s/^/#![no_std]\n#![no_main]\norigin_studio::no_problem!();\n\n/' src/main.rs
cargo +nightly run --quiet

This will produce a crate and print "Hello, world!".

Yes, you might say, I could have already done that, with just the first and last commands. But this version uses origin to start and stop the program, and rustix to do the printing. And beyond that, it uses origin to start and stop threads, rustix-futex-sync to do locking for threads, and rustix-dlmalloc to do memory allocation, so it doesn't use libc at all.

Dependencies

~10–18MB
~341K SLoC