Compare commits

..
1 Commits
Author SHA1 Message Date
cat 60e0030e9b mrustc: init
This contains some extraordinarily ugly hacks for a set of even uglier
Makefiles.

Signed-off-by: Ophestra <cat@gensokyo.uk>
2026-07-19 13:56:15 +09:00
2 changed files with 82 additions and 30 deletions
+69 -30
View File
@@ -1,3 +1,51 @@
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",
"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 = "rustc source tree used by mrustc";
exclude = true;
@@ -11,32 +59,20 @@ package rustc-bootstrap-source {
chmod = true;
}
package mrustc {
description = "alternative rust compiler (re-implementation)";
website = "https://github.com/thepowersgang/mrustc";
anitya = 391250;
package rustc-bootstrap {
description = "rust toolchain bootstrapped via mrustc";
exclude = true;
version# = "0.12.0";
source = remoteGitHub {
suffix = "thepowersgang/mrustc";
tag = "v"+version;
checksum = "Db25OAKL_1yZIF6MlXOTHhrEJ-Pd-i-accVtt5rJollmpKm6B3bgS0xN7hoC1cVu";
};
patches = [
"0001-do-not-download-rustc.patch",
"0002-Revert-HIR-Typecheck-Optimise-by-doing-multiple-chec.patch",
];
source = mrustc-source;
extra = [ rustc-bootstrap-source ];
enterSource = true;
writable = true;
chmod = true;
exec = make {
inPlace = true;
skipConfigure = true;
preMake = `
export CC=gcc CXX=g++
export PARLEVEL=`+jobsE+`
export RUSTC_SOURCE='../extra/rustc-bootstrap-source'
export RUSTC_VERSION="$(cut -d ' ' -f 1 "$RUSTC_SOURCE/version")"
@@ -44,21 +80,26 @@ 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"
sed -i 's/\$(shell git show --pretty=%H -s --no-show-signature)/unknown/' Makefile
sed -i 's/\$(shell git show -s --pretty=%h --no-show-signature)/unknown/' Makefile
sed -i 's/\$(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)/v`+version+`/' Makefile
sed -i 's/\$(shell git diff-index --quiet HEAD; echo $$?)/0/' Makefile
sed -i 's/\$(shell env LC_TIME=C date -u +"%a, %e %b %Y %T +0000")/Thu, 1 Jan 1970 00:00:00 +0000/' Makefile
ln -s "$RUSTC_SOURCE" "rustc-$RUSTC_VERSION-src"
mkdir bin && ln -s /system/bin/mrustc bin/
`;
preCheck = `
make -f minicargo.mk LIBS
make local_tests
`;
check = [ "test" ];
make = [
"-f",
"minicargo.mk",
"CC=gcc",
"CXX='g++ -w'",
"LIBS",
];
check = [
"CC=gcc",
"CXX='g++ -w'",
"test",
"local_tests",
];
install = `
export CC=gcc CXX=g++
OUTDIR="output-$RUSTC_VERSION"
make -f minicargo.mk "$OUTDIR/rustc"
make -f minicargo.mk "$OUTDIR/cargo"
@@ -73,9 +114,7 @@ make -C run_rustc
pkg-config,
perl,
python,
// mrustc requires buggy gcc behaviour
gcc,
mrustc,
kernel-headers,
];
+13
View File
@@ -0,0 +1,13 @@
diff --git a/Makefile b/Makefile
index 4317d2c0..415427b4 100644
--- a/Makefile
+++ b/Makefile
@@ -187,7 +187,7 @@ $(OBJDIR)%.o: src/%.cpp
$(OBJDIR)version.o: $(OBJDIR)%.o: src/%.cpp $(filter-out $(OBJDIR)version.o,$(OBJ)) Makefile
@+mkdir -p $(dir $@)
@echo [CXX] -o $@
- $V$(CXX) -o $@ -c $< $(CXXFLAGS) $(CPPFLAGS) -MMD -MP -MF $@.dep -D VERSION_GIT_FULLHASH=\"$(shell git show --pretty=%H -s --no-show-signature)\" -D VERSION_GIT_BRANCH="\"$(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)\"" -D VERSION_GIT_SHORTHASH=\"$(shell git show -s --pretty=%h --no-show-signature)\" -D VERSION_BUILDTIME="\"$(shell env LC_TIME=C date -u +"%a, %e %b %Y %T +0000")\"" -D VERSION_GIT_ISDIRTY=$(shell git diff-index --quiet HEAD; echo $$?)
+ $V$(CXX) -o $@ -c $< $(CXXFLAGS) $(CPPFLAGS) -MMD -MP -MF $@.dep -D VERSION_GIT_FULLHASH=\"unknown\" -D VERSION_GIT_BRANCH="\"v0.12.0\"" -D VERSION_GIT_SHORTHASH=\"unknown\" -D VERSION_BUILDTIME="\"Thu, 1 Jan 1970 00:00:00 +0000\"" -D VERSION_GIT_ISDIRTY=0
src/main.cpp: $(PCHS:%=src/%.gch)