feat: Rust std target + ruststd tests; SYS_EXIT_GROUP; fix mkdir/create under missing parent

This commit is contained in:
daniel committed 2026-10-17 10:30:24 +02:00
1 parent 9e66c3b249
commit e87bd358a6
20 files changed
+657 -97

No files matched your search

+18 -8
View File
@@ -320,22 +320,32 @@ mandelbrot: libc
screenshot: libc libjpegwrite libloader dialogs
$(MAKE) -C src/screenshot
# Rust programs (programs/rust, Phase 1: no_std + alloc via -Zbuild-std).
# Optional: skipped with a notice when no rustup-managed cargo with the
# pinned nightly is installed, so the default build never requires Rust.
# RUSTUP_AUTO_INSTALL=0 keeps 'make' from downloading a toolchain itself.
# Rust programs (programs/rust): std and no_std programs for the built-in
# x86_64-unknown-montauk target of the forked rustc (Phase 2), registered with
# rustup as the 'montauk' toolchain (see programs/rust/README.md). Optional:
# skipped with a notice when that toolchain is missing, so the default build
# never requires Rust. RUSTUP_AUTO_INSTALL=0 keeps 'make' from downloading one.
# Rust links the toolchain sysroot libc (like ports), not lib/libc directly:
# re-run build-montauk-toolchain.sh after libc changes.
# re-run build-montauk-toolchain.sh after libc changes. Cargo tracks neither
# that archive nor a rebuilt std in the linked toolchain, so the programs are
# cleaned (and rebuilt) when either is newer than the last build.
CARGO ?= $(firstword $(wildcard $(HOME)/.cargo/bin/cargo) $(shell command -v cargo 2>/dev/null))
RUST_DIR := rust
RUST_OUT := $(RUST_DIR)/target/x86_64-unknown-montauk/release
RUST_PROGRAMS := rusthello
RUST_PROGRAMS := rusthello ruststd
RUST_LIBC := ../toolchain/sysroot/usr/lib/libc.a
rust:
@if [ -z "$(CARGO)" ] || ! (cd $(RUST_DIR) && RUSTUP_AUTO_INSTALL=0 $(CARGO) --version >/dev/null 2>&1); then \
echo "rust: no nightly cargo found - skipping Rust programs (see programs/rust/README.md)"; \
@if [ -z "$(CARGO)" ] || ! (cd $(RUST_DIR) && RUSTUP_AUTO_INSTALL=0 rustc --print target-list 2>/dev/null | grep -qx x86_64-unknown-montauk); then \
echo "rust: no 'montauk' rustup toolchain - skipping Rust programs (see programs/rust/README.md)"; \
else \
stdlib=$$(cd $(RUST_DIR) && RUSTUP_AUTO_INSTALL=0 rustc --print sysroot)/lib/rustlib/x86_64-unknown-montauk/lib; \
if [ ! -f $(RUST_OUT)/.link-stamp ] || [ $(RUST_LIBC) -nt $(RUST_OUT)/.link-stamp ] || \
[ -n "$$(find $$stdlib -name '*.rlib' -newer $(RUST_OUT)/.link-stamp 2>/dev/null | head -1)" ]; then \
(cd $(RUST_DIR) && RUSTUP_AUTO_INSTALL=0 $(CARGO) clean --release --quiet $(addprefix -p ,$(RUST_PROGRAMS))) || exit 1; \
fi; \
(cd $(RUST_DIR) && RUSTUP_AUTO_INSTALL=0 $(CARGO) build --release) || exit 1; \
touch $(RUST_OUT)/.link-stamp; \
mkdir -p $(BINDIR)/os; \
for p in $(RUST_PROGRAMS); do cp $(RUST_OUT)/$$p $(BINDIR)/os/$$p.elf || exit 1; done; \
fi