Skip to content

Instantly share code, notes, and snippets.

@sbourdeauducq
Created August 17, 2018 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbourdeauducq/f828cd8df901916e4bfcf0a35944b568 to your computer and use it in GitHub Desktop.
Save sbourdeauducq/f828cd8df901916e4bfcf0a35944b568 to your computer and use it in GitHub Desktop.
# FIXME: Should be rewritten to use the same structure as nixpkgs rustc.
{ stdenv, targetPackages
, fetchFromGitHub, configureFlags ? []
, llvm-or1k, cmake, curl, cacert, git, which, libffi
, ncurses, file, python2, pkgconfig, openssl
}:
stdenv.mkDerivation {
name = "rustc_or1k-1.28.0";
src = fetchFromGitHub {
rev = "f305fb024318e96997fbe6e4a105b0cc1052aad4";
sha256 = "03lfps3xvvv7wv1nnwn3n1ji13z099vx8c3fpbzp9rnasrwzp5jy";
owner = "m-labs";
repo = "rust";
fetchSubmodules = true;
};
buildInputs = [ llvm-or1k file python2 git curl cacert cmake which libffi pkgconfig openssl ];
# rustc complains about modified source files otherwise
dontUpdateAutotoolsGnuConfigScripts = true;
# HACK: rustc downloads and uses bootstrap cargo to build, which requires ~/.cargo
preConfigure = ''
export HOME=$(mktemp -d)
'';
configureFlags = configureFlags
#++ [ "--enable-rpath" ]
++ [ "--default-linker=${targetPackages.stdenv.cc}/bin/cc" ]
++ [ "--enable-llvm-link-shared" ]
++ [ "--disable-docs" ]
++ [ "--disable-manage-submodules" ]
++ [ "--enable-extended" ]
++ [ "--llvm-root=${llvm-or1k}" ];
# The bootstrap.py will generated a Makefile that then executes the build.
# The BOOTSTRAP_ARGS used by this Makefile must include all flags to pass
# to the bootstrap builder.
postConfigure = ''
substituteInPlace Makefile --replace 'BOOTSTRAP_ARGS :=' 'BOOTSTRAP_ARGS := --jobs $(NIX_BUILD_CORES)'
'';
# the rust build system complains that nix alters the checksums
dontFixLibtool = true;
postPatch = ''
patchShebangs src/etc
'';
# rustc unfortunately need cmake for compiling llvm-rt but doesn't
# use it for the normal build. This disables cmake in Nix.
dontUseCmakeConfigure = true;
outputs = [ "out" "man" "doc" ];
setOutputFlags = false;
doCheck = false;
meta = with stdenv.lib; {
homepage = https://www.rust-lang.org/;
description = "A safe, concurrent, practical language";
license = [ licenses.mit licenses.asl20 ];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment