[PATCH] gnu: Add cadical

  • Done
  • quality assurance status badge
Details
3 participants
  • Max Heisinger
  • Sören Tempel
  • Steve George
Owner
unassigned
Submitted by
Max Heisinger
Severity
normal
M
M
Max Heisinger wrote on 9 Jan 14:41 +0100
(address . guix-patches@gnu.org)
cb61e44b-4ae5-4a78-a90c-8e07baa4c693@jku.at
From 89b262587c67bb2761f7bf62f3d2f5dfc065c669 Mon Sep 17 00:00:00 2001
Message-ID: <89b262587c67bb2761f7bf62f3d2f5dfc065c669.1704807579.git.maximilian.heisinger@jku.at>
From: Max Heisinger <maximilian.heisinger@jku.at>
Date: Tue, 9 Jan 2024 14:26:56 +0100
Subject: [PATCH] gnu: Add CaDiCaL.

* gnu/packages/maths.scm (cadical): Add package.

Change-Id: I300d454ce79623c737b9208623bcce0dde798f14
---
gnu/packages/maths.scm | 91 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)

Toggle diff (106 lines)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index adc7beb655..2b21ce3db2 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -8925,6 +8925,97 @@ (define-public kissat
optimized algorithms and implementation.")
(license license:expat)))
+(define-public cadical
+ (package
+ (name "cadical")
+ (version "1.9.4")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/arminbiere/cadical")
+ (commit (string-append "rel-" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1sd3r1czgm6h36fa5if2npnjpfnxjnzlnc2srkbwi2ywvsysyavi"))))
+ (build-system gnu-build-system)
+ (inputs (list xz gzip lzip bzip2 p7zip))
+ (arguments
+ (list
+ #:test-target "test"
+ #:phases #~(modify-phases %standard-phases
+ (add-after 'unpack 'patch-source
+ (lambda* (#:key inputs outputs source #:allow-other-keys)
+ (substitute* "src/file.cpp"
+ (("(bzip2|gzip|lzma|xz) -c" all cmd)
+ (string-append (search-input-file inputs
+ (string-append
+ "bin/" cmd))
+ " -c"))
+ (("7z ([ax])" all mode)
+ (string-append (search-input-file inputs "bin/7z")
+ " " mode))
+ ;; Since we hard-coded the paths, we no longer need to find
+ ;; them.
+ (("char \\*found = find\\_program \\(prg\\)")
+ "const char* found = \"<configured-at-build-time>\"")
+ (("delete\\[\\] found;")
+ ""))
+ (substitute* "scripts/make-build-header.sh"
+ ;; The identifier in Guix is the source, as the input may be
+ ;; replaced while building.
+ (("`../scripts/get-git-id.sh`")
+ source)
+ ;; Remove non-determinism by removing the date from the
+ ;; binary.
+ (("\\$DATE")
+ "<no non-deterministic timestamp in the binary>"))
+ ;; Convert the static library to a shared one.
+ (substitute* "makefile.in"
+ (("libcadical\\.a")
+ "libcadical.so")
+ (("\\$\\(COMPILE\\) -o")
+ (string-append "$(COMPILE) -Wl,-rpath="
+ (assoc-ref outputs "out") "/lib -o"))
+ (("ar rc")
+ "$(COMPILE) -shared -o"))
+ (substitute* "test/api/run.sh"
+ (("libcadical\\.a")
+ "libcadical.so"))
+ (substitute* "configure"
+ (("-static")
+ "-shared")
+ ;; Tests are not written with a shared libcadical.so in
+ ;; mind, so the LD_LIBRARY_PATH has to be set to the
+ ;; libcadical.so in the build directory while running
+ ;; tests. The rpath points to the installed directory and is
+ ;; only available after installation.
+ (("\\\\\\$\\(MAKE\\)")
+ (string-append "export LD_LIBRARY_PATH="
+ (getcwd) "/build/ ; \\\\\\$(MAKE)"))
+ (("CXXFLAGS=\"\\$CXXFLAGS\\$options\"")
+ "CXXFLAGS=\"$CXXFLAGS$options -fPIC\""))))
+ (replace 'configure
+ (lambda* (#:key configure-flags #:allow-other-keys)
+ ;; The configure script does not support standard GNU options.
+ (apply invoke "./configure" configure-flags)))
+ (replace 'install
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (install-file "build/cadical"
+ (string-append out "/bin"))
+ (install-file "build/libcadical.so"
+ (string-append out "/lib"))
+ (install-file "src/cadical.hpp"
+ (string-append out "/include"))))))))
+ (home-page "https://github.com/arminbiere/cadical")
+ (synopsis "CaDiCaL Simplified Satisfiability (SAT) Solver")
+ (description
+ "CaDiCaL is a hackable CDCL SAT solver written in C++. It offers an incremental
+API and a library for solving SAT problems given in CNF in the standard DIMACS
+format.")
+ (license license:expat)))
+
(define-public aiger
(package
(name "aiger")

base-commit: 8920cf302c5a2fd457a2629afe24cf4768f1fed7
--
2.41.0
S
S
Sören Tempel wrote on 18 May 22:48 +0200
(address . 68347@debbugs.gnu.org)
2BMVYTX997XC7.2G3UX9RRLVL6O@8pit.net
Hi,

I also started working on a CaDiCaL package for a channel of mine [1].
My version is very similar but uses a Fedora-based patch to build a
shared library instead of substitutions. However, the approach chosen
here is also fine with me.

Is there a chance that this could get merged so that we can join forces
and maintain a single CaDiCaL package in the main Guix repository? :)

Best,
Sören

M
M
Max Heisinger wrote on 22 May 16:22 +0200
(address . 68347@debbugs.gnu.org)
af782a92-e377-4eef-816c-2be8500bf3a5@jku.at
Hi,

thank you for your patch-based approach Sören! I think yours is more readable
for the Makefile changes.

We could add the substitutions for 7z, xz, etc. and the changes to
scripts/make-build-header.sh in order to make the build reproducible and not
rely on runtime $PATH searches, then we'd have combined the best from both
patches - however I'd also be fine to start with my original version and add
the patch in a later revision.

I would also be happy if we could maintain a single CaDiCaL package in the main
Guix repository :)

Best,
Max
S
S
Steve George wrote on 13 Nov 18:01 +0100
closing 68347
(address . control@debbugs.gnu.org)(address . 68347-submitter@debbugs.gnu.org)
1731517081-58-bts-steve@futurile.net
# hi both - looks like cadical is at 2.0.0 in the archive.
# thanks for sending this contribution in.
close 68347
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 68347@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 68347
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch