summary refs log tree commit diff
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2023-07-28 20:45:33 +0900
committerNguyễn Gia Phong <cnx@loang.net>2023-08-04 17:38:11 +0900
commit7ed604bf4fedc8b66da4d2e66b68a2ec5ed1bc2c (patch)
tree7a58183594536a37de226b75b3d28b7b916487f5
parent9365489d2307441e606dad83179e278c201cf088 (diff)
downloadguix-7ed604bf4fedc8b66da4d2e66b68a2ec5ed1bc2c.tar.gz
gnu: klee: Add uClibc support klee
* gnu/packages/klee.scm (klee-uclibc): New variable.
* gnu/packages/klee.scm (klee): Link with klee-uclibc.
-rw-r--r--gnu/packages/klee.scm71
-rw-r--r--gnu/packages/patches/klee-uclibc-local-locale.patch35
2 files changed, 105 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")
diff --git a/gnu/packages/patches/klee-uclibc-local-locale.patch b/gnu/packages/patches/klee-uclibc-local-locale.patch
new file mode 100644
index 0000000000..4cc9a4af86
--- /dev/null
+++ b/gnu/packages/patches/klee-uclibc-local-locale.patch
@@ -0,0 +1,35 @@
+From be66efeb07f7c213bc8dd9c52fa25c6da86b492b Mon Sep 17 00:00:00 2001
+From: Jiri Slaby <jslaby@suse.cz>
+Date: Tue, 10 May 2022 12:29:29 +0200
+Subject: [PATCH 1/5] extra/locale/Makefile: don't always require curl/wget
+
+Especially when UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is unset.
+
+Fixes: 9351bdc9ad61 (switch to https; fallback to curl when wget not available)
+---
+ extra/locale/Makefile.in | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in
+index 430c80658429..947bdf62caf6 100644
+--- a/extra/locale/Makefile.in
++++ b/extra/locale/Makefile.in
+@@ -6,6 +6,7 @@
+ #
+ 
+ # command used to download source code
++ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
+ GET  :=
+ WGET := $(shell command -v wget 2> /dev/null)
+ CURL := $(shell command -v curl 2> /dev/null)
+@@ -19,6 +20,7 @@ else
+ $(error "curl/wget not found")
+ endif
+ endif
++endif
+ 
+ 
+ LOCALE_DATA_FILENAME := uClibc-locale-030818.tgz
+-- 
+2.41.0
+