summaryrefslogtreecommitdiff
path: root/pkgs/gem5.nix
blob: f9aebd773c29610cf1700124352480eb573b326e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ boost
, lib
, fetchFromGitHub
, gnum4
, gperftools
, hdf5-cpp
, libpng
, protobuf
, scons
, stdenv
, zlib
, enableHdf5 ? true
, enableLibpng ? true
, enableTrace ? true
, enableSystemC ? true
, enableTcmalloc ? true
, gem5ISA
}:
let
  version = "22.1.0.0";

  isa = assert lib.assertMsg (lib.elem gem5ISA [ "arm" "null" "mips" "power" "x86" ])
    "${gem5ISA} is not a valid gem5 target ISA";
    lib.toUpper gem5ISA;

  target = "build/${isa}/gem5.opt";
in
stdenv.mkDerivation {
  pname = "gem5";
  version = "${gem5ISA}-${version}";

  src = fetchFromGitHub {
    repo = "gem5";
    owner = "gem5";

    rev = "v${version}";
    sha256 = "sha256-Yxag8emR6hf7oX4GAtQi/YYcKrpXicUoQg5+rjKyjc0=";
  };

  buildInputs = [ zlib ]
    ++ lib.optional enableHdf5 hdf5-cpp
    ++ lib.optional enableLibpng libpng
    ++ lib.optional enableTrace boost
    ++ lib.optional enableSystemC protobuf
    ++ lib.optional enableTcmalloc gperftools;

  nativeBuildInputs = [ gnum4 scons ];

  sconsFlags = [ target ];

  enableParallelBuilding = true;

  # Without this we get "ValueError: invalid width 0 (must be > 0)" 
  COLUMNS = 80;

  postPatch = ''
    patchShebangs util/
  '';

  installPhase = ''
    mkdir -p $out/bin/
    cp ${target} $out/bin/
  '';
}