From: Zhu Zihao <all_but_last@163.com>
To: 56107@debbugs.gnu.org
Subject: [bug#56107] [PATCH]: Update z3 to 4.8.17 and use cmake to build the package.
Date: Mon, 20 Jun 2022 20:32:47 +0800 [thread overview]
Message-ID: <86mte7v7jf.fsf@163.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 255 bytes --]
[-- Attachment #2: 0001-gnu-z3-Use-G-expressions.patch --]
[-- Type: text/x-patch, Size: 5381 bytes --]
From a8ccfba4a1c5ef02618d81f3873912b28411092e Mon Sep 17 00:00:00 2001
From: Zhu Zihao <all_but_last@163.com>
Date: Mon, 20 Jun 2022 20:09:20 +0800
Subject: [PATCH 1/3] gnu: z3: Use G-expressions.
* gnu/packages/maths.scm (z3)[arguments]: Use G-expressions.
[native-inputs]: Use label-less style.
---
gnu/packages/maths.scm | 89 +++++++++++++++++++++---------------------
1 file changed, 45 insertions(+), 44 deletions(-)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 0ad14ba36e..b6d56e7467 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -50,6 +50,7 @@
;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me>
;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
;;; Copyright © 2021 Pierre-Antoine Bouttier <pierre-antoine.bouttier@univ-grenoble-alpes.fr>
+;;; Copyright © 2022 Zhu Zihao <all_but_last@163.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -5829,51 +5830,51 @@ (define-public z3
"1hnbzq10d23drd7ksm3c1n2611c3kd0q0yxgz8y78zaafwczvwxx"))))
(build-system gnu-build-system)
(arguments
- `(#:imported-modules ((guix build python-build-system)
- ,@%gnu-build-system-modules)
- #:modules (((guix build python-build-system) #:select (site-packages))
- (guix build gnu-build-system)
- (guix build utils))
- #:phases
- (modify-phases %standard-phases
- (add-after 'unpack 'enable-bytecode-determinism
- (lambda _
- (setenv "PYTHONHASHSEED" "0")
- #t))
- (add-after 'unpack 'fix-compatability
- ;; Versions after 4.8.3 have immintrin.h IFDEFed for Windows only.
- (lambda _
- (substitute* "src/util/mpz.cpp"
- (("#include <immintrin.h>") ""))
- #t))
- (add-before 'configure 'bootstrap
- (lambda _
- (invoke "python" "scripts/mk_make.py")))
- ;; work around gnu-build-system's setting --enable-fast-install
- ;; (z3's `configure' is a wrapper around the above python file,
- ;; which fails when passed --enable-fast-install)
- (replace 'configure
- (lambda* (#:key inputs outputs #:allow-other-keys)
- (invoke "./configure"
- "--python"
- (string-append "--prefix=" (assoc-ref outputs "out"))
- (string-append "--pypkgdir=" (site-packages inputs outputs)))))
- (add-after 'configure 'change-directory
- (lambda _
- (chdir "build")
- #t))
- (add-before 'check 'make-test-z3
- (lambda _
- ;; Build the test suite executable.
- (invoke "make" "test-z3" "-j"
- (number->string (parallel-job-count)))))
- (replace 'check
- (lambda _
- ;; Run all the tests that don't require arguments.
- (invoke "./test-z3" "/a"))))))
+ (list
+ #:imported-modules `((guix build python-build-system)
+ ,@%cmake-build-system-modules)
+ #:modules '((guix build cmake-build-system)
+ (guix build utils)
+ ((guix build python-build-system) #:select (site-packages)))
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'enable-bytecode-determinism
+ (lambda _
+ (setenv "PYTHONHASHSEED" "0")
+ #t))
+ (add-after 'unpack 'fix-compatability
+ ;; Versions after 4.8.3 have immintrin.h IFDEFed for Windows only.
+ (lambda _
+ (substitute* "src/util/mpz.cpp"
+ (("#include <immintrin.h>") ""))
+ #t))
+ (add-before 'configure 'bootstrap
+ (lambda _
+ (invoke "python" "scripts/mk_make.py")))
+ ;; work around gnu-build-system's setting --enable-fast-install
+ ;; (z3's `configure' is a wrapper around the above python file,
+ ;; which fails when passed --enable-fast-install)
+ (replace 'configure
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (invoke "./configure"
+ "--python"
+ (string-append "--prefix=" (assoc-ref outputs "out"))
+ (string-append "--pypkgdir=" (site-packages inputs outputs)))))
+ (add-after 'configure 'change-directory
+ (lambda _
+ (chdir "build")
+ #t))
+ (add-before 'check 'make-test-z3
+ (lambda _
+ ;; Build the test suite executable.
+ (invoke "make" "test-z3" "-j"
+ (number->string (parallel-job-count)))))
+ (replace 'check
+ (lambda _
+ ;; Run all the tests that don't require arguments.
+ (invoke "./test-z3" "/a"))))))
(native-inputs
- `(("which" ,which)
- ("python" ,python-wrapper)))
+ (list which python-wrapper))
(synopsis "Theorem prover")
(description "Z3 is a theorem prover and @dfn{satisfiability modulo
theories} (SMT) solver. It provides a C/C++ API, as well as Python bindings.")
--
2.36.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-z3-Update-to-4.8.17.patch --]
[-- Type: text/x-patch, Size: 1164 bytes --]
From 5ce1ec4c3c6d0a865645da9a6b0899f3596b5e3e Mon Sep 17 00:00:00 2001
From: Zhu Zihao <all_but_last@163.com>
Date: Mon, 20 Jun 2022 20:14:37 +0800
Subject: [PATCH 2/3] gnu: z3: Update to 4.8.17.
* gnu/packages/maths.scm (z3): Update to 4.8.17.
---
gnu/packages/maths.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index b6d56e7467..2f1f731890 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -5818,7 +5818,7 @@ (define-public jacal
(define-public z3
(package
(name "z3")
- (version "4.8.9")
+ (version "4.8.17")
(home-page "https://github.com/Z3Prover/z3")
(source (origin
(method git-fetch)
@@ -5827,8 +5827,8 @@ (define-public z3
(file-name (git-file-name name version))
(sha256
(base32
- "1hnbzq10d23drd7ksm3c1n2611c3kd0q0yxgz8y78zaafwczvwxx"))))
(build-system gnu-build-system)
+ "1vvb09q7w7zd29qc4qjysrrhyylszm1wf6azkff004ixwn026b05"))))
(arguments
(list
#:imported-modules `((guix build python-build-system)
--
2.36.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-gnu-z3-Prefer-CMake-to-build-the-package.patch --]
[-- Type: text/x-patch, Size: 5174 bytes --]
From 6bd6bda66d40782e2f269001d9bc53e3bf8a153f Mon Sep 17 00:00:00 2001
From: Zhu Zihao <all_but_last@163.com>
Date: Mon, 20 Jun 2022 20:17:54 +0800
Subject: [PATCH 3/3] gnu: z3: Prefer CMake to build the package.
Z3 developer recommends to use CMake to build Z3 except the OCaml bindings.
Use CMake also enable us to cross compile z3.
* gnu/packages/maths.scm (z3)[build-system]: Use cmake-build-system.
[arguments]<#:configure-flags>: Add flags for CMake.
<#:phases>: Remove stale phase 'fix-compatability'.
In phase 'check', build the z3 test binary and don't test when cross
compiling.
Add phase 'compile-python-modules' phase to generate python bytecode cache for
z3 python binding.
Add phase 'fix-z3-library-path' to help z3 pythong binding to find the z3
shared library.
(ocaml-z3)[build-system]: Override the inherited value with 'gnu-build-system'.
---
gnu/packages/maths.scm | 64 ++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 33 deletions(-)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 2f1f731890..02809f5a63 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -5827,8 +5827,8 @@ (define-public z3
(file-name (git-file-name name version))
(sha256
(base32
- (build-system gnu-build-system)
"1vvb09q7w7zd29qc4qjysrrhyylszm1wf6azkff004ixwn026b05"))))
+ (build-system cmake-build-system)
(arguments
(list
#:imported-modules `((guix build python-build-system)
@@ -5836,43 +5836,40 @@ (define-public z3
#:modules '((guix build cmake-build-system)
(guix build utils)
((guix build python-build-system) #:select (site-packages)))
+ #:configure-flags
+ #~(list "-DZ3_BUILD_PYTHON_BINDINGS=ON"
+ "-DZ3_LINK_TIME_OPTIMIZATION=ON"
+ (string-append
+ "-DCMAKE_INSTALL_PYTHON_PKG_DIR="
+ #$output "/lib/python"
+ #$(version-major+minor (package-version python-wrapper))
+ "/site-packages"))
#:phases
#~(modify-phases %standard-phases
- (add-after 'unpack 'enable-bytecode-determinism
+ (replace 'check
+ (lambda* (#:key parallel-build? #:allow-other-keys)
+ (unless #$(%current-target-system)
+ (invoke "make" "test-z3"
+ (format #f "-j~a"
+ (if parallel-build?
+ (parallel-job-count)
+ 1)))
+ (invoke "./test-z3" "/a"))))
+ (add-after 'install 'compile-python-modules
(lambda _
(setenv "PYTHONHASHSEED" "0")
- #t))
- (add-after 'unpack 'fix-compatability
- ;; Versions after 4.8.3 have immintrin.h IFDEFed for Windows only.
- (lambda _
- (substitute* "src/util/mpz.cpp"
- (("#include <immintrin.h>") ""))
- #t))
- (add-before 'configure 'bootstrap
- (lambda _
- (invoke "python" "scripts/mk_make.py")))
- ;; work around gnu-build-system's setting --enable-fast-install
- ;; (z3's `configure' is a wrapper around the above python file,
- ;; which fails when passed --enable-fast-install)
- (replace 'configure
+
+ (invoke "python" "-m" "compileall"
+ "--invalidation-mode=unchecked-hash"
+ #$output)))
+ ;; This step is missing in the CMake build system, do it here.
+ (add-after 'compile-python-modules 'fix-z3-library-path
(lambda* (#:key inputs outputs #:allow-other-keys)
- (invoke "./configure"
- "--python"
- (string-append "--prefix=" (assoc-ref outputs "out"))
- (string-append "--pypkgdir=" (site-packages inputs outputs)))))
- (add-after 'configure 'change-directory
- (lambda _
- (chdir "build")
- #t))
- (add-before 'check 'make-test-z3
- (lambda _
- ;; Build the test suite executable.
- (invoke "make" "test-z3" "-j"
- (number->string (parallel-job-count)))))
- (replace 'check
- (lambda _
- ;; Run all the tests that don't require arguments.
- (invoke "./test-z3" "/a"))))))
+ (let* ((dest (string-append (site-packages inputs outputs)
+ "/z3/lib/libz3.so"))
+ (z3-lib (string-append #$output "/lib/libz3.so")))
+ (mkdir-p (dirname dest))
+ (symlink z3-lib dest)))))))
(native-inputs
(list which python-wrapper))
(synopsis "Theorem prover")
@@ -5884,6 +5881,7 @@ (define-public ocaml-z3
(package
(inherit z3)
(name "ocaml-z3")
+ (build-system gnu-build-system)
(arguments
`(#:imported-modules ((guix build python-build-system)
,@%gnu-build-system-modules)
--
2.36.1
[-- Attachment #5: Type: text/plain, Size: 100 bytes --]
--
Retrieve my PGP public key:
gpg --recv-keys D47A9C8B2AE3905B563D9135BE42B352A9F6821F
Zihao
next reply other threads:[~2022-06-20 12:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 12:32 Zhu Zihao [this message]
2022-06-20 12:54 ` [bug#56107] [PATCH]: Update z3 to 4.8.17 and use cmake to build the package Maxime Devos
2022-06-21 8:16 ` Zhu Zihao
2022-07-02 23:40 ` Ludovic Courtès
2022-07-03 9:43 ` Zhu Zihao
2022-07-04 9:14 ` bug#56107: " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86mte7v7jf.fsf@163.com \
--to=all_but_last@163.com \
--cc=56107@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.