diff mbox series

[bug#71925,v2,2/2] gnu: klee: Build with klee-uclibc support.

Message ID 635839070779883196fec8119d70c273f46fc841.1720373191.git.soeren@soeren-tempel.net
State New
Headers show
Series [bug#71925,v2,1/2] gnu: Add klee-uclibc. | expand

Commit Message

Sören Tempel July 7, 2024, 5:26 p.m. UTC
From: Sören Tempel <soeren@soeren-tempel.net>

* gnu/packages/check.scm (klee): Use klee-uclibc.
---
 gnu/packages/check.scm | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index 35e26ba6da..52941681a9 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -1036,7 +1036,7 @@  (define-public klee-uclibc
                       (lambda* (#:key outputs #:allow-other-keys)
                         (install-file "lib/libc.a"
                                       (string-append (assoc-ref outputs "out")
-                                                     "/lib")))))))
+                                                     "/klee/lib")))))))
       ;; ncurses is only needed for the `make menuconfig` interface.
       (native-inputs (list clang-13 llvm-13 python ncurses))
       (synopsis "Variant of uClibc tailored to symbolic execution")
@@ -1062,13 +1062,28 @@  (define-public klee
       (base32 "1nma6dqi8chjb97llsa8mzyskgsg4dx56lm8j514j5wmr8vkafz6"))))
    (arguments
     (list
+     #:phases
+     #~(modify-phases %standard-phases
+                      (add-after 'install 'wrap-hooks
+                        (lambda* (#:key inputs outputs #:allow-other-keys)
+                          (let* ((out (assoc-ref outputs "out"))
+                                 (bin (string-append out "/bin"))
+                                 (lib (string-append out "/lib")))
+                            ;; Ensure that KLEE finds runtime libraries (e.g. uclibc).
+                            (wrap-program (string-append bin "/klee")
+                              `("KLEE_RUNTIME_LIBRARY_PATH" =
+                                (,(string-append lib "/klee/runtime/"))))))))
      #:configure-flags
      #~(list (string-append "-DLLVMCC="
                             (search-input-file %build-inputs "/bin/clang"))
              (string-append "-DLLVMCXX="
-                            (search-input-file %build-inputs "/bin/clang++")))))
+                            (search-input-file %build-inputs "/bin/clang++"))
+             (string-append "-DKLEE_UCLIBC_PATH="
+                            (let ((uclibc (search-input-file %build-inputs "/klee/lib/libc.a")))
+                              (dirname (dirname uclibc))))
+             "-DENABLE_POSIX_RUNTIME=ON")))
    (native-inputs (list clang-13 llvm-13 python-lit))
-   (inputs (list gperftools sqlite z3))
+   (inputs (list bash-minimal klee-uclibc gperftools sqlite z3))
    (build-system cmake-build-system)
    (home-page "https://klee-se.org/")
    (synopsis "Symbolic execution engine")