summary refs log tree commit diff
path: root/gnu/packages/klee.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/klee.scm')
-rw-r--r--gnu/packages/klee.scm71
1 files changed, 70 insertions, 1 deletions
diff --git a/gnu/packages/klee.scm b/gnu/packages/klee.scm
index ea4d4ff439..25b9d68dbc 100644
--- a/gnu/packages/klee.scm
+++ b/gnu/packages/klee.scm
@@ -18,18 +18,85 @@
 
 (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")
@@ -55,6 +122,8 @@
                                #$(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"
@@ -65,7 +134,7 @@
       `(("clang" ,clang-toolchain-12)
         ("googletest" ,googletest)
         ("python-lit" ,python-lit)))
-    (inputs (list cryptominisat gperftools llvm-12
+    (inputs (list cryptominisat gperftools llvm-12 klee-uclibc
                   python python-tabulate sqlite stp z3))
     (home-page "https://klee.github.io")
     (synopsis "Symbolic execution engine")