nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at fix-function-merge 56 lines 1.7 kB view raw
1{ lib, stdenv, fetchFromGitHub, fetchpatch, dtc, pkgsCross }: 2 3stdenv.mkDerivation rec { 4 pname = "spike"; 5 version = "1.1.0"; 6 7 src = fetchFromGitHub { 8 owner = "riscv"; 9 repo = "riscv-isa-sim"; 10 rev = "v${version}"; 11 sha256 = "sha256-4D2Fezej0ioOOupw3kgMT5VLs+/jXQjwvek6v0AVMzI="; 12 }; 13 14 patches = [ 15 (fetchpatch { 16 name = "fesvr-fix-compilation-with-gcc-13.patch"; 17 url = "https://github.com/riscv-software-src/riscv-isa-sim/commit/0a7bb5403d0290cea8b2356179d92e4c61ffd51d.patch"; 18 hash = "sha256-JUMTbGawvLkoOWKkruzLzUFQytVR3wqTlGu/eegRFEE="; 19 }) 20 ]; 21 22 nativeBuildInputs = [ dtc ]; 23 enableParallelBuilding = true; 24 25 postPatch = '' 26 patchShebangs scripts/*.sh 27 patchShebangs tests/ebreak.py 28 ''; 29 30 doCheck = true; 31 32 # To test whether spike is working, we run the RISC-V hello applications using the RISC-V proxy 33 # kernel on the Spike emulator and see whether we get the expected output. 34 doInstallCheck = true; 35 installCheckPhase = 36 let 37 riscvPkgs = pkgsCross.riscv64-embedded; 38 in 39 '' 40 runHook preInstallCheck 41 42 echo -e "#include<stdio.h>\nint main() {printf(\"Hello, world\");return 0;}" > hello.c 43 ${riscvPkgs.stdenv.cc}/bin/${riscvPkgs.stdenv.cc.targetPrefix}cc -o hello hello.c 44 $out/bin/spike -m64 ${riscvPkgs.riscv-pk}/bin/pk hello | grep -Fq "Hello, world" 45 46 runHook postInstallCheck 47 ''; 48 49 meta = with lib; { 50 description = "RISC-V ISA Simulator"; 51 homepage = "https://github.com/riscv/riscv-isa-sim"; 52 license = licenses.bsd3; 53 platforms = [ "x86_64-linux" "aarch64-linux" ]; 54 maintainers = with maintainers; [ blitz ]; 55 }; 56}