unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#66889] [PATCH 0/2] Unbundle igraph dependencies.
@ 2023-11-01 22:53 David Elsing
  2023-11-01 22:57 ` [bug#66889] [PATCH 1/2] gnu: Add pcg-c David Elsing
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Elsing @ 2023-11-01 22:53 UTC (permalink / raw)
  To: 66889; +Cc: David Elsing

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [bug#66889] [PATCH 1/2] gnu: Add pcg-c.
  2023-11-01 22:53 [bug#66889] [PATCH 0/2] Unbundle igraph dependencies David Elsing
@ 2023-11-01 22:57 ` David Elsing
  2023-11-01 22:57 ` [bug#66889] [PATCH 2/2] gnu: igraph: Update to 0.10.7 David Elsing
  2023-12-02 10:58 ` bug#66889: [PATCH 0/2] Unbundle igraph dependencies Ludovic Courtès
  2 siblings, 0 replies; 4+ messages in thread
From: David Elsing @ 2023-11-01 22:57 UTC (permalink / raw)
  To: 66889; +Cc: David Elsing

* 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@mailbox.org>
 ;;; Copyright © 2023 zamfofex <zamfofex@twdb.moe>
 ;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
+;;; Copyright © 2023 David Elsing <david.elsing@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





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [bug#66889] [PATCH 2/2] gnu: igraph: Update to 0.10.7.
  2023-11-01 22:53 [bug#66889] [PATCH 0/2] Unbundle igraph dependencies David Elsing
  2023-11-01 22:57 ` [bug#66889] [PATCH 1/2] gnu: Add pcg-c David Elsing
@ 2023-11-01 22:57 ` David Elsing
  2023-12-02 10:58 ` bug#66889: [PATCH 0/2] Unbundle igraph dependencies Ludovic Courtès
  2 siblings, 0 replies; 4+ messages in thread
From: David Elsing @ 2023-11-01 22:57 UTC (permalink / raw)
  To: 66889; +Cc: David Elsing

* 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@member.fsf.org>
 ;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2023 David Elsing <david.elsing@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





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#66889: [PATCH 0/2] Unbundle igraph dependencies.
  2023-11-01 22:53 [bug#66889] [PATCH 0/2] Unbundle igraph dependencies David Elsing
  2023-11-01 22:57 ` [bug#66889] [PATCH 1/2] gnu: Add pcg-c David Elsing
  2023-11-01 22:57 ` [bug#66889] [PATCH 2/2] gnu: igraph: Update to 0.10.7 David Elsing
@ 2023-12-02 10:58 ` Ludovic Courtès
  2 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2023-12-02 10:58 UTC (permalink / raw)
  To: David Elsing; +Cc: 66889-done

Hi David,

David Elsing <david.elsing@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’.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-02 10:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-01 22:53 [bug#66889] [PATCH 0/2] Unbundle igraph dependencies David Elsing
2023-11-01 22:57 ` [bug#66889] [PATCH 1/2] gnu: Add pcg-c David Elsing
2023-11-01 22:57 ` [bug#66889] [PATCH 2/2] gnu: igraph: Update to 0.10.7 David Elsing
2023-12-02 10:58 ` bug#66889: [PATCH 0/2] Unbundle igraph dependencies Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).