From 447dce99da1a92c0efa2810ae9e9d592152a7586 Mon Sep 17 00:00:00 2001 From: David Craven Date: Tue, 7 Jun 2016 20:53:25 +0200 Subject: [PATCH] rustc: Enable crosscompiling std crates --- pkgs/development/compilers/rustc/beta.nix | 4 ++- pkgs/development/compilers/rustc/generic.nix | 29 ++++---------------- pkgs/development/compilers/rustc/head.nix | 4 ++- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/pkgs/development/compilers/rustc/beta.nix b/pkgs/development/compilers/rustc/beta.nix index 7dbd8ae7a69..363dc71c02d 100644 --- a/pkgs/development/compilers/rustc/beta.nix +++ b/pkgs/development/compilers/rustc/beta.nix @@ -1,4 +1,4 @@ -{ stdenv, callPackage, rustcStable }: +{ stdenv, callPackage, rustcStable, targets ? [], targetToolchains ? [] }: callPackage ./generic.nix { shortVersion = "beta-1.10.0"; @@ -9,4 +9,6 @@ callPackage ./generic.nix { patches = [ ./patches/disable-lockfile-check.patch ] ++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch; rustc = rustcStable; + inherit targets; + inherit targetToolchains; } diff --git a/pkgs/development/compilers/rustc/generic.nix b/pkgs/development/compilers/rustc/generic.nix index 42deddd9e1d..a08843f494e 100644 --- a/pkgs/development/compilers/rustc/generic.nix +++ b/pkgs/development/compilers/rustc/generic.nix @@ -7,22 +7,10 @@ , srcSha, srcRev , configureFlags ? [] , patches +, targets +, targetToolchains } @ args: -/* Rust's build process has a few quirks : - -- The Rust compiler is written is Rust, so it requires a bootstrap - compiler, which is downloaded during the build. To make the build - pure, we download it ourself before and put it where it is - expected. Once the language is stable (1.0) , we might want to - switch it to use nix's packaged rust compiler. This might not be possible - as the compiler is highly coupled to the bootstrap. - -NOTE : some derivation depend on rust. When updating this, please make -sure those derivations still compile. (racer, for example). - -*/ - let version = if isRelease then "${shortVersion}" @@ -35,15 +23,7 @@ let llvmShared = llvm.override { enableSharedLibraries = true; }; - target = if stdenv.system == "i686-linux" - then "i686-unknown-linux-gnu" - else if stdenv.system == "x86_64-linux" - then "x86_64-unknown-linux-gnu" - else if stdenv.system == "i686-darwin" - then "i686-apple-darwin" - else if stdenv.system == "x86_64-darwin" - then "x86_64-apple-darwin" - else abort "no snapshot to bootstrap for this platform (missing target triple)"; + target = builtins.replaceStrings [" "] [","] (builtins.toString targets); meta = with stdenv.lib; { homepage = http://www.rust-lang.org/; @@ -75,9 +55,11 @@ stdenv.mkDerivation { # ++ [ "--jemalloc-root=${jemalloc}/lib" ++ [ "--default-linker=${stdenv.cc}/bin/cc" "--default-ar=${binutils.out}/bin/ar" ] ++ stdenv.lib.optional (stdenv.cc.cc ? isClang) "--enable-clang" + ++ stdenv.lib.optional (targets != []) "--target=${target}" ++ stdenv.lib.optional (!forceBundledLLVM) "--llvm-root=${llvmShared}"; inherit patches; + passthru.target = target; postPatch = '' substituteInPlace src/rust-installer/gen-install-script.sh \ @@ -125,4 +107,5 @@ stdenv.mkDerivation { preCheck = "export TZDIR=${tzdata}/share/zoneinfo"; doCheck = true; + dontSetConfigureCross = true; } diff --git a/pkgs/development/compilers/rustc/head.nix b/pkgs/development/compilers/rustc/head.nix index 8d9373eb3c3..aa32416c649 100644 --- a/pkgs/development/compilers/rustc/head.nix +++ b/pkgs/development/compilers/rustc/head.nix @@ -1,5 +1,5 @@ # Please make sure to check if rustfmt still builds when updating nightly -{ stdenv, callPackage, rustcStable }: +{ stdenv, callPackage, rustcStable, targets ? [], targetToolchains ? [] }: callPackage ./generic.nix { shortVersion = "master-1.11.0"; @@ -10,4 +10,6 @@ callPackage ./generic.nix { ./patches/use-rustc-1.9.0.patch ] ++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch; rustc = rustcStable; + inherit targets; + inherit targetToolchains; }