5f7a2f2979
generate-copyright builds COPYRIGHT.html by reading each dependency's
licence files out of the bootstrap vendor directory. In-tree crates are
filtered out earlier (reuse covers them), so everything reaching
load_important_files is assumed to have been vendored.
cargo vendor only vendors REGISTRY sources. The libc fork arrives as a
[patch.crates-io] PATH dependency (02-libc-redox-fork.patch) living at
local/sources/libc, outside the rust tree -- neither in-tree nor
vendored. Joining the vendor root produced a directory that does not
exist, and read_dir failed the whole install step with a bare
Error: I/O Error: Os { code: 2, kind: NotFound }
naming no crate and no path, after the compiler had already built.
A path dependency's licence files live beside its own Cargo.toml, and
for such a crate that directory is the source of truth -- our fork ships
LICENSE-APACHE and LICENSE-MIT there. Falling back to the manifest
directory keeps those notices IN COPYRIGHT.html rather than dropping
them, which matters under the free/libre software policy in
local/AGENTS.md. Suppressing the step would have lost them.
The manifest directory is threaded from get_metadata (which holds the
full cargo_metadata::Package) to load_important_files and dropped again,
so get_metadata_and_notices keeps its existing public return type.
Patch ordering: 03 must follow 02, which introduces the path dependency
that makes it necessary.
Upstream-reportable: any downstream using [patch.crates-io] with a path
source hits this.
108 lines
3.8 KiB
TOML
108 lines
3.8 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",
|
|
# Must come AFTER 02: it exists because 02 introduces the libc fork as a
|
|
# [patch.crates-io] PATH dependency, which generate-copyright cannot find
|
|
# in the bootstrap vendor directory.
|
|
"03-generate-copyright-path-deps.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/**",
|
|
]
|