From patchwork Wed Apr 2 05:25:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Raven Hallsby X-Patchwork-Id: 41148 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4CE1527BBE9; Wed, 2 Apr 2025 06:27:32 +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=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 17AFA27BBE2 for ; Wed, 2 Apr 2025 06:27:30 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tzqd2-0002tK-FF; Wed, 02 Apr 2025 01:27:08 -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 ) id 1tzqd0-0002sj-AW for guix-patches@gnu.org; Wed, 02 Apr 2025 01:27:06 -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 ) id 1tzqcz-00016s-Rs for guix-patches@gnu.org; Wed, 02 Apr 2025 01:27:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=RjfKQ6NepDTJcuZlQCRXsJZct5R5GvN167V02X8VHpY=; b=SYnlD6Xp4hM2ao+TewCVGzkfpJjh8hphdPD/2U5dLTU+L23U7b6s8uJ/IZr6TBNuniVL39IIhpy+G7urJ1CGacfkktLEv2Qzr+Zz+aphHrcL2AwV4j4qVDzJEazCtZemp7Hg+wsR43VhAY0OGF+NIZQYePHzG/R+aociGOXJDLO1AdQmePbH/6JLqT8ODRO7haTD208FIicg8v1O48yDdN2IINL/gSg8P5Nrq+iheYx2UB/H1XPFNXvFSYujodgqZKkpj4FgopFKtxWNABe3A6FajzKTJLtEYqvtStdq5eKyO2t6vPDFwDMaCrZtMwEhQeMgl/eUv5Zr4RnoqEBiVg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tzqcz-0001eH-JJ for guix-patches@gnu.org; Wed, 02 Apr 2025 01:27:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77448] [PATCH 2/2] gnu: Add souffle Resent-From: Raven Hallsby Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 02 Apr 2025 05:27:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77448 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77448@debbugs.gnu.org Cc: Raven Hallsby Received: via spool by 77448-submit@debbugs.gnu.org id=B77448.17435715675930 (code B ref 77448); Wed, 02 Apr 2025 05:27:05 +0000 Received: (at 77448) by debbugs.gnu.org; 2 Apr 2025 05:26:07 +0000 Received: from localhost ([127.0.0.1]:53694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tzqbx-0001Wm-Qz for submit@debbugs.gnu.org; Wed, 02 Apr 2025 01:26:06 -0400 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]:54781) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tzqbu-0001Vk-2W for 77448@debbugs.gnu.org; Wed, 02 Apr 2025 01:25:59 -0400 Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-3cda56e1dffso29600115ab.1 for <77448@debbugs.gnu.org>; Tue, 01 Apr 2025 22:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hallsby.com; s=google; t=1743571552; x=1744176352; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RjfKQ6NepDTJcuZlQCRXsJZct5R5GvN167V02X8VHpY=; b=DtPYUKNsQHjJXocoClJRhIn8ILpKPDhy2Yx42uW/VfQl6WBxQVICBoiG1YUyXJh3Lt Ej6VrHK0hJ9T0kRsyFPXVsYdeaUKpdQpu9IOhdo86Kz0ZX0nU68qTNwBbDGnbOemD4sp qb1WtJsBTAl5ZHquMLwGtCxW2+Ws0FCvZ/HY8oVVP1akz5wO2fAKJmDSTVuSsb00G+wg /5/3Q47Jmda3SD1q9XBJ35CdbH7qCpI+Vgb1gRkKZ+NBVZpmjl1pU6/lJnx2MkwqpJcD SyoSJ8NQrRy8ICkLlo8NeMtbXo07s2TBSBtHEiBQw212tY0LbWIinbkc4oTODdmZSBFQ zZ2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743571552; x=1744176352; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RjfKQ6NepDTJcuZlQCRXsJZct5R5GvN167V02X8VHpY=; b=dUrLLVKXm4pvpYlSWDAz2ctkDs7hmX5UQWPvlqy5gjZ1Ppvk0MtY6O5cpXJW6sFeIS kvg3nI/Sm9uWfyuiYrCgI3CalGXVNt8PPWZgBYleYSeh8TxtOlSk0oPcbA2UHy1fiyvx BgfrcJn1kY0TJ9rTowjtvo+y49hKrVg923jyxZxJ7f9CgUR9HWp3HIBdw5dsapPycDnX fQBeedtleCufnaIJYuX7T4a6luUK1fv861wu2u8I2+jHVbBjsF3yIk1q9GvYTlW2Wsm8 +NqWiYzeXpdFUGmnAUlC2G6jolGoW4gw/k7Uz2nDM9/B0pmqyFHr3BgaO96WZE65Zsyo gNVA== X-Gm-Message-State: AOJu0YxFmCSt2U/9UgrEzJr6Iw+Wm0rFje/NzA2v/m0MWPS86UEk9E7L j3VGCNKIFKJCKHk66QZNyn9JrqlMeDPZslwNSP2phq1spWc/25tXgRHImOtorlBHBEG62wT5N6Q = X-Gm-Gg: ASbGncsFePOXy3qMGvlLP4U1z8etUumC5nvpwcJvQNZ0Xjoo+AOqjHn8U20TTabJywO m6ebvytNilaxUCgWA36ecljCZXGeGuuWKmeDncy3HSCYxY0lYIOgiHVDao1jZRpaetnel8V31nC q0ritEmFL1kXIg7lKgSVelbCMnVvF458PTZwteFqBb++rl4q/mf1whmZZy6ihbtcw4KQgjCrWaU dH2E+HYV/eJoDB96l94Ew59RB7s/2LKfUUcpycpywQWrE5yYqamkrNxatxVMlEWUorgXoONUdv5 h7ai0R0M5aS5CPQHKVBtXzB6JPzu2kadp73hw1gCY2N0qcVm5w== X-Google-Smtp-Source: AGHT+IGoW067s2sEKPOVqcXjJVgvQZGpvoG/imLdqjJiqRpHm0k0m8LfJMFEGqCB3BojhAMMxcz2eA== X-Received: by 2002:a05:6e02:3c82:b0:3cf:c7d3:e4b with SMTP id e9e14a558f8ab-3d5e0a09a11mr172877805ab.21.1743571551525; Tue, 01 Apr 2025 22:25:51 -0700 (PDT) Received: from Karl-Desktop.raven ([207.237.222.72]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4f46489d849sm2742981173.108.2025.04.01.22.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 22:25:51 -0700 (PDT) Date: Wed, 2 Apr 2025 00:25:15 -0500 Message-ID: <7f59b2bec9c480dbecc35fc231ce4b07996762b8.1743570894.git.karl@hallsby.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Raven Hallsby X-ACL-Warn: , Raven Hallsby via Guix-patches X-Patchwork-Original-From: Raven Hallsby via Guix-patches via From: Raven Hallsby 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 From: Karl Hallsby * gnu/packages/datalog.scm: New file. * gnu/local.mk: Register it. * gnu/packages/datalog.scm (souffle): New variable. Change-Id: I5ac1a2ed943a79f50a85794585804522fddf0bdc --- gnu/local.mk | 1 + gnu/packages/datalog.scm | 235 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+) create mode 100644 gnu/packages/datalog.scm diff --git a/gnu/local.mk b/gnu/local.mk index a96ca42532d..b6791eb0c26 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -240,6 +240,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/data-language.scm \ %D%/packages/databases.scm \ %D%/packages/datamash.scm \ + %D%/packages/datalog.scm \ %D%/packages/datastructures.scm \ %D%/packages/dav.scm \ %D%/packages/dbm.scm \ diff --git a/gnu/packages/datalog.scm b/gnu/packages/datalog.scm new file mode 100644 index 00000000000..89fd6583acb --- /dev/null +++ b/gnu/packages/datalog.scm @@ -0,0 +1,235 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2025 Raven Hallsby +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages datalog) + #:use-module (guix download) + #:use-module (guix gexp) + #:use-module (guix git-download) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix build-system cmake) + #:use-module (guix utils) + #:use-module (gnu packages bash) + #:use-module (gnu packages bison) + #:use-module (gnu packages commencement) + #:use-module (gnu packages compression) + #:use-module (gnu packages cpp) + #:use-module (gnu packages documentation) + #:use-module (gnu packages flex) + #:use-module (gnu packages fontutils) + #:use-module (gnu packages ghostscript) + #:use-module (gnu packages graphviz) + #:use-module (gnu packages java) + #:use-module (gnu packages libffi) + #:use-module (gnu packages ncurses) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages python) + #:use-module (gnu packages sqlite) + #:use-module (gnu packages swig) + #:use-module (gnu packages version-control)) + +(define-public souffle + ;; 2.4.1 is the most recent tagged commit, but is from 2023. A commit from + ;; 2024 (040a962f) fixes the last 2 unit test failures that 2.4.1 experienced. + ;; So we use a more recent commit hash instead. + (let ((commit "94ccab0127d78a2c295730e8c8f560aabc82ea0f") + (revision "0")) + (package + (name "souffle") + (version (string-append "2.4.1-" revision "." + (string-take commit 7))) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/souffle-lang/souffle") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0k27cf1h6bl6rwkk4zkwpsfk2n4814fda2v7mcin0r9wkx1pdrxi")))) + (native-inputs + (list bison flex + ;; Only needed for building documentation + doxygen fontconfig font-ghostscript graphviz-minimal)) + (inputs + (list gcc-toolchain + mcpp + python-minimal + bash-minimal + libffi + ncurses + sqlite + swig + `(,openjdk "jdk") + zlib)) + (build-system cmake-build-system) + (arguments + (list + #:configure-flags + #~(list + ;; Prevent souffle from calling out to git for a version number + "-DSOUFFLE_GIT=OFF" + ;; Use larger representation values. + "-DSOUFFLE_DOMAIN_64BIT=ON" + ;; Allow Java/Python/others to use libffi to interop with souffle. + "-DSOUFFLE_SWIG=ON" + ;; By default Souffle only runs tests on evaluation examples. We + ;; force it to also test its code examples. + "-DSOUFFLE_ENABLE_TESTING=ON" + "-DSOUFFLE_TEST_EXAMPLES=ON" + "-DSOUFFLE_TEST_EVALUATION=ON" + ;; Enable documentation target + "-DSOUFFLE_GENERATE_DOXYGEN=man" + ;; Generate Bash completions + "-DSOUFFLE_BASH_COMPLETION=on" + (string-append "-DBASH_COMPLETION_COMPLETIONSDIR=" + #$output "/etc/bash_completion.d")) + #:phases + #~(modify-phases %standard-phases + ;; Allow for parallel testing. The -j in the "make check" command does + ;; not propagate to ctest. With 4500+ tests, and some taking multiple + ;; minutes to finish, parallelism really helps. + (replace 'check + (lambda* (#:key tests? parallel-tests? #:allow-other-keys) + (setenv "CTEST_OUTPUT_ON_FAILURE" "1") + (when tests? (invoke "ctest" "--output-on-failure" "-j" + (if parallel-tests? + (number->string (parallel-job-count)) + "1"))))) + (add-after 'check 'build-docs + (lambda* (#:key inputs #:allow-other-keys) + ;; Already in build/ directory + ;; Set a cache directory for fontconfig + (setenv "XDG_CACHE_HOME" (mkdtemp "/tmp/cache-XXXXXX")) + (invoke "make" "doxygen"))) + (add-after 'install 'install-docs + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + ;; Still currently in build/ + (format #t "~a~%" (getcwd)) + (with-directory-excursion "../source" + (format #t "excursion: ~a~%" (getcwd)) + (mkdir-p (string-append out "/share/man/man1/")) + (copy-recursively "man/" + (string-append out "/share/man/man1/")) + (mkdir-p (string-append out "/share/man/man3/")) + (install-file "doc/man/man3/souffle.3" + (string-append out "/share/man/man3/")))))) + ;; Clean up various files and wrap binaries. + ;; The compiler wrapper script takes many of its values from an + ;; embedded JSON string rather than environment variables, which + ;; makes some of our wrapping ineffective. + (add-after 'install 'wrap-programs + (lambda* (#:key inputs #:allow-other-keys) + ;; Wrap the compiled binaries that point to the libraries + ;; souffle needs at runtime. + (wrap-program (string-append #$output "/bin/souffle") + `("PATH" ":" prefix + ;; Souffle has a "build system" that will run the souffle + ;; compiler to produce a C++ program and then run g++ to + ;; build the final binary. + ,(list (string-append (assoc-ref inputs "swig") "/bin") + (string-append (assoc-ref inputs "python-minimal") + "/bin") + (string-append (assoc-ref inputs "mcpp") "/bin") + (string-append (assoc-ref inputs "gcc-toolchain") + "/bin"))) + `("C_INCLUDE_PATH" ":" prefix + ,(list (string-append #$output "/include") + (string-append (assoc-ref inputs "gcc-toolchain") + "/include") + (string-append (assoc-ref inputs "zlib") "/include") + (string-append (assoc-ref inputs "ncurses") "/include") + (string-append (assoc-ref inputs "sqlite") "/include") + (string-append (assoc-ref inputs "libffi") "/include"))) + `("CPLUS_INCLUDE_PATH" ":" prefix + ;; Souffle needs to know where its own headers are. + ,(list (string-append #$output "/include") + (string-append (assoc-ref inputs "gcc-toolchain") "/include/c++") + (string-append (assoc-ref inputs "gcc-toolchain") "/include") + (string-append (assoc-ref inputs "zlib") "/include") + (string-append (assoc-ref inputs "ncurses") "/include") + (string-append (assoc-ref inputs "sqlite") "/include") + (string-append (assoc-ref inputs "libffi") "/include"))) + ;; Make sure g++ and co. can find necessary files when + ;; compiling the souffle-generated C++ program. In particular, + ;; crt1.o and crti.o need to be found. + ;; The final compiled program has rpaths set to libraries by + ;; the compiler script. So no LD_LIBRARY_PATH changes are + ;; needed. + `("LIBRARY_PATH" ":" prefix + ,(list (string-append #$output "/lib") ; Technically Souffle has no /lib + (string-append (assoc-ref inputs "gcc-toolchain") "/lib") + (string-append (assoc-ref inputs "zlib") "/lib") + (string-append (assoc-ref inputs "ncurses") "/lib") + (string-append (assoc-ref inputs "sqlite") "/lib") + (string-append (assoc-ref inputs "libffi") "/lib")))) + ;; And now we must "wrap" souffle's compiler wrapper script's + ;; internal JSON config file, so the invoked g++ can find + ;; everything it needs. + (with-directory-excursion #$output + (let ((includes (list (string-append #$output "/include") + (string-append (assoc-ref inputs "gcc-toolchain") "/include/c++") + (string-append (assoc-ref inputs "gcc-toolchain") "/include") + (string-append (assoc-ref inputs "zlib") "/include") + (string-append (assoc-ref inputs "ncurses") "/include") + (string-append (assoc-ref inputs "sqlite") "/include") + (string-append (assoc-ref inputs "libffi") "/include") + (string-append (assoc-ref inputs "libc") "/lib") + ;; Need an explicit path to ? + (string-append (assoc-ref inputs "kernel-headers") "/include"))) + (libs (list (string-append (assoc-ref inputs "gcc-toolchain") "/lib") + (string-append (assoc-ref inputs "zlib") "/lib") + (string-append (assoc-ref inputs "ncurses") "/lib") + (string-append (assoc-ref inputs "sqlite") "/lib") + (string-append (assoc-ref inputs "libffi") "/lib") + (string-append (assoc-ref inputs "libc") "/lib")))) + (substitute* "bin/souffle-compile.py" + ;; Make C++ includes & linking work and remove embedded build path + (("(\"includes\"): \"([[[[:alnum:] -_.]+)\"," all option prev-vals) + (string-append option ": \"" + (string-join includes " -I" 'prefix) " " + "\",")) + (("(\"link_options\"): \"([[:alnum:] -_.]+)\"," all option prev-options) + (string-append option ": \"" + (string-join libs " -L" 'prefix) " " + prev-options + "\",")) + ;; Remove embedded build path + (("(\"source_include_dir\"): \".*\"," all option) + (string-append option ": \"\",")))))))))) + ;; (native-search-paths + ;; (list (search-path-specification + ;; (variable "C_INCLUDE_PATH") + ;; (files '("include"))) + ;; (search-path-specification + ;; (variable "CPLUS_INCLUDE_PATH") + ;; (files '("include"))) + ;; (search-path-specification + ;; (variable "LIBRARY_PATH") + ;; (files '("lib"))))) + (home-page "https://souffle-lang.github.io") + (synopsis "Compiler for a variant of Datalog using Horn clauses") + (description + "Souffle is a logic programming language inspired by Datalog by +crafting analyses in Horn clauses. It overcomes some of the limitations in +classical Datalog. For example, programmers are not restricted to finite +domains, and the usage of functors (intrinsic, user-defined, +records/constructors, etc.) is permitted. Souffle has a component model so +that large logic projects can be expressed.") + (license license:upl1.0))))