diff mbox series

[bug#68296,v4,1/2] gnu: Add klee-uclibc.

Message ID d5c66ff568b4e9c84b2ecd4d8b44b88cf2dad619.1711653619.git.soeren@soeren-tempel.net
State New
Headers show
Series [bug#68296,v4,1/2] gnu: Add klee-uclibc. | expand

Commit Message

Sören Tempel March 28, 2024, 7:20 p.m. UTC
From: Sören Tempel <soeren@soeren-tempel.net>

* gnu/packages/check.scm (klee-uclibc): New variable.

Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
---
Change since v3: Resolve merge conflict, update KLEE website.

 gnu/packages/check.scm | 62 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)


base-commit: daab3da5042a5803ffa13ee759b3f8895dd92de4
diff mbox series

Patch

diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index 7fd28c3ac7..9beba88788 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -51,6 +51,7 @@ 
 ;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
 ;;; Copyright © 2024 Navid Afkhami <navid.afkhami@mdc-berlin.de>
+;;; Copyright © 2024 Sören Tempel <soeren@soeren-tempel.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -84,6 +85,7 @@  (define-module (gnu packages check)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages guile-xyz)
+  #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -3705,3 +3707,63 @@  (define-public subunit
 command line filters to process a subunit stream and language bindings for
 Python, C, C++ and shell.  Bindings are easy to write for other languages.")
     (license (list license:asl2.0 license:bsd-3)))) ;user can pick
+
+(define-public klee-uclibc
+  (let ((commit "955d502cc1f0688e82348304b053ad787056c754"))
+    (package
+      (name "klee-uclibc")
+      (version (git-version "20230612" "0" commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/klee/klee-uclibc")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "12fnr5mq80cxwvv09gi844mi31jgi8067swagxnlxlhxj4mi125j"))))
+      (build-system gnu-build-system)
+      ;; Only x86_64 is presently supported by KLEE upstream.
+      (supported-systems '("x86_64-linux"))
+      (arguments
+       `(#:tests? #f ;upstream uClibc tests do not work in the fork
+         #:phases (modify-phases %standard-phases
+                    ;; Disable locales as these would have to be downloaded and
+                    ;; shouldn't really be needed for symbolic execution either.
+                    (add-after 'unpack 'patch-config
+                      (lambda _
+                        (substitute* "klee-premade-configs/x86_64/config"
+                          (("UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA=y")
+                           "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA=n")
+                          (("UCLIBC_PREGENERATED_LOCALE_DATA=y")
+                           "UCLIBC_PREGENERATED_LOCALE_DATA=n")
+                          (("UCLIBC_HAS_LOCALE=y")
+                           "UCLIBC_HAS_LOCALE=n")
+                          (("UCLIBC_HAS_XLOCALE=y")
+                           "UCLIBC_HAS_XLOCALE=n"))))
+
+                    ;; Upstream uses a custom non-GNU configure script written
+                    ;; in Python, replace the default configure phase accordingly.
+                    (replace 'configure
+                      (lambda _
+                        (invoke "./configure"
+                                "--make-llvm-lib"
+                                "--enable-release")))
+
+                    ;; Custom install phase to only install the libc.a file manually.
+                    ;; This is the only file which is used/needed by KLEE itself.
+                    (replace 'install
+                      (lambda* (#:key outputs #:allow-other-keys)
+                        (install-file "lib/libc.a"
+                                      (string-append (assoc-ref outputs "out")
+                                                     "/lib")))))))
+      (inputs (list clang-toolchain-13))
+      ;; ncurses is only needed for the `make menuconfig` interface.
+      (native-inputs (list python ncurses))
+      (synopsis "Variant of uClibc tailored to symbolic execution")
+      (description
+       "Modified version of uClibc for symbolic execution of
+Unix userland software.  This library can only be used in conjunction
+with the @code{klee} package.")
+      (home-page "https://klee-se.org/")
+      (license license:lgpl2.1))))