aboutsummaryrefslogtreecommitdiff
path: root/gn/packages/virtualization.scm
blob: 5421a2b139697b3f1927f89078c12c3fbeeaf999 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
(define-module (gn packages virtualization)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix gexp)
  #:use-module (guix utils)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system scons)
  #:use-module (gnu packages)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages cpp)
  #:use-module (gnu packages cross-base)
  #:use-module (gnu packages graphviz)
  #:use-module (gnu packages image)
  #:use-module (gnu packages m4)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages protobuf)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-xyz))

(define-public riscv-pk
  (package
    (name "riscv-pk")
    (version "1.0.0")
    (source
      (origin
        (method git-fetch)
        (uri (git-reference
               (url "https://github.com/riscv-software-src/riscv-pk")
               (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
         (base32 "1cc0rz4q3a1zw8756b8yysw8lb5g4xbjajh5lvqbjix41hbdx6xz"))))
    (build-system gnu-build-system)
    (arguments
     (list
       #:out-of-source? #t
       ;#:configure-flags
       ;#~(list "--host=riscv64-linux-gnu")
       #:target "riscv64-linux-gnu"
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'force-install-directory
             (lambda _
               (substitute* "Makefile.in"
                 (("\\$\\(install_subdir\\)") "")))))))
    (native-inputs
     (if (not (string-prefix? "riscv64" (%current-system)))
       (list (cross-gcc "riscv64-linux-gnu")
             (cross-binutils "riscv64-linux-gnu"))
       '()))
    (home-page "https://github.com/riscv-software-src/riscv-pk")
    (synopsis "RISC-V Proxy Kernel")
    (description "The RISC-V Proxy Kernel, @code{pk}, is a lightweight
application execution environment that can host statically-linked RISC-V ELF
binaries.  It is designed to support tethered RISC-V implementations with
limited I/O capability and and thus handles I/O-related system calls by proxying
them to a host computer.  This package also contains the Berkeley Boot Loader,
@code{bbl}, which is a supervisor execution environment for tethered RISC-V
systems.  It is designed to host the RISC-V Linux port.")
    (license license:bsd-3)))

(define-public gem5
  (package
    (name "gem5")
    (version "21.2.1.0")
    (source
      (origin
        (method git-fetch)
        (uri (git-reference
               (url "https://gem5.googlesource.com/public/gem5")
               (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
         (base32 "0wyns8cfkigzw3m21331m8ydc7akm8l2lp0kci4pq8jyzsanmjm3"))
        (snippet
          #~(begin
              (use-modules (guix build utils))
              ;; For reproducibility.
              (substitute* "src/base/date.cc"
                (("__DATE__") "\"1970-01-01\"")
                (("__TIME__") "\"00:00:00\""))))))
    (build-system scons-build-system)
    (arguments
     `(#:scons-flags
       (list "--verbose")
       #:tests? #f      ; TODO: How to run test suite?
       #:build-targets '("build/ARM/gem5.opt"
                         "build/MIPS/gem5.opt"
                         "build/NULL/gem5.opt"
                         "build/POWER/gem5.opt"
                         "build/RISCV/gem5.opt"
                         "build/SPARC/gem5.opt"
                         "build/X86/gem5.opt")
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-source
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* "SConstruct"
               ;; Scons does not use the environment variables by default,
               ;; but this substitution makes it do so.
               ;(("main = Environment")
               ; "main = Environment(ENV=os.environ)\nmain = Environment")
               ;; Force adding missing includes into the environment.
               (("main\\.Append\\(CPPPATH=\\[Dir\\('" all)
                (string-append
                  all (assoc-ref inputs "kernel-headers") "/include')])\n"
                  all (assoc-ref inputs "libpng") "/include')])\n"
                  all (assoc-ref inputs "zlib") "/include')])\n"
                  all)))
             (substitute* "ext/libelf/SConscript"
               (("m4env\\.Tool" all)
                (string-append
                  "m4env.Append(CPPPATH=[Dir('"
                  (assoc-ref inputs "kernel-headers")
                  "/include')])\n"
                  all)))
             (substitute* "ext/libelf/native-elf-format"
               (("cc") ,(cc-for-target)))))
         (replace 'check
           (lambda* (#:key tests? #:allow-other-keys)
             (when tests?
               (invoke "python3" "tests/run.py"))))
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (bin (string-append out "/bin/")))
               (mkdir-p bin)
               (for-each
                 (lambda (arch)
                   (when (directory-exists?
                           (string-append "build/" (string-upcase arch)))
                     (copy-file
                       (string-append "build/" (string-upcase arch) "/gem5.opt")
                       (string-append bin "gem5-" arch ".opt"))
                     (copy-file
                       (string-append "build/" (string-upcase arch) "/gem5py")
                       (string-append bin "gem5py-" arch))
                     (copy-file
                       (string-append "build/" (string-upcase arch) "/gem5py_m5")
                       (string-append bin "gem5py_m5-" arch))))
                 (list "arm" "mips" "null" "power" "riscv" "sparc" "x86"))))))))
    (inputs
     (list gperftools
           libpng
           protobuf
           python
           python-pydot
           python-six
           zlib))
    (native-inputs
     (list boost
           m4
           pkg-config))
    (home-page "http://gem5.org/")
    (synopsis "Modular platform for computer-system architecture research")
    (description "The gem5 simulator is a modular platform for computer-system
architecture research, encompassing system-level architecture as well as
processor microarchitecture.")
    (license license:bsd-2)))

(define-public gem5-riscv
  (package
    (inherit gem5)
    (name "gem5-riscv")
    (arguments
     (substitute-keyword-arguments (package-arguments gem5)
       ((#:build-targets _)
        `(list "build/RISCV/gem5.opt"))
       ((#:phases phases)
        `(modify-phases ,phases
           (replace 'install
               (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (bin (string-append out "/bin")))
                 (install-file "build/RISCV/gem5.opt" bin)
                 (install-file "build/RISCV/gem5py" bin)
                 (install-file "build/RISCV/gem5py_m5" bin))))))))))