1DOLLY 72TOOLCHAIN rust-build3REQUIRES HOST runtime@04REQUIRES HOST display@05REQUIRES HOST input@06REQUIRES HOST dso@07REQUIRES HOST http@08REQUIRES HOST threads@0910# Rust as Dolly builds it: rustc, its standard library and Cargo, compiled11# here from their pinned sources. The seed builds the first rustc; that one12# builds the rustc kept. Every Rust program in the catalog is built by this13# image's toolchain.14FROM /v0.1.2/demos/rust/Dollyfile-rust-sdk 66ef91c4215f57973965f6740bb338ccc260d3e767bbf4a95ed5bee2cf4daa9015COPY /v0.1.2/demos/rust/Dollyfile-rust-llvm 75887a20e72661a6feac938b8e0b49e354385530b07b131eb233bddb5d7d6d0f /opt/rust-llvm /opt/rust-llvm16# cmp, for the check that the second generation rebuilds the same library.17INSTALL /v0.1.2/Dollyfile-posix f86fffdfdd22e67543d0c8f787f3623f6cf1953f89242a0da66ae287d21a9ec218REQUIRES TOOL cargo19REQUIRES TOOL rustc20REQUIRES TOOL cc21REQUIRES TOOL cmp22REQUIRES TOOL gzip23REQUIRES TOOL tar24REQUIRES TOOL cp25REQUIRES TOOL mkdir26REQUIRES TOOL rm2728# rustc's and std's source as the seed's build prepared it, their locked29# crates as Cargo's directory source, and the build's settings in30# /tmp/rustc/.cargo/config.toml.31SOURCE /v0.1.2/dist/static/rust/rustc.tar.gz f0b868e4ae64c9842939247250b3e7cb0fa623aab823112994e5bd00cdc9c536 /tmp/rustc.tar.gz32SLOP gzip -dc /tmp/rustc.tar.gz | tar -xf - -C /33SLOP rm /tmp/rustc.tar.gz3435# One generation: the compiler, built by the rustc in /opt/rust-sdk against the36# standard library there, replaces that rustc. It is linked as a host of37# procedural-macro libraries, with room for its data.38FILE /tmp/rustc/compiler.slop39    cd /tmp/rustc/source40    RUSTC_BOOTSTRAP=1 cargo rustc -j 4 --offline -p rustc-main --bin rustc-main --features llvm --target-dir /tmp/rustc/target -- -C link-arg=-rdynamic -C link-arg=-Wl,--initial-memory=3355443241    cp /tmp/rustc/target/debug/rustc-main /opt/rust-sdk/bin/rustc-real42    rm -rf /tmp/rustc/target43# The standard library by the rustc in /opt/rust-sdk, left in44# /tmp/rustc/sdk-target. Cargo's build-std reads the source below the sysroot45# and builds it for a crate.46FILE /tmp/rustc/std.slop47    cd /tmp/rustc/sdk48    rm -rf /tmp/rustc/sdk-target49    RUSTC_BOOTSTRAP=1 RUSTFLAGS="-C relocation-model=pic -C embed-bitcode=yes" cargo build -j 4 --offline --lib --target /opt/rust-sdk/wasm64-emscripten-probe.json -Z json-target-spec -Z build-std=std,panic_abort,proc_macro --target-dir /tmp/rustc/sdk-target50    rm /tmp/rustc/sdk-target/wasm64-emscripten-probe/debug/deps/libdolly_rust_sdk-*51FILE /tmp/rustc/sdk/Cargo.toml52    [package]53    name = "dolly-rust-sdk"54    version = "0.0.0"55    edition = "2024"56    [workspace]57FILE /tmp/rustc/sdk/src/lib.rs58    // Built for its dependency: the standard library.59SLOP mkdir -p /opt/rust-sdk/lib/rustlib/src/rust60SLOP cp -R /tmp/rustc/source/library /opt/rust-sdk/lib/rustlib/src/rust/library6162# The first generation is the seed's work and links the seed's standard63# library. Its own standard library replaces the seed's.64SLOP slop -e /tmp/rustc/compiler.slop65SLOP slop -e /tmp/rustc/std.slop66SLOP slop -c 'rm /opt/rust-sdk/lib/rustlib/wasm64-emscripten-probe/lib/*.rlib'67SLOP slop -c 'cp /tmp/rustc/sdk-target/wasm64-emscripten-probe/debug/deps/*.rlib /opt/rust-sdk/lib/rustlib/wasm64-emscripten-probe/lib'68# The second generation is built by the first from the same source and holds69# nothing of the seed: it is the rustc this image keeps. The standard library70# it builds must be, byte for byte, the one installed.71SLOP slop -e /tmp/rustc/compiler.slop72SLOP slop -e /tmp/rustc/std.slop73SLOP CWD /tmp/rustc/sdk-target/wasm64-emscripten-probe/debug/deps slop -e -c 'for library in *.rlib; do cmp "$library" "/opt/rust-sdk/lib/rustlib/wasm64-emscripten-probe/lib/$library"; done'74SLOP rm -rf /tmp/rustc /opt/rust-llvm /opt/rust-sdk/lib/rustlib/src7576# Cargo, by the kept compiler and library; the seed's Cargo drives its last build.77SOURCE /v0.1.2/dist/static/rust/cargo.tar.gz 6bf320264ef2386bd56bb5b59ea0f0a15d26018218bcafe7d62aa9219a957945 /tmp/cargo.tar.gz78SLOP gzip -dc /tmp/cargo.tar.gz | tar -xf - -C /79SLOP rm /tmp/cargo.tar.gz80SLOP CWD /tmp/cargo/source cargo build -j 4 --offline --bin cargo --target-dir /tmp/cargo/build81SLOP cp /tmp/cargo/build/debug/cargo /usr/bin/cargo82SLOP mkdir -p /usr/share/licenses/cargo /usr/share/dolly/builds83SLOP cp /tmp/cargo/source/LICENSE-MIT /usr/share/licenses/cargo/LICENSE-MIT84SLOP cp /tmp/cargo/source/LICENSE-APACHE /usr/share/licenses/cargo/LICENSE-APACHE85SLOP cp /tmp/cargo/source/LICENSE-THIRD-PARTY /usr/share/licenses/cargo/LICENSE-THIRD-PARTY86SLOP cp /tmp/cargo/vendor/libgit2-sys-0.18.5+1.9.4/libgit2/COPYING /usr/share/licenses/cargo/libgit2-COPYING87SLOP cp /tmp/cargo/source/Cargo.lock /usr/share/dolly/builds/cargo.lock88SLOP rm -rf /tmp/cargo8990# The SDK's members are this recipe's now, not the seed's.91EXPORTS FOLDER rust-sdk /opt/rust-sdk92EXPORTS FOLDER rust-licenses /usr/share/licenses/rust93EXPORTS FOLDER cargo-licenses /usr/share/licenses/cargo94FILE /usr/share/dolly/builds/cargo.lock95SLOP rustc --version --verbose96SLOP cargo --version9798# The built toolchain builds and runs a program that uses a procedural macro.99FILE /tmp/rust-check/Cargo.toml100    [workspace]101    members = ["twice", "check"]102    resolver = "3"103FILE /tmp/rust-check/twice/Cargo.toml104    [package]105    name = "twice"106    version = "0.1.0"107    edition = "2024"108    [lib]109    proc-macro = true110FILE /tmp/rust-check/twice/src/lib.rs111    use proc_macro::TokenStream;112    #[proc_macro]113    pub fn twice(input: TokenStream) -> TokenStream {114        format!("({0}) + ({0})", input).parse().unwrap()115    }116FILE /tmp/rust-check/check/Cargo.toml117    [package]118    name = "check"119    version = "0.1.0"120    edition = "2024"121    [dependencies]122    twice = { path = "../twice" }123FILE /tmp/rust-check/check/src/main.rs124    fn main() { println!("built by cargo: {}", twice::twice!(21)); }125SLOP CWD /tmp/rust-check cargo build --offline126SLOP /tmp/rust-check/target/debug/check127SLOP rm -rf /tmp/rust-check128129ENTRY /bin/foreground -i /bin/slop130