mrustc: 0.9 -> 0.10
And switch from Rust 1.29 to 1.54, as this is the top version supported by mrustc
This commit is contained in:
parent
da7761caca
commit
fd3641ec26
4 changed files with 43 additions and 38 deletions
|
@ -3,8 +3,8 @@
|
||||||
, mrustc
|
, mrustc
|
||||||
, mrustc-minicargo
|
, mrustc-minicargo
|
||||||
, rust
|
, rust
|
||||||
, llvm_7
|
, llvm_12
|
||||||
, llvmPackages_7
|
, llvmPackages_12
|
||||||
, libffi
|
, libffi
|
||||||
, cmake
|
, cmake
|
||||||
, python3
|
, python3
|
||||||
|
@ -18,12 +18,14 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
rustcVersion = "1.29.0";
|
mrustcTargetVersion = "1.54";
|
||||||
|
rustcVersion = "1.54.0";
|
||||||
rustcSrc = fetchurl {
|
rustcSrc = fetchurl {
|
||||||
url = "https://static.rust-lang.org/dist/rustc-${rustcVersion}-src.tar.gz";
|
url = "https://static.rust-lang.org/dist/rustc-${rustcVersion}-src.tar.gz";
|
||||||
sha256 = "1sb15znckj8pc8q3g7cq03pijnida6cg64yqmgiayxkzskzk9sx4";
|
sha256 = "0xk9dhfff16caambmwij67zgshd8v9djw6ha0fnnanlv7rii31dc";
|
||||||
};
|
};
|
||||||
rustcDir = "rustc-${rustcVersion}-src";
|
rustcDir = "rustc-${rustcVersion}-src";
|
||||||
|
outputDir = "output-${rustcVersion}";
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
|
@ -37,20 +39,12 @@ stdenv.mkDerivation rec {
|
||||||
dontFixLibtool = true;
|
dontFixLibtool = true;
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
./patches/0001-use-shared-llvm.patch
|
./patches/0001-dont-download-rustc.patch
|
||||||
./patches/0002-dont-build-llvm.patch
|
|
||||||
./patches/0003-echo-newlines.patch
|
|
||||||
./patches/0004-increase-parallelism.patch
|
|
||||||
];
|
];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
echo "applying patch ./rustc-${rustcVersion}-src.patch"
|
echo "applying patch ./rustc-${rustcVersion}-src.patch"
|
||||||
patch -p0 -d ${rustcDir}/ < rustc-${rustcVersion}-src.patch
|
patch -p0 -d ${rustcDir}/ < rustc-${rustcVersion}-src.patch
|
||||||
|
|
||||||
for p in ${lib.concatStringsSep " " llvmPackages_7.compiler-rt.patches}; do
|
|
||||||
echo "applying patch $p"
|
|
||||||
patch -p1 -d ${rustcDir}/src/libcompiler_builtins/compiler-rt < $p
|
|
||||||
done
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# rustc unfortunately needs cmake to compile llvm-rt but doesn't
|
# rustc unfortunately needs cmake to compile llvm-rt but doesn't
|
||||||
|
@ -69,7 +63,7 @@ stdenv.mkDerivation rec {
|
||||||
];
|
];
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
# for rustc
|
# for rustc
|
||||||
llvm_7 libffi zlib libxml2
|
llvm_12 libffi zlib libxml2
|
||||||
# for cargo
|
# for cargo
|
||||||
openssl
|
openssl
|
||||||
(curl.override { inherit openssl; })
|
(curl.override { inherit openssl; })
|
||||||
|
@ -79,7 +73,7 @@ stdenv.mkDerivation rec {
|
||||||
# Use shared mrustc/minicargo/llvm instead of rebuilding them
|
# Use shared mrustc/minicargo/llvm instead of rebuilding them
|
||||||
"MRUSTC=${mrustc}/bin/mrustc"
|
"MRUSTC=${mrustc}/bin/mrustc"
|
||||||
"MINICARGO=${mrustc-minicargo}/bin/minicargo"
|
"MINICARGO=${mrustc-minicargo}/bin/minicargo"
|
||||||
"LLVM_CONFIG=${llvm_7.dev}/bin/llvm-config"
|
"LLVM_CONFIG=${llvm_12.dev}/bin/llvm-config"
|
||||||
"RUSTC_TARGET=${rust.toRustTarget stdenv.targetPlatform}"
|
"RUSTC_TARGET=${rust.toRustTarget stdenv.targetPlatform}"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -91,26 +85,26 @@ stdenv.mkDerivation rec {
|
||||||
${toString makeFlags}
|
${toString makeFlags}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
touch ${rustcDir}/dl-version
|
||||||
|
export OUTDIR_SUF=-${rustcVersion}
|
||||||
|
export RUSTC_VERSION=${rustcVersion}
|
||||||
|
export MRUSTC_TARGET_VER=${mrustcTargetVersion}
|
||||||
|
|
||||||
echo minicargo.mk: libs
|
echo minicargo.mk: libs
|
||||||
make -f minicargo.mk "''${flagsArray[@]}" LIBS
|
make -f minicargo.mk "''${flagsArray[@]}" LIBS
|
||||||
|
|
||||||
echo minicargo.mk: deps
|
echo test
|
||||||
mkdir -p output/cargo-build
|
make "''${flagsArray[@]}" test
|
||||||
# minicargo has concurrency issues when running these; let's build them
|
|
||||||
# without parallelism
|
# disabled because it expects ./bin/mrustc
|
||||||
for crate in regex regex-0.2.11 curl-sys
|
#echo local_tests
|
||||||
do
|
#make "''${flagsArray[@]}" local_tests
|
||||||
echo "building $crate"
|
|
||||||
minicargo ${rustcDir}/src/vendor/$crate \
|
|
||||||
--vendor-dir ${rustcDir}/src/vendor \
|
|
||||||
--output-dir output/cargo-build -L output/
|
|
||||||
done
|
|
||||||
|
|
||||||
echo minicargo.mk: rustc
|
echo minicargo.mk: rustc
|
||||||
make -f minicargo.mk "''${flagsArray[@]}" output/rustc
|
make -f minicargo.mk "''${flagsArray[@]}" ${outputDir}/rustc
|
||||||
|
|
||||||
echo minicargo.mk: cargo
|
echo minicargo.mk: cargo
|
||||||
make -f minicargo.mk "''${flagsArray[@]}" output/cargo
|
make -f minicargo.mk "''${flagsArray[@]}" ${outputDir}/cargo
|
||||||
|
|
||||||
echo run_rustc
|
echo run_rustc
|
||||||
make -C run_rustc "''${flagsArray[@]}"
|
make -C run_rustc "''${flagsArray[@]}"
|
||||||
|
@ -123,17 +117,17 @@ stdenv.mkDerivation rec {
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
run_rustc/output/prefix/bin/hello_world | grep "hello, world"
|
run_rustc/${outputDir}/prefix/bin/hello_world | grep "hello, world"
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
mkdir -p $out/bin/ $out/lib/
|
mkdir -p $out/bin/ $out/lib/
|
||||||
cp run_rustc/output/prefix/bin/cargo $out/bin/cargo
|
cp run_rustc/${outputDir}/prefix/bin/cargo $out/bin/cargo
|
||||||
cp run_rustc/output/prefix/bin/rustc_binary $out/bin/rustc
|
cp run_rustc/${outputDir}/prefix/bin/rustc_binary $out/bin/rustc
|
||||||
|
|
||||||
cp -r run_rustc/output/prefix/lib/* $out/lib/
|
cp -r run_rustc/${outputDir}/prefix/lib/* $out/lib/
|
||||||
cp $out/lib/rustlib/${rust.toRustTarget stdenv.targetPlatform}/lib/*.so $out/lib/
|
cp $out/lib/rustlib/${rust.toRustTarget stdenv.targetPlatform}/lib/*.so $out/lib/
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
version = "0.9";
|
version = "0.10";
|
||||||
tag = "v${version}";
|
tag = "v${version}";
|
||||||
rev = "15773561e40ca5c8cffe0a618c544b6cfdc5ad7e";
|
rev = "b364724f15fd6fce8234ad8add68107c23a22151";
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
|
@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
|
||||||
owner = "thepowersgang";
|
owner = "thepowersgang";
|
||||||
repo = "mrustc";
|
repo = "mrustc";
|
||||||
rev = tag;
|
rev = tag;
|
||||||
sha256 = "194ny7vsks5ygiw7d8yxjmp1qwigd71ilchis6xjl6bb2sj97rd2";
|
sha256 = "0f7kh4n2663sn0z3xib8gzw0s97qpvwag40g2vs3bfjlrbpgi9z0";
|
||||||
};
|
};
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
|
|
|
@ -12,14 +12,14 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
makefile = "minicargo.mk";
|
makefile = "minicargo.mk";
|
||||||
makeFlags = [ "tools/bin/minicargo" ];
|
makeFlags = [ "bin/minicargo" ];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp tools/bin/minicargo $out/bin
|
cp bin/minicargo $out/bin
|
||||||
|
|
||||||
# without it, minicargo defaults to "<minicargo_path>/../../bin/mrustc"
|
# without it, minicargo defaults to "<minicargo_path>/../bin/mrustc"
|
||||||
wrapProgram "$out/bin/minicargo" --set MRUSTC_PATH ${mrustc}/bin/mrustc
|
wrapProgram "$out/bin/minicargo" --set MRUSTC_PATH ${mrustc}/bin/mrustc
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- a/minicargo.mk 2023-04-06 08:26:18.408817572 +0200
|
||||||
|
+++ b/minicargo.mk 2023-04-06 08:27:11.553536996 +0200
|
||||||
|
@@ -176,7 +176,7 @@
|
||||||
|
@echo [CURL] $@
|
||||||
|
@rm -f $@
|
||||||
|
@curl -sS https://static.rust-lang.org/dist/$@ -o $@
|
||||||
|
-$(RUSTC_SRC_DL): $(RUSTC_SRC_TARBALL) rustc-$(RUSTC_VERSION)-src.patch
|
||||||
|
+$(RUSTC_SRC_DL): rustc-$(RUSTC_VERSION)-src.patch
|
||||||
|
tar -xf $(RUSTC_SRC_TARBALL)
|
||||||
|
cd $(RUSTCSRC) && patch -p0 < ../rustc-$(RUSTC_VERSION)-src.patch;
|
||||||
|
touch $(RUSTC_SRC_DL)
|
Loading…
Reference in a new issue