origin-stduio

Crates.ioorigin-stduio
lib.rsorigin-stduio
version0.1.0
sourcesrc
created_at2023-08-26 15:30:14.46313
updated_at2023-08-26 15:30:14.46313
descriptionProgram startup and thread support written in Rust
homepage
repositoryhttps://github.com/sunfishcode/origin
max_upload_size
id955586
size62,208
Dan Gohman (sunfishcode)

documentation

https://docs.rs/origin

README

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.

Commit count: 202

cargo fmt