package mrustc-source { description = "patched mrustc source tree"; exclude = true; version# = "0.12.0"; output = remoteGitHub { suffix = "thepowersgang/mrustc"; tag = "v"+version; checksum = "Db25OAKL_1yZIF6MlXOTHhrEJ-Pd-i-accVtt5rJollmpKm6B3bgS0xN7hoC1cVu"; }; chmod = true; patches = [ "0001-do-not-download-rustc.patch", "0002-Revert-HIR-Typecheck-Optimise-by-doing-multiple-chec.patch", "0003-rustc-src-enable-rustix-use-libc-feature-revert-port.patch", "remove-git-invocations.patch", ]; } package mrustc { description = "alternative rust compiler (re-implementation)"; website = "https://github.com/thepowersgang/mrustc"; anitya = 391250; source = mrustc-source; enterSource = true; writable = true; minimal = true; exec = make { inPlace = true; skipConfigure = true; make = [ "CXX='g++ -w'" ]; // test suite runs during rustc-bootstrap skipCheck = true; install = "install -vD bin/mrustc /work/system/bin/mrustc"; }; inputs = [ bash, // mrustc requires buggy gcc behaviour gcc, ]; runtime = [ gcc ]; } package rustc-bootstrap-source { description = "unpatched bootstrap rust toolchain source tree"; exclude = true; version# = "1.90.0"; output = remoteTar { url = "https://static.rust-lang.org/dist/rustc-"+version+"-src.tar.gz"; compress = gzip; checksum = "kUjk5mOHRc7cTom0uJ5afFTkhFcXLYK8tJl_aqduffGSHc0TH_a-KKz6PI0nk_xK"; }; chmod = true; } package rustc-bootstrap-llvm { description = "bootstrap rustc-standalone LLVM build"; exclude = true; source = rustc-bootstrap-source; exec = cmake { append = [ "src", "llvm-project", "llvm" ]; // Reference $(RUSTCSRC)src/bootstrap/native.rs for these values cache = { "CMAKE_C_COMPILER": "gcc"; "CMAKE_C_FLAGS": "-w"; "CMAKE_CXX_COMPILER": "g++"; "CMAKE_CXX_FLAGS": "-w"; "LLVM_LINK_LLVM_DYLIB": "OFF"; "LLVM_TARGETS_TO_BUILD": "'X86;ARM;AArch64'"; "LLVM_ENABLE_ASSERTIONS": "OFF"; "LLVM_INCLUDE_EXAMPLES": "OFF"; "LLVM_INCLUDE_TESTS": "OFF"; "LLVM_INCLUDE_DOCS": "OFF"; "LLVM_INCLUDE_BENCHMARKS": "OFF"; "LLVM_ENABLE_ZLIB": "OFF"; "LLVM_ENABLE_TERMINFO": "OFF"; "LLVM_ENABLE_LIBEDIT": "OFF"; "WITH_POLLY": "OFF"; "LIBUNWIND_ENABLE_SHARED": "OFF"; }; skipTest = true; }; inputs = [ python-early, gcc, kernel-headers, ]; } package rustc-mrustc { description = "initial rustc stage compiled by mrustc"; exclude = true; source = rustc-bootstrap-source; extra = [ mrustc-source, rustc-bootstrap-llvm, ]; writable = true; early = "cd ../extra/mrustc-source"; minimal = true; exec = make { inPlace = true; skipConfigure = true; preMake = ` LLVM='../rustc-bootstrap-llvm/system/bin/llvm-config' RUSTC_SOURCE='../../rustc-mrustc' export CC=gcc CXX=g++ export PARLEVEL=`+jobsE+` export RUSTC_TARGET="$(uname -m)-unknown-linux-musl" export RUSTC_VERSION="$(cut -d ' ' -f 1 "$RUSTC_SOURCE/version")" export MRUSTC_TARGET_VER="$(cut -d '.' -f 1,2 <<< "$RUSTC_VERSION")" export OUTDIR_SUF="-$RUSTC_VERSION" patch -d "$RUSTC_SOURCE" -p0 < "rustc-$RUSTC_VERSION-src.patch" touch "$RUSTC_SOURCE/dl-version" ln -s "$RUSTC_SOURCE" "rustc-$RUSTC_VERSION-src" mkdir bin && ln -s /system/bin/mrustc bin/ ln -sf gcc /system/bin/cc ln -sf g++ /system/bin/c++ `; make = [ "-f", "minicargo.mk", "CXX='g++ -w'", `LLVM_CONFIG="$LLVM"`, "LIBS", ]; check = [ "CXX='g++ -w'", // run this first to avoid intermittent failures "local_tests", ]; install = ` make \ `+jobsFlagE+` \ `+loadFlagE+` \ CXX='g++ -w' \ test OUTDIR="output-$RUSTC_VERSION" make -f minicargo.mk LLVM_CONFIG="$LLVM" "$OUTDIR/rustc" make -f minicargo.mk LLVM_CONFIG="$LLVM" "$OUTDIR/cargo" mkdir -p /work/system/bin/ (set -o braceexpand && cp "$OUTDIR"/{rustc,cargo} bin/minicargo /work/system/bin/) `; }; inputs = [ bash, perl, patch, mrustc, llvm, ]; runtime = [ gcc, llvm, mrustc ]; } package rustc-bootstrap { description = "early rustc bootstrapped by rustc-mrustc"; exclude = true; source = rustc-bootstrap-source; extra = [ mrustc-source ]; files = { "b00-link-self-contained.patch"; }; writable = true; early = "cd ../extra/mrustc-source"; minimal = true; exec = make { inPlace = true; skipConfigure = true; preMake = ` RUSTC_SOURCE='../../rustc-bootstrap' export RUSTC_TARGET="$(uname -m)-unknown-linux-musl" export RUSTC_VERSION="$(cut -d ' ' -f 1 "$RUSTC_SOURCE/version")" patch -d "$RUSTC_SOURCE" -p0 < "rustc-$RUSTC_VERSION-src.patch" cat /usr/src/*.patch | patch -p1 ln -s "$RUSTC_SOURCE" "rustc-$RUSTC_VERSION-src" mkdir bin "output-$RUSTC_VERSION" (set -o braceexpand && \ ln -s /system/bin/{mrustc,minicargo} bin/ && \ ln -s /system/bin/{rustc,cargo} "output-$RUSTC_VERSION") ln -sf gcc /system/bin/cc ln -sf g++ /system/bin/c++ `; make = [ "-C", "run_rustc", "CC=gcc", "PARLEVEL="+jobsE, ]; }; inputs = [ bash, patch, rustc-mrustc, ]; }