foundry
Foundry OS: the operating system built on the Rustbelt kernel
| author | Grok Bot <grokbot@localhost> | 2026-10-31 18:52:56 -0700 |
|---|---|---|
| commit | 0ffe635cd6a184be44f131a43a33b657615d13ec | |
| parent | 2ca603aac89fc7515b60714f32d6479db6365cbd | |
| tree | browse files at this commit | |
rust/: Cargo workspace (rbsh, coreutils-rs, net, sys) sharing rbrt/ulib.rs Same rustc flags as the kernel's build.rs (static ET_EXEC, code-model=large, panic=abort, opt-level=2, link.ld at 0x80_0040_0000). The shell is now the crate foundry-rbsh with binary 'rbsh' (staged as /bin/sh for contract v1). Only #[path] lines changed in the program sources.
29 files changed, 265 insertions, 20 deletions
@@ -0,0 +1,9 @@+# Cargo reads this file when it runs from rust/ (the Makefile cds here).+[build]+target = "x86_64-unknown-none"++# Same flags as the kernel's build.rs: a static (not position-independent)+# executable, and the "large" code model because the code lives above 4 GiB.+# The linker script is added by rbrt/build.rs (it needs an absolute path).+[target.x86_64-unknown-none]+rustflags = ["-C", "relocation-model=static", "-C", "code-model=large"]
@@ -0,0 +1,19 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 4++[[package]]+name = "foundry-coreutils"+version = "0.1.0"++[[package]]+name = "foundry-net"+version = "0.1.0"++[[package]]+name = "foundry-rbsh"+version = "0.1.0"++[[package]]+name = "foundry-sys"+version = "0.1.0"
@@ -0,0 +1,28 @@+# Foundry OS: the Rust userland, as one Cargo workspace.+#+# Every program is a `no_std` binary for the built-in `x86_64-unknown-none`+# target (no operating-system standard library), linked as a static ET_EXEC+# at Rustbelt's user base 0x80_0040_0000 (see link.ld). The shared runtime+# (syscall wrappers, println!, heap, _start) is rbrt/ulib.rs, which every+# program includes as a module with `#[path = ...] mod ulib;` -- exactly as+# in the kernel repo. Turning rbrt into a real library crate is milestone M1b.+[workspace]+resolver = "3"+members = ["rbsh", "coreutils-rs", "net", "sys"]++[workspace.package]+version = "0.1.0"+edition = "2024"+license = "MIT OR Apache-2.0"+publish = false++# The same code-generation settings the kernel's build.rs passes to rustc:+# -C panic=abort -C opt-level=2 -C debuginfo=0 -C strip=debuginfo.+[profile.release]+panic = "abort"+opt-level = 2+debug = 0+strip = "debuginfo"++[profile.dev]+panic = "abort"
@@ -0,0 +1,64 @@+[package]+name = "foundry-coreutils"+description = "Foundry OS core tools in no_std Rust: ls cat wc grep mkdir rm touch cp sleep"+version.workspace = true+edition.workspace = true+license.workspace = true+publish.workspace = true+build = "../rbrt/build.rs"+autobins = false++[[bin]]+name = "ls"+path = "src/bin/ls.rs"+test = false+bench = false++[[bin]]+name = "cat"+path = "src/bin/cat.rs"+test = false+bench = false++[[bin]]+name = "wc"+path = "src/bin/wc.rs"+test = false+bench = false++[[bin]]+name = "grep"+path = "src/bin/grep.rs"+test = false+bench = false++[[bin]]+name = "mkdir"+path = "src/bin/mkdir.rs"+test = false+bench = false++[[bin]]+name = "rm"+path = "src/bin/rm.rs"+test = false+bench = false++[[bin]]+name = "touch"+path = "src/bin/touch.rs"+test = false+bench = false++[[bin]]+name = "cp"+path = "src/bin/cp.rs"+test = false+bench = false++[[bin]]+name = "sleep"+path = "src/bin/sleep.rs"+test = false+bench = false+
@@ -3,7 +3,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -6,7 +6,7 @@ extern crate alloc; #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use alloc::{format, string::String};
@@ -6,7 +6,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -11,7 +11,7 @@ extern crate alloc; #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use alloc::{format, string::String, vec::Vec};
@@ -3,7 +3,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -4,7 +4,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -4,7 +4,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -4,7 +4,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -4,7 +4,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -0,0 +1,40 @@+[package]+name = "foundry-net"+description = "Foundry OS network tools: ifconfig ping host fetch httpd"+version.workspace = true+edition.workspace = true+license.workspace = true+publish.workspace = true+build = "../rbrt/build.rs"+autobins = false++[[bin]]+name = "ifconfig"+path = "src/bin/ifconfig.rs"+test = false+bench = false++[[bin]]+name = "ping"+path = "src/bin/ping.rs"+test = false+bench = false++[[bin]]+name = "host"+path = "src/bin/host.rs"+test = false+bench = false++[[bin]]+name = "fetch"+path = "src/bin/fetch.rs"+test = false+bench = false++[[bin]]+name = "httpd"+path = "src/bin/httpd.rs"+test = false+bench = false+
@@ -13,7 +13,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use core::fmt::Write;
@@ -9,7 +9,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; fn main() -> i64 {
@@ -17,7 +17,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; extern crate alloc;
@@ -7,7 +7,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::Ip;
@@ -10,7 +10,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; const PAYLOAD: usize = 56; // like Linux's ping: 56 + 8 header = 64 bytes
@@ -0,0 +1,18 @@+# rbrt: the Foundry OS Rust runtime++`ulib.rs` is the tiny runtime every Foundry OS Rust program includes:+raw Rustbelt/Linux syscall wrappers, `print!`/`println!`/`eprintln!`, a+`brk` heap (so `Vec` and `String` work), the `_start` entry point that calls+the program's `fn main() -> i64`, and the panic handler.++For milestone M1 it is still included as a *module* (`#[path = ...] mod ulib;`),+exactly as in the kernel repo, so the programs compile unchanged. Milestone+M1b turns it into a real library crate (`#[macro_export]` macros,+`#[panic_handler]`, `#[global_allocator]`).++`build.rs` here is the build script shared by all packages: it adds+`-T rust/link.ld` to the link.++The kernel repo keeps its own frozen copy of `ulib.rs` for its ABI test+programs (hello, forktest, ...), so the two copies may drift apart; that is+intended.
@@ -0,0 +1,12 @@+//! Shared build script for every Foundry OS Rust program (each package's+//! Cargo.toml says `build = "../rbrt/build.rs"`). It only tells the linker+//! to use rust/link.ld, which puts the program at 0x80_0040_0000.+use std::{env, path::PathBuf};++fn main() {+ let manifest = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());+ let ld = manifest.join("../link.ld").canonicalize().expect("rust/link.ld missing");+ println!("cargo:rustc-link-arg=-T{}", ld.display());+ println!("cargo:rerun-if-changed={}", ld.display());+ println!("cargo:rerun-if-changed=../rbrt/ulib.rs");+}
@@ -0,0 +1,16 @@+[package]+name = "foundry-rbsh"+description = "rbsh, the Foundry OS interactive shell (DOS commands + drive letters). Installed as /bin/sh under boot contract v1."+version.workspace = true+edition.workspace = true+license.workspace = true+publish.workspace = true+build = "../rbrt/build.rs"+autobins = false++[[bin]]+name = "rbsh"+path = "src/main.rs"+test = false+bench = false+
@@ -23,9 +23,9 @@ extern crate alloc; #[macro_use]-#[path = "ulib.rs"]+#[path = "../../rbrt/ulib.rs"] mod ulib;-#[path = "shparse.rs"]+#[path = "parse.rs"] mod shparse; use alloc::{
@@ -0,0 +1,5 @@+# Same toolchain as the Rustbelt kernel repo (nightly + the prebuilt+# x86_64-unknown-none target), so the programs are built by the same compiler.+[toolchain]+channel = "nightly"+targets = ["x86_64-unknown-none"]
@@ -0,0 +1,34 @@+[package]+name = "foundry-sys"+description = "Foundry OS system programs: getty tile random sysinfo"+version.workspace = true+edition.workspace = true+license.workspace = true+publish.workspace = true+build = "../rbrt/build.rs"+autobins = false++[[bin]]+name = "getty"+path = "src/bin/getty.rs"+test = false+bench = false++[[bin]]+name = "tile"+path = "src/bin/tile.rs"+test = false+bench = false++[[bin]]+name = "random"+path = "src/bin/random.rs"+test = false+bench = false++[[bin]]+name = "sysinfo"+path = "src/bin/sysinfo.rs"+test = false+bench = false+
@@ -21,7 +21,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -11,7 +11,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; use ulib::*;
@@ -9,7 +9,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; fn main() -> i64 {
@@ -19,7 +19,7 @@ #![no_main] #[macro_use]-#[path = "ulib.rs"]+#[path = "../../../rbrt/ulib.rs"] mod ulib; extern crate alloc;