Files
RedBear-OS/recipes/dev/rust/recipe.toml
T
vasilito 88b4d06ec2 libc: vendor a Redox-complete fork for waitid/CLD_*/P_*
local/sources/libc is libc 0.2.189 with src/unix/redox/mod.rs extended to
expose the waitid surface relibc already implements:

  - idtype_t (= c_int, as relibc defines it)
  - P_ALL / P_PID / P_PGID
  - CLD_EXITED / KILLED / DUMPED / TRAPPED / STOPPED / CONTINUED
  - extern fn waitid(idtype_t, id_t, *mut siginfo_t, c_int) -> c_int

All of it is real in relibc -- src/header/sys_wait/mod.rs defines the
types and constants, and `nm libc.a` shows `T waitid` -- but the libc
crate's Redox bindings never exposed any of it, and still do not as of
0.2.189. Any crate calling waitid therefore cannot build for
x86_64-unknown-redox:

  error[E0531]: cannot find unit struct, unit variant or constant
                `CLD_EXITED` in crate `libc`

which breaks nix, and through it ctrlc and rustc's bootstrap tooling --
the last thing blocking rust-native.

Values and types come from relibc, not from Linux. Every non-Redox target
is byte-for-byte upstream 0.2.189, so host builds are unaffected. Wired
into the rust workspace via [patch.crates-io]; the fork type-checks for
x86_64-unknown-redox.

Upstream-reportable: this gap belongs in the libc crate.
2026-08-03 18:02:32 +03:00

104 lines
3.6 KiB
TOML

[package]
name = "rust"
version = "0.1.0"
[source]
git = "https://gitlab.redox-os.org/redox-os/rust.git"
branch = "redox-2025-10-03"
shallow_clone = true
patches = [
"01-miri-nix-0.31.patch",
"02-libc-redox-fork.patch"
]
script = """
# ctrlc 3.4.7 pins nix "0.30", and nix 0.30.1 is incompatible with the
# libc 0.2.178 this tree resolves: it declares
# type SaFlags_t = libc::c_ulong;
# while libc now has sigaction.sa_flags and the SA_* constants as c_int,
# so rustc's bootstrap tooling fails to compile with
# error[E0308]: expected `u64`, found `i32` (nix/src/macros.rs:72)
# error[E0308]: expected `i32`, found `u64` (nix/src/sys/signal.rs:808)
# nix 0.31 fixed this by flipping the default to c_int, and ctrlc 3.5
# requires nix "0.31". Move forward to the fixed pair rather than pinning
# libc back, per local/AGENTS.md "Most-recent-upstream-when-building rule".
# Both crates are already in the offline registry cache.
cargo update -p ctrlc --precise 3.5.2 --offline 2>/dev/null || \
cargo update -p ctrlc --precise 3.5.2 || true
"""
[build]
template = "custom"
dependencies = [
"llvm21",
"zlib",
"curl",
"openssl3",
]
dev-dependencies = [
"llvm21.dev",
"llvm21.runtime",
"lld21",
]
script = """
if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ]; then
cat ${COOKBOOK_RECIPE}/config-bootstrap.toml > config.toml
sed -i "s|TARGET|${TARGET}|g" config.toml
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_TOOLCHAIN}|g" config.toml
else
DYNAMIC_INIT
# Linker flags for stage2 compiler (host -> target)
ARCH="${TARGET%%-*}"
export CARGO_TARGET_${ARCH^^}_UNKNOWN_REDOX_RUSTFLAGS="${RUSTFLAGS}" # Rust
# Hack for Rust errorneusly running `llvm-config --version` on cross compiled llvm-config
cat "${COOKBOOK_ROOT}/bin/${TARGET}-llvm-config" > "${COOKBOOK_SYSROOT}/bin/llvm-config"
# Hack for Rust stage1 being dynamically linked with LLVM in prefix toolchain
export LD_LIBRARY_PATH="${COOKBOOK_HOST_SYSROOT}/lib:${LD_LIBRARY_PATH}"
# Linker flags for stage1 compiler (host -> host)
export RUSTFLAGS_BOOTSTRAP="\
-Clink-args=-L${COOKBOOK_HOST_SYSROOT}/lib \
-Clink-args=-Wl,-rpath-link,${COOKBOOK_HOST_SYSROOT}/lib"
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
cat ${COOKBOOK_RECIPE}/config.toml > config.toml
sed -i "s|COOKBOOK_SYSROOT|${COOKBOOK_SYSROOT}|g" config.toml
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_HOST_SYSROOT}|g" config.toml
sed -i "s|COOKBOOK_TARGET|${TARGET}|g" config.toml
sed -i "s|COOKBOOK_GNU_TARGET|${GNU_TARGET}|g" config.toml
fi
# Don't poison the stage1 compiler (host -> host)
unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS CARGO_ENCODED_RUSTFLAGS STRIP
python3 "${COOKBOOK_SOURCE}/x.py" install \
--config config.toml \
--jobs ${COOKBOOK_MAKE_JOBS}
mkdir -p "${COOKBOOK_STAGE}"/usr
rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}"/usr/
rm -rf "${COOKBOOK_STAGE}"/usr/lib/rustlib/*.log
# workaround for rust.lld, needed by e.g. compiling bootloader
# https://github.com/rust-lang/rust/issues/143076#issuecomment-3011710678
LLD_DIR="${COOKBOOK_STAGE}/usr/lib/rustlib/$TARGET/bin"
mkdir -p $LLD_DIR/gcc-ld
cp ${COOKBOOK_SYSROOT}/usr/bin/lld $LLD_DIR/rust-lld
ln -s rust-lld $LLD_DIR/wasm-component-ld
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld.lld
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld64.lld
ln -s ../rust-lld $LLD_DIR/gcc-ld/lld-link
ln -s ../rust-lld $LLD_DIR/gcc-ld/wasm-ld
ln -s ../../../libLLVM.so.21.1 $LLD_DIR/../lib/libLLVM.so.21.1
"""
[[optional-packages]]
name = "doc"
files = [
"usr/share/doc/**",
]