lowRISC / lowrisc-toolchains

UNSUPPORTED INTERNAL toolchain builds
30 stars 14 forks source link

nix-shell expression to get this toolchain #54

Closed Mic92 closed 2 years ago

Mic92 commented 2 years ago

I built this for a colleagues, in case someone else wants to use this with nix, one can use it as a starting point. Might be not 100% what is used in the repo yet:

let
  pkgs = import <nixpkgs> {};
  pkgsRiscv = pkgs.pkgsCross.riscv32;
  binutils = pkgsRiscv.buildPackages.binutils-unwrapped.overrideAttrs (old: {
    src = pkgs.fetchFromGitHub {
      owner = "riscv-collab";
      repo = "riscv-binutils-gdb";
      rev = "7c9dd840fbb6a1171a51feb08afb859288615137";
      sha256 = "sha256-svWDTmGxgbIn/M9UaznFpYvfRR72NsKbDn/Jq6wX37o=";
    };
    #patches = old.patches ++ [
    patches = [
      (pkgs.fetchpatch {
        url = "https://raw.githubusercontent.com/lowRISC/lowrisc-toolchains/8ff8f02ca962600c1b92e2826c7a04d248d14ac6/patches/lowrisc-toolchain-gcc-rv32imcb/binutils/git-7c9dd840/001-bitmanip.patch";
        sha256 = "sha256-d1ZX/jxM0LNTiBg0cVWGaeOjBkh3QGGqGiUOwWKv+/Y=";
      })
    ];
    nativeBuildInputs = old.nativeBuildInputs ++ [
      pkgs.flex
      pkgs.autoconf269
      pkgs.autoreconfHook
    ];
    configureFlags = old.configureFlags ++ [
      "--disable-gdb"
    ];
  });
  cc = pkgsRiscv.buildPackages.wrapCCWith rec {
    cc = pkgsRiscv.buildPackages.gcc-unwrapped;
    bintools = pkgsRiscv.buildPackages.wrapBintoolsWith {
      bintools = binutils;
      libc = pkgsRiscv.glibc;
    };
  };
in
(pkgsRiscv.overrideCC pkgsRiscv.stdenv cc).mkDerivation {
  name = "env";
}

save as shell.nix and run nix-shell.