push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,176 @@
{
lib,
stdenv,
fetchurl,
mrustc,
mrustc-minicargo,
#llvm_12,
libffi,
cmake,
perl,
python3,
zlib,
libxml2,
pkg-config,
curl,
which,
time,
}:
let
mrustcTargetVersion = "1.54";
rustcVersion = "1.54.0";
rustcSrc = fetchurl {
url = "https://static.rust-lang.org/dist/rustc-${rustcVersion}-src.tar.gz";
sha256 = "0xk9dhfff16caambmwij67zgshd8v9djw6ha0fnnanlv7rii31dc";
};
rustcDir = "rustc-${rustcVersion}-src";
outputDir = "output-${rustcVersion}";
in
stdenv.mkDerivation rec {
pname = "mrustc-bootstrap";
version = "${mrustc.version}_${rustcVersion}";
inherit (mrustc) src;
postUnpack = "tar -xf ${rustcSrc} -C source/";
# the rust build system complains that nix alters the checksums
dontFixLibtool = true;
patches = [
./patches/0001-dont-download-rustc.patch
];
postPatch = ''
echo "applying patch ./rustc-${rustcVersion}-src.patch"
patch -p0 -d ${rustcDir}/ < rustc-${rustcVersion}-src.patch
'';
# rustc unfortunately needs cmake to compile llvm-rt but doesn't
# use it for the normal build. This disables cmake in Nix.
dontUseCmakeConfigure = true;
strictDeps = true;
nativeBuildInputs = [
cmake
mrustc
mrustc-minicargo
perl
pkg-config
python3
time
which
];
buildInputs = [
# for rustc
#llvm_12
libffi
zlib
libxml2
# for cargo
curl
];
makeFlags = [
# Use shared mrustc/minicargo/llvm instead of rebuilding them
"MRUSTC=${mrustc}/bin/mrustc"
#"MINICARGO=${mrustc-minicargo}/bin/minicargo" # FIXME: we need to rebuild minicargo locally so --manifest-overrides is applied
#"LLVM_CONFIG=${llvm_12.dev}/bin/llvm-config"
"RUSTC_TARGET=${stdenv.targetPlatform.rust.rustcTarget}"
];
buildPhase = ''
runHook preBuild
local flagsArray=(
PARLEVEL=$NIX_BUILD_CORES
${toString makeFlags}
)
touch ${rustcDir}/dl-version
export OUTDIR_SUF=-${rustcVersion}
export RUSTC_VERSION=${rustcVersion}
export MRUSTC_TARGET_VER=${mrustcTargetVersion}
export MRUSTC_PATH=${mrustc}/bin/mrustc
echo minicargo.mk: libs
make -f minicargo.mk "''${flagsArray[@]}" LIBS
echo test
make "''${flagsArray[@]}" test
# disabled because it expects ./bin/mrustc
#echo local_tests
#make "''${flagsArray[@]}" local_tests
echo minicargo.mk: rustc
make -f minicargo.mk "''${flagsArray[@]}" ${outputDir}/rustc
echo minicargo.mk: cargo
make -f minicargo.mk "''${flagsArray[@]}" ${outputDir}/cargo
echo run_rustc
make -C run_rustc "''${flagsArray[@]}"
unset flagsArray
runHook postBuild
'';
doCheck = true;
checkPhase = ''
runHook preCheck
run_rustc/${outputDir}/prefix/bin/hello_world | grep "hello, world"
runHook postCheck
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin/ $out/lib/
cp run_rustc/${outputDir}/prefix/bin/cargo $out/bin/cargo
cp run_rustc/${outputDir}/prefix/bin/rustc_binary $out/bin/rustc
cp -r run_rustc/${outputDir}/prefix/lib/* $out/lib/
cp $out/lib/rustlib/${stdenv.targetPlatform.rust.rustcTarget}/lib/*.so $out/lib/
runHook postInstall
'';
meta = with lib; {
inherit (src.meta) homepage;
description = "Minimal build of Rust";
longDescription = ''
A minimal build of Rust, built from source using mrustc.
This is useful for bootstrapping the main Rust compiler without
an initial binary toolchain download.
'';
maintainers = with maintainers; [
progval
r-burns
];
license = with licenses; [
mit
asl20
];
platforms = [ "x86_64-linux" ];
# rustc 1.54 only supports LLVM 12, which was removed from Nixpkgs.
# mrustc can bootstrap up to rustc 1.74, which supported LLVM 17,
# which has also been removed.
#
# 1.74 also shipped with the Cranelift backend, so perhaps that
# could be used instead? Alternatively, it may be possible to
# backport the upstream patches to support LLVM 18 to 1.74.
# Assuming LLVM 18 is still in Nixpkgs by the time you read this
# comment, anyway. But if not, then maybe mrustc has been updated
# to support newer rustc versions? Hope springs eternal.
#
# (Note that you still have to “draw the rest of the owl” to
# bootstrap the chain of rustc versions between this bootstrap
# and the version currently used in Nixpkgs, anyway, so this was
# already not useful for bootstrapping a Rust compiler for use with
# Nixpkgs without a lot of additional work. See Guixs Rust
# bootstrap chain, or the nonRust minimal bootstrap in Guix and
# Nixpkgs, for inspiration.)
broken = true;
};
}

View File

@@ -0,0 +1,60 @@
{
lib,
stdenv,
fetchFromGitHub,
zlib,
}:
let
version = "0.11.2";
tag = "v${version}";
rev = "b6754f574f8846eb842feba4ccbeeecb10bdfacc";
in
stdenv.mkDerivation rec {
pname = "mrustc";
inherit version;
# Always update minicargo.nix and bootstrap.nix in lockstep with this
src = fetchFromGitHub {
owner = "thepowersgang";
repo = "mrustc";
rev = tag;
hash = "sha256-HW9+2mXri3ismeNeaDoTsCY6lxeH8AELegk+YbIn7Jw=";
};
postPatch = ''
sed -i 's/\$(shell git show --pretty=%H -s)/${rev}/' Makefile
sed -i 's/\$(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)/${tag}/' Makefile
sed -i 's/\$(shell git diff-index --quiet HEAD; echo $$?)/0/' Makefile
sed '1i#include <limits>' -i src/trans/codegen_c.cpp
'';
strictDeps = true;
buildInputs = [ zlib ];
enableParallelBuilding = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp bin/mrustc $out/bin
runHook postInstall
'';
meta = with lib; {
description = "Mutabah's Rust Compiler";
mainProgram = "mrustc";
longDescription = ''
In-progress alternative rust compiler, written in C++.
Capable of building a fully-working copy of rustc,
but not yet suitable for everyday use.
'';
inherit (src.meta) homepage;
license = licenses.mit;
maintainers = with maintainers; [
progval
r-burns
];
platforms = [ "x86_64-linux" ];
};
}

View File

@@ -0,0 +1,45 @@
{
lib,
stdenv,
makeWrapper,
mrustc,
}:
stdenv.mkDerivation rec {
pname = "mrustc-minicargo";
inherit (mrustc) src version;
strictDeps = true;
nativeBuildInputs = [ makeWrapper ];
enableParallelBuilding = true;
makefile = "minicargo.mk";
makeFlags = [ "bin/minicargo" ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp bin/minicargo $out/bin
# without it, minicargo defaults to "<minicargo_path>/../bin/mrustc"
wrapProgram "$out/bin/minicargo" --set MRUSTC_PATH ${mrustc}/bin/mrustc
runHook postInstall
'';
meta = with lib; {
description = "Minimalist builder for Rust";
mainProgram = "minicargo";
longDescription = ''
A minimalist builder for Rust, similar to Cargo but written in C++.
Designed to work with mrustc to build Rust projects
(like the Rust compiler itself).
'';
inherit (src.meta) homepage;
license = licenses.mit;
maintainers = with maintainers; [
progval
r-burns
];
platforms = [ "x86_64-linux" ];
};
}

View File

@@ -0,0 +1,14 @@
The $(RUSTC_SRC_DL) file already exists, but for some reason Make wants to rebuild
this target when it has $(RUSTC_SRC_TARBALL) as a dependency.
--- a/minicargo.mk
+++ b/minicargo.mk
@@ -220,7 +220,7 @@ $(RUSTC_SRC_DL): rustc-$(RUSTC_VERSION)-src/extracted rustc-$(RUSTC_VERSION)-src
# - libstd, libpanic_unwind, libtest and libgetopts
# - libproc_macro (mrustc)
ifeq ($(USE_MERGED_BUILD),1)
-$(RUSTCSRC)mrustc-stdlib/Cargo.toml: $(RUSTC_SRC_DL) minicargo.mk
+$(RUSTCSRC)mrustc-stdlib/Cargo.toml: minicargo.mk
@mkdir -p $(dir $@)
@echo "#![no_core]" > $(dir $@)/lib.rs
@echo "[package]" > $@