Message ID | 50e13182dab9f13a90c63a670a286eb447133e44.1720033365.git.soeren@soeren-tempel.net |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7BAAB27BBEA; Wed, 3 Jul 2024 20:11:05 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E7EA827BBE2 for <patchwork@mira.cbaines.net>; Wed, 3 Jul 2024 20:11:04 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1sP5Ne-0005OC-00; Wed, 03 Jul 2024 15:11:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1sP5Nc-0005Nz-Fc for guix-patches@gnu.org; Wed, 03 Jul 2024 15:11:00 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1sP5Nc-0007Ml-7F for guix-patches@gnu.org; Wed, 03 Jul 2024 15:11:00 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1sP5Ne-000262-38 for guix-patches@gnu.org; Wed, 03 Jul 2024 15:11:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71925] [PATCH 2/2] gnu: klee: Build with klee-uclibc support. Resent-From: soeren@soeren-tempel.net Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 03 Jul 2024 19:11:02 +0000 Resent-Message-ID: <handler.71925.B71925.17200338077975@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71925 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71925@debbugs.gnu.org Cc: julien@lepiller.eu, liliana.prikler@gmail.com Received: via spool by 71925-submit@debbugs.gnu.org id=B71925.17200338077975 (code B ref 71925); Wed, 03 Jul 2024 19:11:02 +0000 Received: (at 71925) by debbugs.gnu.org; 3 Jul 2024 19:10:07 +0000 Received: from localhost ([127.0.0.1]:40479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1sP5Mk-00024Z-WB for submit@debbugs.gnu.org; Wed, 03 Jul 2024 15:10:07 -0400 Received: from magnesium.8pit.net ([45.76.88.171]:25154) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <soeren@soeren-tempel.net>) id 1sP5Mi-000248-QG; Wed, 03 Jul 2024 15:10:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=opensmtpd; bh=vfqaNJpw Xho82eiI6925UKTltucqaKoFaTfGceXL3Fs=; h=references:in-reply-to:date: subject:cc:to:from; d=soeren-tempel.net; b=NoqN3uha+BbH5Ls8CP9ieCY7FC+ zHqZRBidWJ4PNhNfXdvslFQEJARWCpWsdB5uCVXycoPCKy29VldQr6jR4USM4dSMIQ5MU+ lmDlho0uw4IP7w3X0A2AegTHr28ctZvq4qFv5Yt+TBQX1qRAgkdUfNKi0i9Amch3d40PdZ joDw= Received: from localhost (dynamic-2a02-3102-49da-001b-62dc-fa7d-6197-0275.310.pool.telefonica.de [2a02:3102:49da:1b:62dc:fa7d:6197:275]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id dc8e40bf (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Wed, 3 Jul 2024 21:10:01 +0200 (CEST) From: soeren@soeren-tempel.net Date: Wed, 3 Jul 2024 21:09:43 +0200 Message-ID: <50e13182dab9f13a90c63a670a286eb447133e44.1720033365.git.soeren@soeren-tempel.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <cover.1720033365.git.soeren@soeren-tempel.net> References: <cover.1720033365.git.soeren@soeren-tempel.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
Add klee-uclibc.
|
|
Commit Message
Sören Tempel
July 3, 2024, 7:09 p.m. UTC
From: Sören Tempel <soeren@soeren-tempel.net>
* gnu/packages/check.scm (klee): Use klee-uclibc.
---
gnu/packages/check.scm | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
Comments
Am Mittwoch, dem 03.07.2024 um 21:09 +0200 schrieb soeren@soeren-tempel.net: > From: Sören Tempel <soeren@soeren-tempel.net> > > * gnu/packages/check.scm (klee): Use klee-uclibc. > --- > gnu/packages/check.scm | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm > index 35e26ba6da..ad589f6e15 100644 > --- a/gnu/packages/check.scm > +++ b/gnu/packages/check.scm > @@ -1062,13 +1062,26 @@ (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/")))))))) The leading colon is pointless here, since you're doing an "=" assign. More importantly, can we make this a search path? > #: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++")) > + "-DENABLE_POSIX_RUNTIME=ON" > + (string-append "-DKLEE_UCLIBC_PATH=" #$klee-uclibc)))) Can we use search-input-file for this and dirname our way up? > (native-inputs (list clang-13 llvm-13 python-lit)) > - (inputs (list gperftools sqlite z3)) > + (inputs (list bash-minimal gperftools sqlite z3)) > (build-system cmake-build-system) > (home-page "https://klee-se.org/") > (synopsis "Symbolic execution engine") Cheers
Hi Liliana, Thanks a lot for the quick feedback, responses below. Liliana Marie Prikler <liliana.prikler@gmail.com> wrote: > The leading colon is pointless here, since you're doing an "=" assign. Good catch! I can fix this in a patch revision. > More importantly, can we make this a search path? I don't think so as it's not a colon separated search path, it can only point to a single directory; hence, I assumed that wrap-program is more appropriate here. > Can we use search-input-file for this and dirname our way up? The input file that we are looking for here is called libc.a, I am not sure what the benefit of using search-input-file is, but I personally think something along the lines of `(dirname (search-input-file %build-inputs "/lib/libc.a"))` is less readable then `#$klee-uclibc` but I can definitely change this if you want me to :) > Is this only distributed as an .a file or could we make a .so out of > it? This is only distributed as a .a, not as a shared object. In fact, KLEE also doesn't not link against this library at all and instead converts it to an LLVM .bca file (shipped in /lib/klee/runtime/klee-uclibc.bca) during build. This file is then used directly by KLEE's symbolic LLVM interpreter to execute code utilizing libc functions. Hence, klee-uclibc is also not a propagated input for the klee package. Let me know if I should send a revision, would love to get this merged. Greetings Sören
Am Sonntag, dem 07.07.2024 um 13:24 +0200 schrieb Sören Tempel: > Hi Liliana, > > Thanks a lot for the quick feedback, responses below. > > Liliana Marie Prikler <liliana.prikler@gmail.com> wrote: > > The leading colon is pointless here, since you're doing an "=" > > assign. > > Good catch! I can fix this in a patch revision. > > > More importantly, can we make this a search path? > > I don't think so as it's not a colon separated search path, it can > only point to a single directory; hence, I assumed that wrap-program > is more appropriate here. Fair enough. > > Can we use search-input-file for this and dirname our way up? > > The input file that we are looking for here is called libc.a, I am > not > sure what the benefit of using search-input-file is, but I personally > think something along the lines of `(dirname (search-input-file > %build-inputs "/lib/libc.a"))` is less readable then `#$klee-uclibc` > but I can definitely change this if you want me to :) > > > Is this only distributed as an .a file or could we make a .so out > > of it? > > This is only distributed as a .a, not as a shared object. In fact, > KLEE also doesn't not link against this library at all and instead > converts it to an LLVM .bca file (shipped in > /lib/klee/runtime/klee-uclibc.bca) > during build. This file is then used directly by KLEE's symbolic LLVM > interpreter to execute code utilizing libc functions. Hence, klee- > uclibc is also not a propagated input for the klee package. > > Let me know if I should send a revision, would love to get this > merged. Can we make it so that it uses the file directly instead of inferring the name? Then we could install klee-uclibc to, say "/lib/klee/uclibc.a" and reference it in this build by said file name. Cheers
Hello! Liliana Marie Prikler <liliana.prikler@gmail.com> wrote: > Can we make it so that it uses the file directly instead of inferring > the name? Then we could install klee-uclibc to, say > "/lib/klee/uclibc.a" and reference it in this build by said file name. That would require us to patch KLEE's CMakeLists.txt and I am not sure if that's worth it [1]. I think I would personally prefer using search-input-file and dirname then. However, I am also still somewhat new to Guix, could you elaborate what the problem with using `(string-append "-DKLEE_UCLIBC_PATH=" #$klee-uclibc)` is (for the sake of expanding my understanding of Guix in this regard)? Greetings, Sören [1]: https://github.com/klee/klee/blob/v3.1/CMakeLists.txt#L480-L501
Am Sonntag, dem 07.07.2024 um 18:50 +0200 schrieb Sören Tempel: > Hello! > > Liliana Marie Prikler <liliana.prikler@gmail.com> wrote: > > Can we make it so that it uses the file directly instead of > > inferring the name? Then we could install klee-uclibc to, say > > "/lib/klee/uclibc.a" and reference it in this build by said file > > name. > > That would require us to patch KLEE's CMakeLists.txt and I am not > sure if that's worth it [1]. I think I would personally prefer using > search-input-file and dirname then. However, I am also still somewhat > new to Guix, could you elaborate what the problem with using > `(string-append "-DKLEE_UCLIBC_PATH=" #$klee-uclibc)` is (for the > sake of expanding my understanding of Guix in this regard)? Well, the question is mainly what people ought to do to swap out klee- uclibc from their builds – e.g. if they want to replace it with a newer one etc. Inputs are our means of making sure that people have a handle for this kind of thing. Cheers
Hello again! Thanks for the explanation, I send a v2 revision which (hopefully) addresses your feedback. I have opted to install the libc.a file to /klee/lib/libc.a this way, it's compatible with search-inputs without requiring us to patch KLEE's build system. Let me know what you think :) Best, Sören Liliana Marie Prikler <liliana.prikler@gmail.com> wrote: > Am Sonntag, dem 07.07.2024 um 18:50 +0200 schrieb Sören Tempel: > > Hello! > > > > Liliana Marie Prikler <liliana.prikler@gmail.com> wrote: > > > Can we make it so that it uses the file directly instead of > > > inferring the name? Then we could install klee-uclibc to, say > > > "/lib/klee/uclibc.a" and reference it in this build by said file > > > name. > > > > That would require us to patch KLEE's CMakeLists.txt and I am not > > sure if that's worth it [1]. I think I would personally prefer using > > search-input-file and dirname then. However, I am also still somewhat > > new to Guix, could you elaborate what the problem with using > > `(string-append "-DKLEE_UCLIBC_PATH=" #$klee-uclibc)` is (for the > > sake of expanding my understanding of Guix in this regard)? > Well, the question is mainly what people ought to do to swap out klee- > uclibc from their builds – e.g. if they want to replace it with a newer > one etc. Inputs are our means of making sure that people have a handle > for this kind of thing. > > Cheers
Am Sonntag, dem 07.07.2024 um 19:28 +0200 schrieb Sören Tempel: > Hello again! > > Thanks for the explanation, I send a v2 revision which (hopefully) > addresses your feedback. I have opted to install the libc.a file > to /klee/lib/libc.a this way, it's compatible with search-inputs > without requiring us to patch KLEE's build system. v2's klee-uclibc appears to still install libc.a in /lib rather than /klee/lib – do you want it do be this way around or would /lib/klee/ (honouring FHS) be smarter? Cheers
Liliana Marie Prikler <liliana.prikler@gmail.com> wrote: > v2's klee-uclibc appears to still install libc.a in /lib rather than > /klee/lib – Sorry, I messed up the rebase and added the change to klee-uclibc in the second patch by accident, see [1]. I will send a v3 which fixes this in a second. > do you want it do be this way around or would /lib/klee/ (honouring > FHS) be smarter? If we want to install the file to /lib/klee, then we would have to patch the KLEE build system [2], which I wanted to avoid. I can also patch it if you think that this is preferable, might need some source code changes too. [1]: https://issues.guix.gnu.org/71925#10 [2]: https://github.com/klee/klee/blob/v3.1/CMakeLists.txt#L487
diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm index 35e26ba6da..ad589f6e15 100644 --- a/gnu/packages/check.scm +++ b/gnu/packages/check.scm @@ -1062,13 +1062,26 @@ (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++")) + "-DENABLE_POSIX_RUNTIME=ON" + (string-append "-DKLEE_UCLIBC_PATH=" #$klee-uclibc)))) (native-inputs (list clang-13 llvm-13 python-lit)) - (inputs (list gperftools sqlite z3)) + (inputs (list bash-minimal gperftools sqlite z3)) (build-system cmake-build-system) (home-page "https://klee-se.org/") (synopsis "Symbolic execution engine")