Skip to content

Commit

Permalink
riscv-gnu-toolchain-rv32gc, riscv-gnu-toolchain-rv64gc, riscv-gnu-too…
Browse files Browse the repository at this point in the history
…lchain-rv64gc-linux: init at 2023.01.04
  • Loading branch information
GenericNerdyUsername committed Feb 1, 2023
1 parent 3790bb8 commit 9108d62
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 0 deletions.
100 changes: 100 additions & 0 deletions pkgs/development/compilers/riscv-gnu-toolchain/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{ stdenv
, lib
, fetchFromGitHub
, fetchurl

, gcc12
, glibc
, newlib
, gdb
, qemu
, musl
, spike
, riscv-pk

, autoconf
, curl
, automake
, python3
, libmpc
, gawk
, bison
, flex
, texinfo
, gperf
, libtool
, expat
, gmp
, mpfr
, flock
, zlib

, srcs ? {
binutils = {
url = "mirror://gnu/binutils/binutils-2.39.tar.bz2";
hash = "sha256-2iSoT+8iAQLdJAQt8G/eqFHCYUpTd/hu/6KPM7exYUg=";
};
dejagnu = {
url = "mirror://gnu/dejagnu/dejagnu-1.6.3.tar.gz";
hash = "sha256-h9rvrNeVi0pp+IxoVtvRY0JhljxBQHnQw3H1ic1mouM=";
};
gcc = gcc12.cc.src;
glibc = glibc.src;
newlib = newlib.src;
gdb = gdb.src;
qemu = qemu.src;
musl = musl.src;
spike = spike.src;
pk = riscv-pk.src;
}

, isa ? "rv64gc"
, withLinux ? false
}:
let

extract = file: stdenv.mkDerivation {
name = file.name + "-unpacked";
src = file;
dontPatch = true;
dontConfigure = true;
dontBuild = true;
installPhase = "cp -r . $out";
dontFixup = true;
};

srcs_fetched = lib.mapAttrs (name: value: if value ? outPath then value else fetchurl value) srcs;
srcs_extracted = lib.mapAttrs (name: value: extract value) srcs_fetched;
srcFlags = lib.mapAttrsToList (name: value: "--with-${name}-src=${value}") srcs_extracted;

in stdenv.mkDerivation rec {
pname = "riscv-gnu-toolchain-" + isa;
version = "2023.01.04";

nativeBuildInputs = [ autoconf automake flock curl python3 gawk bison flex texinfo gperf ];
buildInputs = [ libmpc libtool expat.dev gmp.dev mpfr.dev zlib ];
hardeningDisable = [ "format" ];

patches = [ ./nodotgit.patch ];
configureFlags = [
"--with-arch=${isa}"
] ++
srcFlags ++
lib.optional withLinux "--enable-linux";

preConfigure = "patchShebangs .";

src = fetchFromGitHub {
owner = "riscv-collab";
repo = "riscv-gnu-toolchain";
rev = version;
hash = "sha256-PXPQ/ho+fOudZRErnyQZTVFdceWGBF+geo+3y0tkNm4=";
};

meta = with lib; {
homepage = "https://github.com/riscv-collab/riscv-gnu-toolchain";
description = "RISC-V C and C++ cross-compiler";
maintainers = with maintainers; [ genericnerdyusername ];
license = with licenses; [ bsd3 gpl2 lgpl21 ];
};
}
15 changes: 15 additions & 0 deletions pkgs/development/compilers/riscv-gnu-toolchain/nodotgit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/Makefile.in b/Makefile.in
index 09c5772..a988d0d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -279,9 +279,7 @@ GCCPKGVER :=
endif

$(srcdir)/%/.git:
- cd $(srcdir) && \
- flock `git rev-parse --git-dir`/config git submodule init $(dir $@) && \
- flock `git rev-parse --git-dir`/config git submodule update $(dir $@)
+ true

#
# GLIBC
15 changes: 15 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26319,6 +26319,21 @@ with pkgs;

rfkill_udev = callPackage ../os-specific/linux/rfkill/udev.nix { };

riscv-gnu-toolchain-rv64gc-linux = callPackage ../development/compilers/riscv-gnu-toolchain {
isa = "rv64gc";
withLinux = true;
};

riscv-gnu-toolchain-rv64gc = callPackage ../development/compilers/riscv-gnu-toolchain {
isa = "rv64gc";
withLinux = false;
};

riscv-gnu-toolchain-rv32gc = callPackage ../development/compilers/riscv-gnu-toolchain {
isa = "rv32gc";
withLinux = false;
};

riscv-pk = callPackage ../misc/riscv-pk { };

ristate = callPackage ../tools/misc/ristate { };
Expand Down

0 comments on commit 9108d62

Please sign in to comment.