GNU bug report logs - #66889
[PATCH 0/2] Unbundle igraph dependencies.

Previous Next

Package: guix-patches;

Reported by: David Elsing <david.elsing <at> posteo.net>

Date: Wed, 1 Nov 2023 22:56:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66889 in the body.
You can then email your comments to 66889 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#66889; Package guix-patches. (Wed, 01 Nov 2023 22:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Elsing <david.elsing <at> posteo.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 01 Nov 2023 22:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Elsing <david.elsing <at> posteo.net>
To: guix-patches <at> gnu.org
Cc: David Elsing <david.elsing <at> posteo.net>
Subject: [PATCH 0/2] Unbundle igraph dependencies.
Date: Wed,  1 Nov 2023 22:53:38 +0000
These patches unbundle everything from igraph and update it to 0.10.7.
As newer SuiteSparse versions always use an integer width of 64, I set
the same in igraph. Would it be better to create a package variant of
suitesparse-cxsparse for igraph with an integer width depending on the
architecture? Upstream doesn't recommend unbundling CXSparse for that
reason.

David Elsing (2):
  gnu: Add pcg-c.
  gnu: igraph: Update to 0.10.7.

 gnu/local.mk                                  |   1 +
 gnu/packages/c.scm                            |  55 +++++++++
 gnu/packages/graph.scm                        | 114 +++++++++++++-----
 .../igraph-fix-varargs-integer-size.patch     |  39 ++++++
 4 files changed, 182 insertions(+), 27 deletions(-)
 create mode 100644 gnu/packages/patches/igraph-fix-varargs-integer-size.patch

-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#66889; Package guix-patches. (Wed, 01 Nov 2023 22:59:01 GMT) Full text and rfc822 format available.

Message #8 received at 66889 <at> debbugs.gnu.org (full text, mbox):

From: David Elsing <david.elsing <at> posteo.net>
To: 66889 <at> debbugs.gnu.org
Cc: David Elsing <david.elsing <at> posteo.net>
Subject: [PATCH 1/2] gnu: Add pcg-c.
Date: Wed,  1 Nov 2023 22:57:14 +0000
* gnu/packages/c.scm (pcg-c): New variable.
---
 gnu/packages/c.scm | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index ea58c68262..0c218b9656 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -20,6 +20,7 @@
 ;;; Copyright © 2022 Antero Mejr <antero <at> mailbox.org>
 ;;; Copyright © 2023 zamfofex <zamfofex <at> twdb.moe>
 ;;; Copyright © 2023 Foundation Devices, Inc. <hello <at> foundationdevices.com>
+;;; Copyright © 2023 David Elsing <david.elsing <at> posteo.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1585,3 +1586,57 @@ (define-public ispc
 program instances execute in parallel on the hardware.")
     (home-page "https://github.com/ispc/ispc")
     (license license:bsd-3)))
+
+(define-public pcg-c
+  (let ((commit "83252d9c23df9c82ecb42210afed61a7b42402d7")
+        (revision "1"))
+    (package
+      (name "pcg-c")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/imneme/pcg-c")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0768h0vw75a3smk39qsz1504v04a43s5w1ili1ijbixxv8gm42nf"))
+                (modules '((guix build utils)))
+                ;; Autogenerated files with some tests from test-high. If
+                ;; 128-bit integers are not supported, the build fails, but
+                ;; this is checked when building the tests.
+                (snippet #~(delete-file-recursively "sample"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:test-target "test"
+        #:make-flags
+        #~(list
+           "CC=gcc"
+           (string-append "PREFIX=" #$output))
+        #:phases
+        #~(modify-phases %standard-phases
+            (delete 'configure)
+            (add-after 'unpack 'disable-sample
+              (lambda _
+                (substitute* "Makefile"
+                  ((".*cd sample.*") ""))))
+            (add-after 'unpack 'set-shared-library
+              (lambda _
+                (substitute* '("Makefile" "src/Makefile")
+                  (("\\.a") "\\.so")
+                  ((".*ar .*") "\t$(CC) $(CFLAGS) -o $@ $(LDFLAGS) -shared $^")
+                  ((".*ranlib.*") "")
+                  ((".*CFLAGS \\+=.*O3.*" orig)
+                   (string-append orig "CFLAGS += -fPIC\n")))))
+            (add-before 'install 'make-dirs
+              (lambda _
+                (mkdir-p (string-append #$output "/lib"))
+                (mkdir-p (string-append #$output "/include")))))))
+      (home-page "https://www.pcg-random.org")
+      (synopsis "C implementation of the PCG random generators")
+      (description "The Permuted Congruential Generator (PCG) extends the
+Linear Congruential Generator (LCG) with a permutation function to increase
+output randomness while retaining speed, simplicity, and conciseness.")
+      (license (list license:expat license:asl2.0))))) ; dual licensed
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#66889; Package guix-patches. (Wed, 01 Nov 2023 22:59:02 GMT) Full text and rfc822 format available.

Message #11 received at 66889 <at> debbugs.gnu.org (full text, mbox):

From: David Elsing <david.elsing <at> posteo.net>
To: 66889 <at> debbugs.gnu.org
Cc: David Elsing <david.elsing <at> posteo.net>
Subject: [PATCH 2/2] gnu: igraph: Update to 0.10.7.
Date: Wed,  1 Nov 2023 22:57:15 +0000
* gnu/packages/graph.scm (igraph): Update to 0.10.7.
[source]: Use git-fetch. Apply patch.
<snippet>: Remove the entire "vendor" and "src/isomorphism/bliss" directories.
Patch CMakeLists.txt to not build and use vendored dependencies.
[arguments]: Add -DIGRAPH_INTEGER_SIZE=64 to #:configure-flags. Add phases to
use unbundled libraries and build documentation.
[native-inputs]: Add bison, docbook-xml-4.3, docbook-xsl, flex, pcg-c, python,
source-highlight and xmlto.
[inputs]: Remove gmp and libxml2. Add bliss and suitesparse-cxsparse.
* gnu/packages/patches/igraph-fix-varargs-integer-size.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
---
 gnu/local.mk                                  |   1 +
 gnu/packages/graph.scm                        | 114 +++++++++++++-----
 .../igraph-fix-varargs-integer-size.patch     |  39 ++++++
 3 files changed, 127 insertions(+), 27 deletions(-)
 create mode 100644 gnu/packages/patches/igraph-fix-varargs-integer-size.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 8d817379a7..b51d9d15e8 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1428,6 +1428,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/id3lib-CVE-2007-4460.patch			\
   %D%/packages/patches/id3lib-UTF16-writing-bug.patch			\
   %D%/packages/patches/idris-test-ffi008.patch			\
+  %D%/packages/patches/igraph-fix-varargs-integer-size.patch	\
   %D%/packages/patches/igt-gpu-tools-Use-libproc2.patch		\
   %D%/packages/patches/ilmbase-fix-tests.patch			\
   %D%/packages/patches/imagemagick-CVE-2020-27829.patch		\
diff --git a/gnu/packages/graph.scm b/gnu/packages/graph.scm
index 45a591b9f3..a40b580417 100644
--- a/gnu/packages/graph.scm
+++ b/gnu/packages/graph.scm
@@ -10,6 +10,7 @@
 ;;; Copyright © 2021 Alexandre Hannud Abdo <abdo <at> member.fsf.org>
 ;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2022 Marius Bakke <marius <at> gnu.org>
+;;; Copyright © 2023 David Elsing <david.elsing <at> posteo.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -40,13 +41,18 @@ (define-module (gnu packages graph)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages bioconductor)
   #:use-module (gnu packages bioinformatics)
+  #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cran)
   #:use-module (gnu packages datastructures)
+  #:use-module (gnu packages docbook)
+  #:use-module (gnu packages flex)
   #:use-module (gnu packages gd)
   #:use-module (gnu packages graphics)
   #:use-module (gnu packages graphviz)
@@ -55,6 +61,7 @@ (define-module (gnu packages graph)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pretty-print)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-build)
   #:use-module (gnu packages python-compression)
@@ -93,49 +100,102 @@ (define-public plfit
 (define-public igraph
   (package
     (name "igraph")
-    (version "0.10.4")
+    (version "0.10.7")
     (source
      (origin
-       (method url-fetch)
-       (uri (string-append "https://github.com/igraph/igraph/releases/"
-                           "download/" version "/igraph-" version ".tar.gz"))
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/igraph/igraph")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (patches (search-patches "igraph-fix-varargs-integer-size.patch"))
        (modules '((guix build utils)
                   (ice-9 ftw)
                   (srfi srfi-26)))
        (snippet '(begin
-                   ;; igraph insists on building its own copy of CxSparse
-                   ;; (see: https://github.com/igraph/igraph/commit/\
-                   ;; 334318b7dfe46501236272ca336580f4748114b0) and the build
-                   ;; has no support to use a system provided 'pcg'.
-                   (define keep-libraries '("cs" "pcg"))
-                   (define keep (append '("." ".." "CMakeLists.txt")
-                                        keep-libraries))
-                   (define keep? (cut member <> keep))
-                   (with-directory-excursion "vendor"
-                     (for-each delete-file-recursively
-                               (scandir "." (negate keep?))))
-                   (call-with-output-file "vendor/CMakeLists.txt"
-                     (cut format <> "~{add_subdirectory(~a)~%~}"
-                          keep-libraries))
+
+                   (delete-file-recursively "vendor")
+                   (delete-file-recursively "src/isomorphism/bliss")
                    (substitute* '("src/CMakeLists.txt"
                                   "etc/cmake/benchmark_helpers.cmake")
                      ;; Remove extraneous bundling related variables.
-                     ((".*_IS_VENDORED.*")
-                      ""))))
+                     ((".*_IS_VENDORED.*") "")
+                     ((".*add_sub.*isomorphism/bliss.*") "")
+                     (("(.*TARGETS.*)bliss(.*)cxsparse_vendored(.*)pcg(.*)"
+                       _ part1 part2 part3 part4)
+                      (string-append part1 part2 part3 part4))
+                     (("cxsparse_vendored") "cxsparse")
+                     ((" pcg ") " pcg_random "))
+                   (substitute* "CMakeLists.txt"
+                     (("add_sub.*vendor.*") ""))))
        (sha256
-        (base32 "1z1ay3l1h64jc2igbl2ibvi20sswy56v2yk3ykhis7jzijsh0mxa"))))
+        (base32
+         "025f9c2jsawniqkig4l5z3v9aw3ipazmnlsf80b653mns5bvj1yn"))))
     (build-system cmake-build-system)
-    (arguments (list #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON")
-                     #:test-target "check"))
-    (native-inputs (list pkg-config))
+    (arguments
+     (list
+      #:configure-flags
+      #~(list "-DBUILD_SHARED_LIBS=ON"
+              ;; Use the same integer width as suitesparse-cxsparse, which
+              ;; uses int64_t in SuiteSparse v6.0.0 and later.
+              "-DIGRAPH_INTEGER_SIZE=64")
+      #:test-target "check"
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'version-file
+            (lambda _
+              (let ((port (open-file "IGRAPH_VERSION" "w")))
+                (display #$version port)
+                (close port))))
+          (add-after 'unpack 'patch-suitesparse
+            (lambda _
+              (substitute* '("src/core/sparsemat.c"
+                             "include/igraph_sparsemat.h")
+                (("<cs/cs\\.h>") "<cs.h>")
+                (("cs_igraph") "cs_dl")
+                (("__BEGIN_DECLS.*" all)
+                 (string-append all "\n#define CS_LONG\n")))))
+          (add-after 'unpack 'patch-pcg
+            (lambda _
+              (substitute* '("src/random/rng_pcg32.c"
+                             "src/random/rng_pcg64.c")
+                (("#include \"pcg/(.*)\"" _ name)
+                 (string-append "#include <" name ">")))))
+          (add-after 'unpack 'patch-bliss
+            (lambda _
+              (substitute* "src/isomorphism/bliss.cc"
+                (("#include \"bliss.*")
+                 (string-append
+                  "#include <bliss/graph.hh>\n"
+                  "#include <bliss/digraph.hh>\n")))))
+          (add-after 'build 'build-doc
+            (lambda _
+              (invoke "cmake" "--build" "." "--target" "html")))
+          (add-after 'install 'install-doc
+            (lambda _
+              (copy-recursively
+               "doc/html"
+               (string-append #$output "/share/doc/"
+                              #$name "-" #$version "/html")))))))
+    (native-inputs
+     (list bison
+           docbook-xml-4.3
+           docbook-xsl
+           flex
+           pcg-c
+           pkg-config
+           ;; For the HTML documentation.
+           python
+           source-highlight
+           xmlto))
     (inputs
      (list arpack-ng
-           gmp
+           bliss
            glpk
-           libxml2
            lapack
            openblas
-           plfit))
+           plfit
+           suitesparse-cxsparse))
     ;; libxml2 is in the 'Requires.private' of igraph.pc.
     (propagated-inputs (list libxml2))
     (home-page "https://igraph.org")
diff --git a/gnu/packages/patches/igraph-fix-varargs-integer-size.patch b/gnu/packages/patches/igraph-fix-varargs-integer-size.patch
new file mode 100644
index 0000000000..2d7ffd7e68
--- /dev/null
+++ b/gnu/packages/patches/igraph-fix-varargs-integer-size.patch
@@ -0,0 +1,39 @@
+If the size of int is different from IGRAPH_INTEGER_SIZE, the integer size
+passed to these vararg arguments is different from the assumed one,
+leading to undefined behavior.
+Submitted upstream: https://github.com/igraph/igraph/pull/2423
+
+
+diff -ur a/examples/simple/igraph_union.c b/examples/simple/igraph_union.c
+--- a/examples/simple/igraph_union.c
++++ b/examples/simple/igraph_union.c
+@@ -103,7 +103,7 @@
+     igraph_vector_ptr_init(&glist, 10);
+     for (i = 0; i < igraph_vector_ptr_size(&glist); i++) {
+         VECTOR(glist)[i] = calloc(1, sizeof(igraph_t));
+-        igraph_vector_int_init_int_end(&v, -1, i, i + 1, 1, 0, -1);
++        igraph_vector_int_init_int_end(&v, -1, (int) i, (int) i + 1, 1, 0, -1);
+         igraph_create(VECTOR(glist)[i], &v, 0, IGRAPH_DIRECTED);
+         igraph_vector_int_destroy(&v);
+     }
+@@ -123,7 +123,7 @@
+     igraph_vector_ptr_init(&glist, 10);
+     for (i = 0; i < igraph_vector_ptr_size(&glist); i++) {
+         VECTOR(glist)[i] = calloc(1, sizeof(igraph_t));
+-        igraph_vector_int_init_int_end(&v, -1, i, i + 1, 1, 0, -1);
++        igraph_vector_int_init_int_end(&v, -1, (int) i, (int) i + 1, 1, 0, -1);
+         igraph_create(VECTOR(glist)[i], &v, 0, IGRAPH_UNDIRECTED);
+         igraph_vector_int_destroy(&v);
+     }
+diff -ur a/src/core/matrix.pmt b/src/core/matrix.pmt
+--- a/src/core/matrix.pmt
++++ b/src/core/matrix.pmt
+@@ -1863,7 +1863,7 @@
+ #ifdef FPRINTFUNC_ALIGNED
+             FPRINTFUNC_ALIGNED(file, VECTOR(column_width)[j], MATRIX(*m, i, j));
+ #else
+-            fprintf(file, format, VECTOR(column_width)[j], MATRIX(*m, i, j));
++            fprintf(file, format, (int) VECTOR(column_width)[j], MATRIX(*m, i, j));
+ #endif
+         }
+         fprintf(file, "\n");
-- 
2.41.0





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sat, 02 Dec 2023 10:59:02 GMT) Full text and rfc822 format available.

Notification sent to David Elsing <david.elsing <at> posteo.net>:
bug acknowledged by developer. (Sat, 02 Dec 2023 10:59:02 GMT) Full text and rfc822 format available.

Message #16 received at 66889-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: David Elsing <david.elsing <at> posteo.net>
Cc: 66889-done <at> debbugs.gnu.org
Subject: Re: [bug#66889] [PATCH 0/2] Unbundle igraph dependencies.
Date: Sat, 02 Dec 2023 11:58:24 +0100
Hi David,

David Elsing <david.elsing <at> posteo.net> skribis:

> These patches unbundle everything from igraph and update it to 0.10.7.
> As newer SuiteSparse versions always use an integer width of 64, I set
> the same in igraph. Would it be better to create a package variant of
> suitesparse-cxsparse for igraph with an integer width depending on the
> architecture? Upstream doesn't recommend unbundling CXSparse for that
> reason.

I don’t know what would be better, but what you did here LGTM.

> David Elsing (2):
>   gnu: Add pcg-c.
>   gnu: igraph: Update to 0.10.7.

Finally applied, thanks!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 30 Dec 2023 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 158 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.