From d9b2aa518315a152891368ec0fdaa823a1368fe2 Mon Sep 17 00:00:00 2001 From: lczyk Date: Thu, 15 Jan 2026 18:20:50 +0000 Subject: [PATCH 1/5] feat: cargo 1.85 --- slices/cargo-1.85.yaml | 33 ++++++++++++++ tests/spread/integration/cargo-1.85/task.yaml | 10 +++++ .../spread/integration/cargo-1.85/test_eza.sh | 45 +++++++++++++++++++ .../integration/cargo-1.85/test_hello.sh | 29 ++++++++++++ .../cargo-1.85/test_hello_crate.sh | 23 ++++++++++ .../cargo-1.85/test_help_and_version.sh | 16 +++++++ .../integration/cargo-1.85/test_sudo.sh | 45 +++++++++++++++++++ .../testfiles/hello_crate/Cargo.toml | 3 ++ .../testfiles/hello_crate/greeter/Cargo.toml | 4 ++ .../testfiles/hello_crate/greeter/src/lib.rs | 3 ++ .../testfiles/hello_crate/hello/Cargo.toml | 6 +++ .../testfiles/hello_crate/hello/src/main.rs | 4 ++ 12 files changed, 221 insertions(+) create mode 100644 slices/cargo-1.85.yaml create mode 100644 tests/spread/integration/cargo-1.85/task.yaml create mode 100755 tests/spread/integration/cargo-1.85/test_eza.sh create mode 100755 tests/spread/integration/cargo-1.85/test_hello.sh create mode 100755 tests/spread/integration/cargo-1.85/test_hello_crate.sh create mode 100755 tests/spread/integration/cargo-1.85/test_help_and_version.sh create mode 100755 tests/spread/integration/cargo-1.85/test_sudo.sh create mode 100644 tests/spread/integration/cargo-1.85/testfiles/hello_crate/Cargo.toml create mode 100644 tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/Cargo.toml create mode 100644 tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/src/lib.rs create mode 100644 tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/Cargo.toml create mode 100644 tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/src/main.rs diff --git a/slices/cargo-1.85.yaml b/slices/cargo-1.85.yaml new file mode 100644 index 000000000..0935fbeac --- /dev/null +++ b/slices/cargo-1.85.yaml @@ -0,0 +1,33 @@ +package: cargo-1.85 + +essential: + - cargo-1.85_copyright + +slices: + # NOTE: Rust calls `cc` to link the final binary, so you will need to create + # the symlink for that to work: + # ln -s gcc /usr/bin/cc + # NOTE: Cargo will call rust through `rustc`, so you will need to create a + # symlink pointing to the correct version of rust: + # ln -s rustc-1.85 /usr/bin/rustc + cargo: + essential: + - libc6_libs + - libcurl3t64-gnutls_libs + - libgcc-s1_libs + - libsqlite3-0_libs + - libssh2-1t64_libs + - libssl3t64_libs + - rustc-1.85_rustc + - zlib1g_libs + contents: + # in the deb this is a bash script that sets RUSTC + # and execs the real binary + # but here we don't want needless dependency on bash + /usr/bin/cargo-1.85: + symlink: ../lib/rust-1.85/bin/cargo + /usr/lib/rust-1.85/bin/cargo: + + copyright: + contents: + /usr/share/doc/cargo-1.85/copyright: diff --git a/tests/spread/integration/cargo-1.85/task.yaml b/tests/spread/integration/cargo-1.85/task.yaml new file mode 100644 index 000000000..0a77f654d --- /dev/null +++ b/tests/spread/integration/cargo-1.85/task.yaml @@ -0,0 +1,10 @@ +summary: Integration tests for cargo-1.85 + +variants: + - eza + - hello_crate + - hello + - help_and_version + - sudo + +execute: bash -ex ./test_${SPREAD_VARIANT}.sh diff --git a/tests/spread/integration/cargo-1.85/test_eza.sh b/tests/spread/integration/cargo-1.85/test_eza.sh new file mode 100755 index 000000000..74f4d7dc5 --- /dev/null +++ b/tests/spread/integration/cargo-1.85/test_eza.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs binutils archiver resolv + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +slices=( + cargo-1.85_cargo + binutils_archiver # the zlib dependency requires ar + ca-certificates_data # for HTTPS access to crates.io +) + +rootfs="$(install-slices --arch "$chisel_arch" "${slices[@]}")" +ln -s gcc "$rootfs/usr/bin/cc" +ln -s rustc-1.85 "$rootfs/usr/bin/rustc" + +# Create minimal /dev/null +mkdir -p "$rootfs/dev" && touch "$rootfs/dev/null" && chmod +x "$rootfs/dev/null" + +# We need DNS to fetch crates.io dependencies +mkdir -p "$rootfs/etc" && cp /etc/resolv.conf "$rootfs/etc/resolv.conf" + +# Enable apt source downloads +# NOTE: we need dpkg-dev to unpack the source +sed -i 's|^Types:.*|Types: deb deb-src|' /etc/apt/sources.list.d/ubuntu.sources +apt update && apt install -y dpkg-dev + +# Download source +( + cd "$rootfs" || exit 1 + apt source rust-eza -y + mv rust-eza-* rust-eza +) + +# Build +chroot "$rootfs" cargo-1.85 -Z unstable-options -C /rust-eza build + +# Verify the built binary works +chroot "$rootfs" /rust-eza/target/debug/eza --help | grep -q "eza \[options\] \[files...\]" +touch "$rootfs/tmp/testfile" +chroot "$rootfs" /rust-eza/target/debug/eza /tmp | grep -q "testfile" diff --git a/tests/spread/integration/cargo-1.85/test_hello.sh b/tests/spread/integration/cargo-1.85/test_hello.sh new file mode 100755 index 000000000..46b28ee28 --- /dev/null +++ b/tests/spread/integration/cargo-1.85/test_hello.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs rustc + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" +ln -s gcc "$rootfs/usr/bin/cc" +ln -s rustc-1.85 "$rootfs/usr/bin/rustc" + +# Create minimal /dev/null +mkdir -p "$rootfs/dev" +touch "$rootfs/dev/null" +chmod +x "$rootfs/dev/null" + +# Use cargo to create, build and run a simple "Hello, world!" program +# (cargo new already creates a hello world program by default) +chroot "$rootfs" cargo new hello --bin + +chroot "$rootfs" cargo -Z unstable-options -C hello build +chroot "$rootfs" ./hello/target/debug/hello | grep -q "Hello, world!" + +# Now in release mode +chroot "$rootfs" cargo -Z unstable-options -C hello build --release +chroot "$rootfs" ./hello/target/release/hello | grep -q "Hello, world!" diff --git a/tests/spread/integration/cargo-1.85/test_hello_crate.sh b/tests/spread/integration/cargo-1.85/test_hello_crate.sh new file mode 100755 index 000000000..97e7b5ff3 --- /dev/null +++ b/tests/spread/integration/cargo-1.85/test_hello_crate.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs rustc + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" +ln -s gcc "$rootfs/usr/bin/cc" +ln -s rustc-1.85 "$rootfs/usr/bin/rustc" + +# Create minimal /dev/null +mkdir -p "$rootfs/dev" +touch "$rootfs/dev/null" +chmod +x "$rootfs/dev/null" + +cp -r testfiles/hello_crate "$rootfs" + +chroot "$rootfs" cargo-1.85 -Z unstable-options -C /hello_crate build --workspace +chroot "$rootfs" ./hello_crate/target/debug/hello | grep -q "Hello, world!" diff --git a/tests/spread/integration/cargo-1.85/test_help_and_version.sh b/tests/spread/integration/cargo-1.85/test_help_and_version.sh new file mode 100755 index 000000000..5e953d9d7 --- /dev/null +++ b/tests/spread/integration/cargo-1.85/test_help_and_version.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" +# ln -s gcc "$rootfs/usr/bin/cc" # not needed for help/version +# ln -s rustc-1.85 "$rootfs/usr/bin/rustc" # not needed for help/version + +chroot "$rootfs" cargo-1.85 --help | grep -q "Rust's package manager" +chroot "$rootfs" cargo-1.85 --version | grep -q 'cargo 1.85' \ No newline at end of file diff --git a/tests/spread/integration/cargo-1.85/test_sudo.sh b/tests/spread/integration/cargo-1.85/test_sudo.sh new file mode 100755 index 000000000..10cd524bd --- /dev/null +++ b/tests/spread/integration/cargo-1.85/test_sudo.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs binutils archiver resolv libpam0g + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +slices=( + cargo-1.85_cargo + binutils_archiver # the zlib dependency requires ar + ca-certificates_data # for HTTPS access to crates.io + libpam0g-dev_libs # sudo-rs dependency +) + +rootfs="$(install-slices --arch "$chisel_arch" "${slices[@]}")" +ln -s gcc "$rootfs/usr/bin/cc" +ln -s rustc-1.85 "$rootfs/usr/bin/rustc" + +# Create minimal /dev/null +mkdir -p "$rootfs/dev" && touch "$rootfs/dev/null" && chmod +x "$rootfs/dev/null" + +# We need DNS to fetch crates.io dependencies +mkdir -p "$rootfs/etc" && cp /etc/resolv.conf "$rootfs/etc/resolv.conf" + +# Enable apt source downloads +# NOTE: we need dpkg-dev to unpack the source +sed -i 's|^Types:.*|Types: deb deb-src|' /etc/apt/sources.list.d/ubuntu.sources +apt update && apt install -y dpkg-dev + +# Download source +( + cd "$rootfs" || exit 1 + apt source rust-sudo-rs -y + mv rust-sudo-rs-* rust-sudo-rs +) + +# Build +chroot "$rootfs" cargo-1.85 -Z unstable-options -C /rust-sudo-rs build + +# Verify the built binary works +(chroot "$rootfs" /rust-sudo-rs/target/debug/sudo --help 2>&1 || true) \ + | grep -q "sudo - run commands as another user" diff --git a/tests/spread/integration/cargo-1.85/testfiles/hello_crate/Cargo.toml b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/Cargo.toml new file mode 100644 index 000000000..5200f77a2 --- /dev/null +++ b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +members = [ "greeter", "hello" ] +resolver = "2" diff --git a/tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/Cargo.toml b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/Cargo.toml new file mode 100644 index 000000000..a2dd0cd24 --- /dev/null +++ b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "greeter" +version = "0.1.0" +edition = "2021" diff --git a/tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/src/lib.rs b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/src/lib.rs new file mode 100644 index 000000000..218d1b109 --- /dev/null +++ b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/greeter/src/lib.rs @@ -0,0 +1,3 @@ +pub fn greet() -> String { + "Hello, world!".to_string() +} diff --git a/tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/Cargo.toml b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/Cargo.toml new file mode 100644 index 000000000..3744b6d63 --- /dev/null +++ b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello" +version = "0.1.0" +edition = "2021" +[dependencies] +greeter = { path = "../greeter" } diff --git a/tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/src/main.rs b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/src/main.rs new file mode 100644 index 000000000..5f2dfdf7b --- /dev/null +++ b/tests/spread/integration/cargo-1.85/testfiles/hello_crate/hello/src/main.rs @@ -0,0 +1,4 @@ +use greeter::greet; +fn main() { + println!("{}", greet()); +} From 5069deda5d1ec569561599c16cdf773877eb07e7 Mon Sep 17 00:00:00 2001 From: lczyk Date: Thu, 15 Jan 2026 18:25:10 +0000 Subject: [PATCH 2/5] Squashed commit of the following: commit c64e1610015124c8f5630fc187b8e2de89ba23e3 Author: lczyk Date: Thu Jan 15 13:58:24 2026 +0000 feat: unglob rustc_driver for rust 1.75 commit 7504d9c2d0d5f937cf37a6fc009c44fea7016bc5 Author: lczyk Date: Thu Jan 15 09:54:36 2026 +0000 feat: unglob rustc_driver commit eebd73475bc16d8f2c4b423bc56f08faa73c835d Author: lczyk Date: Thu Jan 8 16:00:55 2026 +0000 feat: squashed rust 1.85 for 25.10 w/out rust --- slices/libstd-rust-1.75.yaml | 16 +- slices/libstd-rust-1.85-dev.yaml | 16 ++ slices/libstd-rust-1.85.yaml | 43 ++++ slices/rustc-1.85.yaml | 27 +++ tests/spread/integration/rustc-1.85/task.yaml | 9 + .../integration/rustc-1.85/test_hello.sh | 17 ++ .../rustc-1.85/test_help_and_version.sh | 15 ++ .../integration/rustc-1.85/test_static.sh | 22 ++ .../spread/integration/rustc-1.85/test_std.sh | 18 ++ .../rustc-1.85/testfiles/greeter.rs | 16 ++ .../integration/rustc-1.85/testfiles/hello.rs | 3 + .../rustc-1.85/testfiles/test_std.rs | 193 ++++++++++++++++++ .../rustc-1.85/testfiles/use_greeter.c | 9 + tests/spread/integration/rustc/test_static.sh | 2 +- 14 files changed, 404 insertions(+), 2 deletions(-) create mode 100644 slices/libstd-rust-1.85-dev.yaml create mode 100644 slices/libstd-rust-1.85.yaml create mode 100644 slices/rustc-1.85.yaml create mode 100644 tests/spread/integration/rustc-1.85/task.yaml create mode 100755 tests/spread/integration/rustc-1.85/test_hello.sh create mode 100755 tests/spread/integration/rustc-1.85/test_help_and_version.sh create mode 100755 tests/spread/integration/rustc-1.85/test_static.sh create mode 100755 tests/spread/integration/rustc-1.85/test_std.sh create mode 100644 tests/spread/integration/rustc-1.85/testfiles/greeter.rs create mode 100644 tests/spread/integration/rustc-1.85/testfiles/hello.rs create mode 100644 tests/spread/integration/rustc-1.85/testfiles/test_std.rs create mode 100644 tests/spread/integration/rustc-1.85/testfiles/use_greeter.c diff --git a/slices/libstd-rust-1.75.yaml b/slices/libstd-rust-1.75.yaml index 90efed61f..0eccce15c 100644 --- a/slices/libstd-rust-1.75.yaml +++ b/slices/libstd-rust-1.75.yaml @@ -11,7 +11,21 @@ slices: - libllvm17t64_libs - libstdc++6_libs contents: - /usr/lib/*-linux-*/librustc_driver-*.so: + # NOTE: we need the full rustc_driver filename to resolve conflict with other versions + /usr/lib/*-linux-*/librustc_driver-0a253efb3b21d718.so: + arch: [s390x] + /usr/lib/*-linux-*/librustc_driver-10560f0510187e02.so: + arch: [i386] + /usr/lib/*-linux-*/librustc_driver-234e49097c8e48f4.so: + arch: [amd64] + /usr/lib/*-linux-*/librustc_driver-8a394d7514f650d9.so: + arch: [riscv64] + /usr/lib/*-linux-*/librustc_driver-a5a0b7023ef860c2.so: + arch: [arm64] + /usr/lib/*-linux-*/librustc_driver-d7bda1ea61e08e1b.so: + arch: [armhf] + /usr/lib/*-linux-*/librustc_driver-e3378e2a08047ff4.so: + arch: [ppc64el] /usr/lib/*-linux-*/libstd-*.so: /usr/lib/*-linux-*/libtest-*.so: diff --git a/slices/libstd-rust-1.85-dev.yaml b/slices/libstd-rust-1.85-dev.yaml new file mode 100644 index 000000000..c63d9ef85 --- /dev/null +++ b/slices/libstd-rust-1.85-dev.yaml @@ -0,0 +1,16 @@ +package: libstd-rust-1.85-dev + +essential: + - libstd-rust-1.85-dev_copyright + +slices: + libs: + essential: + - libc6_libs + - libstd-rust-1.85_libs + contents: + /usr/lib/rust-1.85/lib/rustlib/*-linux-*/lib/*.rlib: + + copyright: + contents: + /usr/share/doc/libstd-rust-1.85-dev/copyright: diff --git a/slices/libstd-rust-1.85.yaml b/slices/libstd-rust-1.85.yaml new file mode 100644 index 000000000..14f5b3ada --- /dev/null +++ b/slices/libstd-rust-1.85.yaml @@ -0,0 +1,43 @@ +package: libstd-rust-1.85 + +essential: + - libstd-rust-1.85_copyright + +slices: + libs: + essential: + - libc6_libs + - libgcc-s1_libs + - libllvm19_libs + - libstdc++6_libs + contents: + # NOTE: we need the full rustc_driver filename to resolve conflict with other versions + # NOTE: this package does not exist on i386 architecture + /usr/lib/*-linux-*/librustc_driver-081a7347a8720157.so: + arch: [riscv64] + /usr/lib/*-linux-*/librustc_driver-547da00ae0ba7b6a.so: + arch: [amd64] + /usr/lib/*-linux-*/librustc_driver-9509c7723880c99b.so: + arch: [s390x] + /usr/lib/*-linux-*/librustc_driver-a3f37fcbbb6ca438.so: + arch: [armhf] + /usr/lib/*-linux-*/librustc_driver-aaf05b9a58979edc.so: + arch: [ppc64el] + /usr/lib/*-linux-*/librustc_driver-c5a60c0267e4a7d7.so: + arch: [arm64] + /usr/lib/rust-1.85/lib/librustc_driver-081a7347a8720157.so: + arch: [riscv64] + /usr/lib/rust-1.85/lib/librustc_driver-547da00ae0ba7b6a.so: + arch: [amd64] + /usr/lib/rust-1.85/lib/librustc_driver-9509c7723880c99b.so: + arch: [s390x] + /usr/lib/rust-1.85/lib/librustc_driver-a3f37fcbbb6ca438.so: + arch: [armhf] + /usr/lib/rust-1.85/lib/librustc_driver-aaf05b9a58979edc.so: + arch: [ppc64el] + /usr/lib/rust-1.85/lib/librustc_driver-c5a60c0267e4a7d7.so: + arch: [arm64] + + copyright: + contents: + /usr/share/doc/libstd-rust-1.85/copyright: diff --git a/slices/rustc-1.85.yaml b/slices/rustc-1.85.yaml new file mode 100644 index 000000000..c36442ca0 --- /dev/null +++ b/slices/rustc-1.85.yaml @@ -0,0 +1,27 @@ +package: rustc-1.85 + +essential: + - rustc-1.85_copyright + +slices: + # NOTE: Rust compiler needs the target-specific linker to link the final + # binary. The default toolchain included here is using gcc and binutils, + # which are already included in the gcc_gcc essential. + # Rust calls `cc` to link the final binary, so you will need to create + # the symlink for that to work: + # ls -s gcc /usr/bin/cc + rustc: + essential: + - base-files_tmp + - gcc_gcc + - libc6-dev_core + - libc6-dev_libm + - libc6_libs + - libstd-rust-1.85-dev_libs + contents: + /usr/bin/rustc-1.85: # symlink to ../rust-1.85/bin/rustc + /usr/lib/rust-1.85/bin/rustc: + + copyright: + contents: + /usr/share/doc/rustc-1.85/copyright: diff --git a/tests/spread/integration/rustc-1.85/task.yaml b/tests/spread/integration/rustc-1.85/task.yaml new file mode 100644 index 000000000..3b564de40 --- /dev/null +++ b/tests/spread/integration/rustc-1.85/task.yaml @@ -0,0 +1,9 @@ +summary: Integration tests for rustc-1.85 + +variants: + - hello + - help_and_version + - std + - static + +execute: bash -ex ./test_${SPREAD_VARIANT}.sh diff --git a/tests/spread/integration/rustc-1.85/test_hello.sh b/tests/spread/integration/rustc-1.85/test_hello.sh new file mode 100755 index 000000000..710346d56 --- /dev/null +++ b/tests/spread/integration/rustc-1.85/test_hello.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs rustc + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +rootfs="$(install-slices --arch "$chisel_arch" rustc-1.85_rustc)" +ln -s gcc "$rootfs/usr/bin/cc" + +cp testfiles/hello.rs "${rootfs}/hello.rs" + +chroot "${rootfs}" rustc-1.85 /hello.rs -o /hello +chroot "${rootfs}" /hello | grep -q "Hello from Rust!" diff --git a/tests/spread/integration/rustc-1.85/test_help_and_version.sh b/tests/spread/integration/rustc-1.85/test_help_and_version.sh new file mode 100755 index 000000000..5e64949fb --- /dev/null +++ b/tests/spread/integration/rustc-1.85/test_help_and_version.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs rustc + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +rootfs="$(install-slices --arch "$chisel_arch" rustc-1.85_rustc)" +# ln -s gcc "$rootfs/usr/bin/cc" # not needed for help/version + +chroot "${rootfs}/" rustc-1.85 --help | grep -q "Usage: rustc" +chroot "${rootfs}/" rustc-1.85 --version | grep -q 'rustc 1.85' diff --git a/tests/spread/integration/rustc-1.85/test_static.sh b/tests/spread/integration/rustc-1.85/test_static.sh new file mode 100755 index 000000000..38ac6c8de --- /dev/null +++ b/tests/spread/integration/rustc-1.85/test_static.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs rustc + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +rootfs="$(install-slices --arch "$chisel_arch" rustc-1.85_rustc)" +ln -s gcc "$rootfs/usr/bin/cc" + +cp testfiles/greeter.rs "$rootfs/greeter.rs" +cp testfiles/use_greeter.c "$rootfs/use_greeter.c" + +chroot "$rootfs" rustc-1.85 /greeter.rs --crate-type staticlib -o /libgreeter.a +test -f "$rootfs/libgreeter.a" + +# Compile and link C program against the static library +chroot "$rootfs" gcc /use_greeter.c -L/ -lgreeter -o /use_greeter +chroot "$rootfs" /use_greeter | grep -q "Hello to C from Rust static library!" diff --git a/tests/spread/integration/rustc-1.85/test_std.sh b/tests/spread/integration/rustc-1.85/test_std.sh new file mode 100755 index 000000000..db64471ca --- /dev/null +++ b/tests/spread/integration/rustc-1.85/test_std.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# spellchecker: ignore rootfs rustc + +arch=$(uname -m) +case "${arch}" in + aarch64) chisel_arch="arm64" ;; + x86_64) chisel_arch="amd64" ;; + *) echo "Unsupported architecture: ${arch}"; exit 1 ;; +esac + +rootfs="$(install-slices --arch "$chisel_arch" rustc-1.85_rustc)" +ln -s gcc "$rootfs/usr/bin/cc" + + +cp testfiles/test_std.rs "${rootfs}"/test_std.rs + +chroot "${rootfs}" rustc-1.85 /test_std.rs -o /test_std +chroot "${rootfs}" /test_std diff --git a/tests/spread/integration/rustc-1.85/testfiles/greeter.rs b/tests/spread/integration/rustc-1.85/testfiles/greeter.rs new file mode 100644 index 000000000..5acd76c2c --- /dev/null +++ b/tests/spread/integration/rustc-1.85/testfiles/greeter.rs @@ -0,0 +1,16 @@ +#[no_mangle] +pub extern "C" fn greet(who: *const u8) -> *const u8 { + #[cfg(target_arch = "aarch64")] + let c_str = unsafe { std::ffi::CStr::from_ptr(who) }; + #[cfg(not(target_arch = "aarch64"))] + let c_str = unsafe { std::ffi::CStr::from_ptr(who as *const i8) }; + + let name = c_str.to_str().unwrap_or("stranger"); + let greeting = format!("Hello to {} from Rust static library!", name); + let c_greeting = std::ffi::CString::new(greeting).unwrap(); + + #[cfg(target_arch = "aarch64")] + return c_greeting.into_raw(); + #[cfg(not(target_arch = "aarch64"))] + return c_greeting.into_raw() as *const u8; +} diff --git a/tests/spread/integration/rustc-1.85/testfiles/hello.rs b/tests/spread/integration/rustc-1.85/testfiles/hello.rs new file mode 100644 index 000000000..94017d80e --- /dev/null +++ b/tests/spread/integration/rustc-1.85/testfiles/hello.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello from Rust!"); +} diff --git a/tests/spread/integration/rustc-1.85/testfiles/test_std.rs b/tests/spread/integration/rustc-1.85/testfiles/test_std.rs new file mode 100644 index 000000000..f63bfdd1e --- /dev/null +++ b/tests/spread/integration/rustc-1.85/testfiles/test_std.rs @@ -0,0 +1,193 @@ +use std::fs::{self, File}; +use std::io::{Read, Write}; +use std::sync::{Arc, Mutex}; +use std::thread; +use std::collections::HashMap; +use std::time::{Duration, Instant}; + +// each test returns Result<(), String> where Err contains error message +type TestResult = Result<(), String>; +type TestFunc = fn() -> TestResult; + +fn main() { + println!("Running basic standard library checks..."); + + // array of function pointers, and names for reporting + let tests: [(TestFunc, &str); 7] = [ + (check_collections, "Collections"), + (check_arithmetic, "Arithmetic"), + (check_file_io, "File I/O"), + (check_concurrency, "Concurrency"), + (check_mem, "Memory"), + (check_time, "Time"), + (check_env, "Environment Variables and Args"), + ]; + + let mut overall_result: bool = true; + for (i, (test, name)) in tests.iter().enumerate() { + let result = test(); + match result { + Ok(_) => println!("Test {} ({}) passed", i + 1, name), + Err(e) => { + println!("Test {} ({}) failed: {}", i + 1, name, e); + overall_result = false; + } + } + } + + if !overall_result { + println!("Some tests failed."); + std::process::exit(1); + } else { + println!("\nAll basic checks passed!"); + } +} + +fn assert(condition: bool, message: &str) -> TestResult { + if condition { + Ok(()) + } else { + Err(message.to_string()) + } +} + +//////////////////////////////////////////////////////////////////////////////// + +fn check_collections() -> TestResult { + // Test String and Vec + let mut s = String::from("hello"); + s.push_str(" world"); + assert(s == "hello world", "String manipulation failed")?; + + let mut v = Vec::new(); + v.push(1); + v.push(2); + v.push(3); + assert(v == vec![1, 2, 3], "Vector manipulation failed")?; + + // Test HashMap + let mut map = HashMap::new(); + map.insert("key1", 10); + map.insert("key2", 20); + assert(map.get("key1") == Some(&10), "HashMap get failed")?; + assert(map.len() == 2, "HashMap length incorrect")?; + map.remove("key1"); + assert(!map.contains_key("key1"), "HashMap remove failed")?; + + Ok(()) +} + +fn check_arithmetic() -> TestResult { + // Test integer operations + assert(10 + 5 == 15, "Integer addition failed")?; + assert(10 - 5 == 5, "Integer subtraction failed")?; + assert(10 * 5 == 50, "Integer multiplication failed")?; + assert(10 / 5 == 2, "Integer division failed")?; + assert(10 % 3 == 1, "Integer modulus failed")?; + + // Test floating point operations and edge cases + let a = 10.0; + let b = 5.0; + assert(a / b == 2.0, "Floating point division failed")?; + + // Test division by zero results in infinity + let c = 1.0; + let d = 0.0; + assert(c / d == f64::INFINITY, "Division by zero did not yield infinity")?; + Ok(()) +} + +fn check_file_io() -> TestResult { + let filename = "test_file.txt"; + let test_data = "Hello from Rust file I/O!"; + + // Write to a file + let mut file = File::create(filename).map_err(|e| format!("File creation failed: {}", e))?; + file.write_all(test_data.as_bytes()).map_err(|e| format!("File write failed: {}", e))?; + + // Read from the file + let mut file = File::open(filename).map_err(|e| format!("File open failed: {}", e))?; + let mut contents = String::new(); + file.read_to_string(&mut contents).map_err(|e| format!("File read failed: {}", e))?; + assert(contents == test_data, "File contents do not match")?; + + // Clean up + fs::remove_file(filename).map_err(|e| format!("File removal failed: {}", e))?; + Ok(()) +} + +fn check_concurrency() -> TestResult { + let counter = Arc::new(Mutex::new(0)); + let mut handles = vec![]; + + for _ in 0..10 { + let counter_clone = Arc::clone(&counter); + let handle = thread::spawn(move || { + let mut num = counter_clone.lock().unwrap(); + *num += 1; + }); + handles.push(handle); + } + + for handle in handles { + handle.join().map_err(|e| format!("Thread join failed: {:?}", e))?; + } + + assert(*counter.lock().unwrap() == 10, "Counter value incorrect")?; + Ok(()) +} + + +fn check_mem() -> TestResult { + // Test size_of for fundamental types + assert(std::mem::size_of::() == 4, "size_of::() failed")?; + assert(std::mem::size_of::() == 8, "size_of::() failed")?; + + // Test alignment of types + assert(std::mem::align_of::() == 4, "align_of::() failed")?; + assert(std::mem::align_of::() == 8, "align_of::() failed")?; + + // Test a struct with different alignments + // spellchecker: ignore repr + #[repr(C)] + struct AlignedStruct { + a: i8, + b: i32, + } + assert(std::mem::size_of::() == 8, "size_of::() failed")?; + + Ok(()) +} + +fn check_time() -> TestResult { + // Test high-resolution timer + let start = Instant::now(); + let duration = Duration::from_millis(50); + thread::sleep(duration); + let elapsed = start.elapsed(); + assert(elapsed >= duration, &format!("Sleep duration incorrect. Expected at least {:?}, got {:?}", duration, elapsed))?; + + // Test system time + let system_now = std::time::SystemTime::now(); + let since_epoch = system_now.duration_since(std::time::UNIX_EPOCH) + .map_err(|e| format!("System time duration_since failed: {}", e))?; + assert(since_epoch.as_secs() > 1700000000, "System time is likely incorrect or too far in the past")?; + + Ok(()) +} + +fn check_env() -> TestResult { + let test_key = "RUST_TEST_VAR"; + let test_val = "rust_test_value"; + + // Set and get an environment variable + std::env::set_var(test_key, test_val); + let var_val = std::env::var(test_key).map_err(|e| format!("Failed to get env var: {}", e))?; + assert(var_val == test_val, "Failed to get correct environment variable value")?; + + // Test that args() returns at least one element (the program name) + let args: Vec = std::env::args().collect(); + assert(args.len() >= 1, "Command line arguments check failed")?; + + Ok(()) +} diff --git a/tests/spread/integration/rustc-1.85/testfiles/use_greeter.c b/tests/spread/integration/rustc-1.85/testfiles/use_greeter.c new file mode 100644 index 000000000..64052fe2e --- /dev/null +++ b/tests/spread/integration/rustc-1.85/testfiles/use_greeter.c @@ -0,0 +1,9 @@ +#include + +extern const char* greet(const char* who); + +int main() { + const char* message = greet("C"); + printf("%s\n", message); + return 0; +} diff --git a/tests/spread/integration/rustc/test_static.sh b/tests/spread/integration/rustc/test_static.sh index d4a782540..5c58c9251 100755 --- a/tests/spread/integration/rustc/test_static.sh +++ b/tests/spread/integration/rustc/test_static.sh @@ -19,4 +19,4 @@ test -f "$rootfs/libgreeter.a" # Compile and link C program against the static library chroot "$rootfs" gcc /use_greeter.c -L/ -lgreeter -o /use_greeter -chroot "$rootfs" /use_greeter | grep -q "Hello to C from Rust static library!" \ No newline at end of file +chroot "$rootfs" /use_greeter | grep -q "Hello to C from Rust static library!" From 81e87127fe447cb8b1b7bb7b853d134dbf96081b Mon Sep 17 00:00:00 2001 From: lczyk Date: Fri, 16 Jan 2026 08:35:14 +0000 Subject: [PATCH 3/5] feat: hello --- tests/spread/integration/cargo-1.85/test_hello.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/spread/integration/cargo-1.85/test_hello.sh b/tests/spread/integration/cargo-1.85/test_hello.sh index 46b28ee28..1efbe417f 100755 --- a/tests/spread/integration/cargo-1.85/test_hello.sh +++ b/tests/spread/integration/cargo-1.85/test_hello.sh @@ -19,11 +19,11 @@ chmod +x "$rootfs/dev/null" # Use cargo to create, build and run a simple "Hello, world!" program # (cargo new already creates a hello world program by default) -chroot "$rootfs" cargo new hello --bin +chroot "$rootfs" cargo-1.85 new hello --bin -chroot "$rootfs" cargo -Z unstable-options -C hello build +chroot "$rootfs" cargo-1.85 -Z unstable-options -C hello build chroot "$rootfs" ./hello/target/debug/hello | grep -q "Hello, world!" # Now in release mode -chroot "$rootfs" cargo -Z unstable-options -C hello build --release +chroot "$rootfs" cargo-1.85 -Z unstable-options -C hello build --release chroot "$rootfs" ./hello/target/release/hello | grep -q "Hello, world!" From cf1278f240f9cf40b76efb21878868c79de007a0 Mon Sep 17 00:00:00 2001 From: lczyk Date: Fri, 16 Jan 2026 08:35:26 +0000 Subject: [PATCH 4/5] feat: eza workaround --- tests/spread/integration/cargo-1.85/test_eza.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/spread/integration/cargo-1.85/test_eza.sh b/tests/spread/integration/cargo-1.85/test_eza.sh index 74f4d7dc5..b503e58c6 100755 --- a/tests/spread/integration/cargo-1.85/test_eza.sh +++ b/tests/spread/integration/cargo-1.85/test_eza.sh @@ -36,6 +36,18 @@ apt update && apt install -y dpkg-dev mv rust-eza-* rust-eza ) +# error[E0282]: type annotations needed for `Box<_>` +# --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/time-0.3.30/src/format_description/parse/mod.rs:83:9 +# | +# 83 | let items = format_items +# | ^^^^^ +# ... +# 86 | Ok(items.into()) +# | ---- type must be known at this point +# | +# = note: this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update` +chroot "$rootfs" cargo-1.85 -Z unstable-options -C /rust-eza update -p time --precise 0.3.35 + # Build chroot "$rootfs" cargo-1.85 -Z unstable-options -C /rust-eza build From 65e92ec4d7fb682c477f03ae1e7771474a1c95cc Mon Sep 17 00:00:00 2001 From: lczyk Date: Sun, 8 Feb 2026 23:52:50 +0000 Subject: [PATCH 5/5] feat: remove note on cc symlink --- slices/cargo-1.85.yaml | 3 --- tests/spread/integration/cargo-1.85/test_eza.sh | 1 - tests/spread/integration/cargo-1.85/test_hello.sh | 1 - tests/spread/integration/cargo-1.85/test_hello_crate.sh | 1 - tests/spread/integration/cargo-1.85/test_help_and_version.sh | 1 - tests/spread/integration/cargo-1.85/test_sudo.sh | 1 - 6 files changed, 8 deletions(-) diff --git a/slices/cargo-1.85.yaml b/slices/cargo-1.85.yaml index 0935fbeac..f2dc1faf4 100644 --- a/slices/cargo-1.85.yaml +++ b/slices/cargo-1.85.yaml @@ -4,9 +4,6 @@ essential: - cargo-1.85_copyright slices: - # NOTE: Rust calls `cc` to link the final binary, so you will need to create - # the symlink for that to work: - # ln -s gcc /usr/bin/cc # NOTE: Cargo will call rust through `rustc`, so you will need to create a # symlink pointing to the correct version of rust: # ln -s rustc-1.85 /usr/bin/rustc diff --git a/tests/spread/integration/cargo-1.85/test_eza.sh b/tests/spread/integration/cargo-1.85/test_eza.sh index b503e58c6..5b82c20cc 100755 --- a/tests/spread/integration/cargo-1.85/test_eza.sh +++ b/tests/spread/integration/cargo-1.85/test_eza.sh @@ -15,7 +15,6 @@ slices=( ) rootfs="$(install-slices --arch "$chisel_arch" "${slices[@]}")" -ln -s gcc "$rootfs/usr/bin/cc" ln -s rustc-1.85 "$rootfs/usr/bin/rustc" # Create minimal /dev/null diff --git a/tests/spread/integration/cargo-1.85/test_hello.sh b/tests/spread/integration/cargo-1.85/test_hello.sh index 1efbe417f..2392f7c75 100755 --- a/tests/spread/integration/cargo-1.85/test_hello.sh +++ b/tests/spread/integration/cargo-1.85/test_hello.sh @@ -9,7 +9,6 @@ case "${arch}" in esac rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" -ln -s gcc "$rootfs/usr/bin/cc" ln -s rustc-1.85 "$rootfs/usr/bin/rustc" # Create minimal /dev/null diff --git a/tests/spread/integration/cargo-1.85/test_hello_crate.sh b/tests/spread/integration/cargo-1.85/test_hello_crate.sh index 97e7b5ff3..57639b197 100755 --- a/tests/spread/integration/cargo-1.85/test_hello_crate.sh +++ b/tests/spread/integration/cargo-1.85/test_hello_crate.sh @@ -9,7 +9,6 @@ case "${arch}" in esac rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" -ln -s gcc "$rootfs/usr/bin/cc" ln -s rustc-1.85 "$rootfs/usr/bin/rustc" # Create minimal /dev/null diff --git a/tests/spread/integration/cargo-1.85/test_help_and_version.sh b/tests/spread/integration/cargo-1.85/test_help_and_version.sh index 5e953d9d7..d72a66f7d 100755 --- a/tests/spread/integration/cargo-1.85/test_help_and_version.sh +++ b/tests/spread/integration/cargo-1.85/test_help_and_version.sh @@ -9,7 +9,6 @@ case "${arch}" in esac rootfs="$(install-slices --arch "$chisel_arch" cargo-1.85_cargo)" -# ln -s gcc "$rootfs/usr/bin/cc" # not needed for help/version # ln -s rustc-1.85 "$rootfs/usr/bin/rustc" # not needed for help/version chroot "$rootfs" cargo-1.85 --help | grep -q "Rust's package manager" diff --git a/tests/spread/integration/cargo-1.85/test_sudo.sh b/tests/spread/integration/cargo-1.85/test_sudo.sh index 10cd524bd..c8863eb56 100755 --- a/tests/spread/integration/cargo-1.85/test_sudo.sh +++ b/tests/spread/integration/cargo-1.85/test_sudo.sh @@ -16,7 +16,6 @@ slices=( ) rootfs="$(install-slices --arch "$chisel_arch" "${slices[@]}")" -ln -s gcc "$rootfs/usr/bin/cc" ln -s rustc-1.85 "$rootfs/usr/bin/rustc" # Create minimal /dev/null