Unverified Commit 7a0e2484 authored by Ryan Lahfa's avatar Ryan Lahfa Committed by GitHub
Browse files

Merge pull request #224970 from progval/mrustc-0.10

mrustc: 0.9 -> 0.10
parents 3ffcae9a 9faa0704
Loading
Loading
Loading
Loading
+28 −33
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@
, mrustc
, mrustc-minicargo
, rust
, llvm_7
, llvmPackages_7
, llvm_12
, llvmPackages_12
, libffi
, cmake
, python3
@@ -18,12 +18,14 @@
}:

let
  rustcVersion = "1.29.0";
  mrustcTargetVersion = "1.54";
  rustcVersion = "1.54.0";
  rustcSrc = fetchurl {
    url = "https://static.rust-lang.org/dist/rustc-${rustcVersion}-src.tar.gz";
    sha256 = "1sb15znckj8pc8q3g7cq03pijnida6cg64yqmgiayxkzskzk9sx4";
    sha256 = "0xk9dhfff16caambmwij67zgshd8v9djw6ha0fnnanlv7rii31dc";
  };
  rustcDir = "rustc-${rustcVersion}-src";
  outputDir = "output-${rustcVersion}";
in

stdenv.mkDerivation rec {
@@ -37,20 +39,12 @@ stdenv.mkDerivation rec {
  dontFixLibtool = true;

  patches = [
    ./patches/0001-use-shared-llvm.patch
    ./patches/0002-dont-build-llvm.patch
    ./patches/0003-echo-newlines.patch
    ./patches/0004-increase-parallelism.patch
    ./patches/0001-dont-download-rustc.patch
  ];

  postPatch = ''
    echo "applying patch ./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
@@ -69,7 +63,7 @@ stdenv.mkDerivation rec {
  ];
  buildInputs = [
    # for rustc
    llvm_7 libffi zlib libxml2
    llvm_12 libffi zlib libxml2
    # for cargo
    openssl
    (curl.override { inherit openssl; })
@@ -78,8 +72,8 @@ stdenv.mkDerivation rec {
  makeFlags = [
    # Use shared mrustc/minicargo/llvm instead of rebuilding them
    "MRUSTC=${mrustc}/bin/mrustc"
    "MINICARGO=${mrustc-minicargo}/bin/minicargo"
    "LLVM_CONFIG=${llvm_7.dev}/bin/llvm-config"
    #"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=${rust.toRustTarget stdenv.targetPlatform}"
  ];

@@ -91,26 +85,27 @@ stdenv.mkDerivation rec {
      ${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 minicargo.mk: deps
    mkdir -p output/cargo-build
    # minicargo has concurrency issues when running these; let's build them
    # without parallelism
    for crate in regex regex-0.2.11 curl-sys
    do
      echo "building $crate"
      minicargo ${rustcDir}/src/vendor/$crate \
        --vendor-dir ${rustcDir}/src/vendor \
        --output-dir output/cargo-build -L output/
    done
    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[@]}" output/rustc
    make -f minicargo.mk "''${flagsArray[@]}" ${outputDir}/rustc

    echo minicargo.mk: cargo
    make -f minicargo.mk "''${flagsArray[@]}" output/cargo
    make -f minicargo.mk "''${flagsArray[@]}" ${outputDir}/cargo

    echo run_rustc
    make -C run_rustc "''${flagsArray[@]}"
@@ -123,17 +118,17 @@ stdenv.mkDerivation rec {
  doCheck = true;
  checkPhase = ''
    runHook preCheck
    run_rustc/output/prefix/bin/hello_world | grep "hello, world"
    run_rustc/${outputDir}/prefix/bin/hello_world | grep "hello, world"
    runHook postCheck
  '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin/ $out/lib/
    cp run_rustc/output/prefix/bin/cargo $out/bin/cargo
    cp run_rustc/output/prefix/bin/rustc_binary $out/bin/rustc
    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/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/
    runHook postInstall
  '';
+3 −3
Original line number Diff line number Diff line
@@ -4,9 +4,9 @@
}:

let
  version = "0.9";
  version = "0.10";
  tag = "v${version}";
  rev = "15773561e40ca5c8cffe0a618c544b6cfdc5ad7e";
  rev = "b364724f15fd6fce8234ad8add68107c23a22151";
in

stdenv.mkDerivation rec {
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
    owner = "thepowersgang";
    repo = "mrustc";
    rev = tag;
    sha256 = "194ny7vsks5ygiw7d8yxjmp1qwigd71ilchis6xjl6bb2sj97rd2";
    sha256 = "0f7kh4n2663sn0z3xib8gzw0s97qpvwag40g2vs3bfjlrbpgi9z0";
  };

  postPatch = ''
+3 −3
Original line number Diff line number Diff line
@@ -12,14 +12,14 @@ stdenv.mkDerivation rec {

  enableParallelBuilding = true;
  makefile = "minicargo.mk";
  makeFlags = [ "tools/bin/minicargo" ];
  makeFlags = [ "bin/minicargo" ];

  installPhase = ''
    runHook preInstall
    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
    runHook postInstall
  '';
+14 −0
Original line number Diff line number Diff line
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	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)
+0 −12
Original line number Diff line number Diff line
--- a/rustc-1.29.0-src/src/librustc_llvm/lib.rs
--- b/rustc-1.29.0-src/src/librustc_llvm/lib.rs
@@ -23,6 +23,9 @@
 #![feature(link_args)]
 #![feature(static_nobundle)]
 
+// https://github.com/rust-lang/rust/issues/34486
+#[link(name = "ffi")] extern {}
+
 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
 #[allow(unused_extern_crates)]
 extern crate rustc_cratesio_shim;
Loading