From 935f374482829d4bdf6a0edb16527a877a676ba4 Mon Sep 17 00:00:00 2001 From: GenericNerdyUsername Date: Sat, 28 Jan 2023 14:42:01 +0000 Subject: [PATCH] riscv-gnu-toolchain-*: init at 2023.01.04 --- .../compilers/riscv-gnu-toolchain/default.nix | 125 ++++++++++++++++++ .../riscv-gnu-toolchain/nodotgit.patch | 15 +++ pkgs/top-level/all-packages.nix | 15 +++ 3 files changed, 155 insertions(+) create mode 100644 pkgs/development/compilers/riscv-gnu-toolchain/default.nix create mode 100644 pkgs/development/compilers/riscv-gnu-toolchain/nodotgit.patch diff --git a/pkgs/development/compilers/riscv-gnu-toolchain/default.nix b/pkgs/development/compilers/riscv-gnu-toolchain/default.nix new file mode 100644 index 000000000000000..e3d8d4b1bcc4d85 --- /dev/null +++ b/pkgs/development/compilers/riscv-gnu-toolchain/default.nix @@ -0,0 +1,125 @@ +{ 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 + +, 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 = { + url = gcc12.cc.src.url; + hash = gcc12.cc.src.outputHash; + }; + glibc = { + url = glibc.src.url; + hash = glibc.src.outputHash; + }; + newlib = { + url = newlib.src.url; + hash = "sha256-8pbjcvUTJCJNOHzBFtw3pr05cZh1Z0b5OisC6aXUAVQ="; + }; + gdb = { + url = gdb.src.url; + hash = gdb.src.outputHash; + }; + qemu = { + url = qemu.src.url; + hash = qemu.src.outputHash; + }; + musl = { + url = musl.src.url; + hash = musl.src.outputHash; + }; + spike = { + url = spike.src.url; + hash = "sha256-mynCIP7R6GfjvqS1xWXyYpI31SWk2f4WaGmcRAYAOh8="; + }; + pk = { + url = riscv-pk.src.url; + hash = "sha256-Rf6ACDD0WptZK6XU/bdDo+TCEmZT+DTZBKXKuScQf/Y="; + }; +} + +, isa ? "rv64gc" +, withLinux ? false +}: +with lib; +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 = mapAttrs (name: value: if value ? outPath then value else fetchurl value) srcs; +srcs_extracted = mapAttrs (name: value: extract value) srcs_fetched; +srcFlags = mapAttrsToList (name: value: "--with-${name}-src=${value}") srcs_extracted; + +in stdenv.mkDerivation rec { + pname = "riscv-gnu-toolchain-" + isa; + version = "2023.01.04"; + + buildInputs = [ autoconf automake flock curl python3 libmpc gawk bison flex texinfo gperf libtool expat.dev gmp.dev mpfr.dev ]; + hardeningDisable = [ "format" ]; + + patches = [ ./nodotgit.patch ]; + configureFlags = [ + "--with-arch=${isa}" + ] ++ + srcFlags ++ + optional withLinux "--enable-linux"; + + preConfigure = '' + patchShebangs . + ''; + + src = fetchFromGitHub { + owner = "riscv-collab"; + repo = pname; + 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 ]; + }; +} diff --git a/pkgs/development/compilers/riscv-gnu-toolchain/nodotgit.patch b/pkgs/development/compilers/riscv-gnu-toolchain/nodotgit.patch new file mode 100644 index 000000000000000..52677d597387488 --- /dev/null +++ b/pkgs/development/compilers/riscv-gnu-toolchain/nodotgit.patch @@ -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 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c2d81ef130fa3ab..324a929d7caf720 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { };