Compare commits

..
1 Commits
Author SHA1 Message Date
cat 1ff440e936 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 15:17:08 +09:00
2 changed files with 23 additions and 73 deletions
+20 -70
View File
@@ -48,7 +48,7 @@ package mrustc {
}
package rustc-bootstrap-source {
description = "unpatched bootstrap rust toolchain source tree";
description = "rustc source tree used by mrustc";
exclude = true;
version# = "1.90.0";
@@ -60,67 +60,22 @@ package rustc-bootstrap-source {
chmod = true;
}
package rustc-bootstrap-llvm {
description = "bootstrap rustc-standalone LLVM build";
package rustc-bootstrap {
description = "rust toolchain bootstrapped via mrustc";
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,
];
source = mrustc-source;
extra = [ rustc-bootstrap-source ];
enterSource = true;
writable = true;
early = "cd ../extra/mrustc-source";
minimal = true;
exec = make {
inPlace = true;
skipConfigure = true;
preMake = `
LLVM='../rustc-bootstrap-llvm/system/bin/llvm-config'
export CC=gcc CXX=g++
export PARLEVEL=`+jobsE+`
export RUSTC_TARGET="$(uname -m)-unknown-linux-musl"
export RUSTC_SOURCE='../../rustc-mrustc'
export RUSTC_SOURCE='../extra/rustc-bootstrap-source'
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"
@@ -129,44 +84,39 @@ 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",
"CC=gcc",
"CXX='g++ -w'",
`LLVM_CONFIG="$LLVM"`,
"LIBS",
];
check = [
"CC=gcc",
"CXX='g++ -w'",
// run this first to avoid intermittent failures
"test",
"local_tests",
];
install = `
make \
`+jobsFlagE+` \
`+loadFlagE+` \
CXX='g++ -w' \
test
export CC=gcc CXX=g++
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} /work/system/bin/)
make -f minicargo.mk "$OUTDIR/rustc"
make -f minicargo.mk "$OUTDIR/cargo"
make -C run_rustc
`;
};
inputs = [
bash,
perl,
patch,
cmake,
pkg-config,
perl,
python,
mrustc,
llvm,
];
runtime = [ gcc, llvm ];
kernel-headers,
];
}
+3 -3
View File
@@ -1,13 +1,13 @@
diff --git a/Makefile b/Makefile
index bb8e64a4..6bc951a7 100644
index 4317d2c0..415427b4 100644
--- a/Makefile
+++ b/Makefile
@@ -188,7 +188,7 @@ $(OBJDIR)%.o: src/%.cpp
@@ -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="\"Nya, 0 Jan -1 25:71:99 +2928\"" -D VERSION_GIT_ISDIRTY=0
+ $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)