mrustc: init
This bootstraps rustc via the mrustc alternative compiler. The build process is extraordinarily ugly because rustc maintainers cargo culted target triple strings without understanding what they are, and completely mishandles them. They also appear to lack fundamental system understanding and assume musl can only be used for static linking. The build process also fails to populate their so called self-contained library directory, so it is manually put together here. This setup uses the vendored LLVM for multiple reasons: the fact that rustc maintainers manage to fuck up so badly they simultaneously pass GCC-only and Clang-only flags when using an LLVM configured to use libc++ instead of GNU slop, and the immense maintenance burden to keep this up to date enough to use Rosa OS LLVM. For now, time and effort saved from trying to mutilate this pile of garbage into working with a proper LLVM build more than compensates for the wasted CPU time. GCC libraries are included in the output because despite the utter reluctance to do dynamic linking correctly on musl, it seems that rustc is also incapable of passing the correct linker flags to produce static executables, and the miserable mrustc Makefiles make it impossible to specify custom linker flags. From my previous experience producing a static virtiofsd build, it would require multiple arguments per library, all of them in rustc's fucked up custom syntax, and I am not ready to deal with that. To avoid contaminating future stages with gcc, this package includes only libraries required at runtime. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
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'
|
||||
export CC=gcc CXX=g++
|
||||
export PARLEVEL=`+jobsE+`
|
||||
export RUSTC_TARGET="$(uname -m)-unknown-linux-musl"
|
||||
export RUSTC_SOURCE='../../rustc-mrustc'
|
||||
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} /work/system/bin/)
|
||||
`;
|
||||
};
|
||||
|
||||
inputs = [
|
||||
bash,
|
||||
perl,
|
||||
patch,
|
||||
mrustc,
|
||||
llvm,
|
||||
];
|
||||
|
||||
runtime = [ gcc, llvm ];
|
||||
}
|
||||
Reference in New Issue
Block a user