summary refs log tree commit diff
path: root/gnu/packages/klee.scm
blob: 25b9d68dbc5543dd41175cc7baf3c1fd91fb341d (plain) (blame)
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
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2023 Nguyễn Gia Phong <cnx@loang.net>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages klee)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system gnu)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages check)
  #:use-module (gnu packages cpp)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages llvm)
  #:use-module (gnu packages maths)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages sqlite)
  #:use-module (guix licenses))

(define-public klee-uclibc
  (package
    (name "klee-uclibc")
    (version "1.3")
    (source
      (origin
        (method git-fetch)
        (uri (git-reference (url "https://github.com/klee/klee-uclibc")
                            (commit (string-append "klee_uclibc_v" version))))
        (file-name (git-file-name name version))
        (sha256
          (base32 "1z33apc90zj844rkwdgvi13sx5xidfc79a02dzjxv686mmchc3y5"))
        (patches (search-patches "klee-uclibc-local-locale.patch"))))
                                 ;"klee-uclibc-no-menuconfig.patch"))))
    (build-system gnu-build-system)
    (arguments
      (list #:phases #~(modify-phases %standard-phases
                         (add-after 'unpack 'unpack-locale
                           (lambda* (#:key inputs #:allow-other-keys)
                             (let ((uclibc-locale
                                    (assoc-ref inputs "uclibc-locale")))
                               (copy-file
                                 uclibc-locale
                                 "extra/locale/uClibc-locale-030818.tgz"))))
                         (replace 'configure
                           (lambda* (#:key inputs #:allow-other-keys)
                             (setenv "CC" "clang")
                             (setenv "UCLIBC_KERNEL_HEADERS"
                                     (string-append
                                       (assoc-ref inputs "linux-libre-headers")
                                       "/include"))
                             ;; configure does not support --prefix
                             (invoke "./configure"
                                     "--make-llvm-lib"
                                     "--enable-release"))))
            #:tests? #f
            #:make-flags #~(list "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA=n"
                                 (string-append "PREFIX=" #$output)
                                 "DEVEL_PREFIX=/"
                                 "RUNTIME_PREFIX=/")))
    (native-inputs
      `(("clang" ,clang-toolchain-12)
        ("linux-libre-headers" ,linux-libre-headers)
        ("llvm" ,llvm)
        ("ncurses" ,ncurses)
        ("perl" ,perl)
        ("python" ,python)
        ("uclibc-locale"
         ,(origin
            (method url-fetch)
            (uri "https://www.uclibc.org/downloads/uClibc-locale-030818.tgz")
            (sha256
              (base32
                "0mxxmspyk3r9clzvk2sl0lpvkflm5p965x6cipcii3x333ijndn4"))))
        ("which" ,which)))
    (synopsis "KLEE's version of uClibc")
    (description "KLEE-uClibc is a modified version version of uClibc for KLEE")
    (home-page "https://github.com/klee/klee-uclibc")
    (license lgpl2.1+)))

(define-public klee
  (package
    (name "klee")
    (version "3.0")
    (source
      (origin
        (method git-fetch)
        (uri (git-reference (url "https://github.com/klee/klee")
                            (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
          (base32 "0dj20nazkcq84ryr87dihvjznapsbl1n21sa8dhhnb0wsad5d6fb"))))
    (build-system cmake-build-system)
    (arguments
      (list
        #:configure-flags
        #~(list "-DCMAKE_BUILD_TYPE=Release"
                "-DKLEE_RUNTIME_BUILD_TYPE=Release"
                (string-append "-DLLVMCC="
                               #$(this-package-native-input "clang")
                               "/bin/clang")
                (string-append "-DLLVMCXX="
                               #$(this-package-native-input "clang")
                               "/bin/clang++")
                "-DKLEE_ENABLE_TIMESTAMP=OFF"
                (string-append "-DKLEE_UCLIBC_PATH="
                               #$(this-package-input "klee-uclibc"))
                "-DENABLE_KLEE_ASSERTS=ON"
                "-DENABLE_POSIX_RUNTIME=ON"
                "-DENABLE_UNIT_TESTS=ON"
                "-DENABLE_SYSTEM_TESTS=ON"
                "-Wno-dev")
        #:test-target "check"))
    (native-inputs
      `(("clang" ,clang-toolchain-12)
        ("googletest" ,googletest)
        ("python-lit" ,python-lit)))
    (inputs (list cryptominisat gperftools llvm-12 klee-uclibc
                  python python-tabulate sqlite stp z3))
    (home-page "https://klee.github.io")
    (synopsis "Symbolic execution engine")
    (description "@code{KLEE} is a symbolic virtual machine built on top of the LLVM compiler infrastructure.")
    (license ncsa)))