On Thu, Jun 22, 2023 at 08:47:48PM +0200, Simon Tournier wrote:
> Hi,
> 
> On Thu, 22 Jun 2023 at 19:25, Efraim Flashner <efr...@flashner.co.il> wrote:
> 
> > (ins)efraim@3900XT ~/workspace/guix$ cat 
> > /gnu/store/v6z5ykkjfzbc72x1x900xflspqc5wd5r-openblas-ilp64-0.3.20/lib/pkgconfig/openblas.pc
> > libdir=/gnu/store/v6z5ykkjfzbc72x1x900xflspqc5wd5r-openblas-ilp64-0.3.20/lib
> > includedir=/gnu/store/v6z5ykkjfzbc72x1x900xflspqc5wd5r-openblas-ilp64-0.3.20/include
> > openblas_config= USE_64BITINT= DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 NO_CBLAS= 
> > NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP= generic MAX_THREADS=128
> > version=0.3.20
> > extralib=-lm -lpthread -lgfortran -lm -lpthread -lgfortran
> > Name: openblas
> > Description: OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 
> > BSD version
> > Version: ${version}
> > URL: https://github.com/xianyi/OpenBLAS
> > Libs: -L${libdir} -lopenblas
> > Libs.private: ${extralib}
> > Cflags: -I${includedir}
> >
> > Looks like it should be "LIBBLAS=-lopenblas"
> 
> I propose to tweak openblas-ilp64.  Currently it looks like:
> 
> --8<---------------cut here---------------start------------->8---
> $ tree $(guix build openblas-ilp64)/lib
> /gnu/store/v6z5ykkjfzbc72x1x900xflspqc5wd5r-openblas-ilp64-0.3.20/lib
> ├── cmake
> │   └── openblas
> │       ├── OpenBLASConfig.cmake
> │       └── OpenBLASConfigVersion.cmake
> ├── libopenblas_ilp64p-r0.3.20.so
> ├── libopenblas_ilp64.so -> libopenblas_ilp64p-r0.3.20.so
> ├── libopenblas_ilp64.so.0 -> libopenblas_ilp64p-r0.3.20.so
> └── pkgconfig
>     └── openblas.pc
> --8<---------------cut here---------------end--------------->8---
> 
> which is inconsistent with pkgconfig as you noticed above.  Therefore, I
> am proposing the addition of a symlink of libopenblas_ilp64p.so to
> libopenblas.so.  For instance this attached patch.

I've attached the patch that I've made it to. julia is built with
openblas-ilp64 on 64-bit architectures, openblas-ilp64 has its
configure-flags adjusted to match what other programs are expecting, and
I've also patched python-numpy to use openblas-ilp64 as another test
target.

-- 
Efraim Flashner   <efr...@flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
diff --git a/gnu/packages/julia.scm b/gnu/packages/julia.scm
index ba54175822..e96131dfc0 100644
--- a/gnu/packages/julia.scm
+++ b/gnu/packages/julia.scm
@@ -269,7 +269,10 @@ (define-public julia
                (substitute* (jlpath "nghttp2")
                  (((from "libnghttp2")) (to "libnghttp2" "libnghttp2")))
                (substitute* (jlpath "OpenBLAS")
-                 (((from "libopenblas")) (to "openblas" "libopenblas")))
+                 (((from "libopenblas"))
+                  ,@(if (target-64bit?)
+                      `((to "openblas" "libopenblas64_" "libopenblas"))
+                      `((to "openblas" "libopenblas")))))
                (substitute* (jlpath "OpenLibm")
                  (((from "libopenlibm")) (to "openlibm" "libopenlibm")))
                (substitute* (jlpath "PCRE2")
@@ -479,12 +482,12 @@ (define-public julia
          "NO_GIT=1"             ; build from release tarball.
          "USE_GPL_LIBS=1"       ; proudly
 
-         ,@(if (target-aarch64?)
-             `("USE_BLAS64=0")
-             '())
-
-         "LIBBLAS=-lopenblas"
-         "LIBBLASNAME=libopenblas"
+         ,@(if (target-64bit?)
+             `("USE_BLAS64=1"
+               "LIBBLAS=-lopenblas64_"
+               "LIBBLASNAME=libopenblas64_")
+             `("LIBBLAS=-lopenblas"
+               "LIBBLASNAME=libopenblas"))
 
          (string-append "UTF8PROC_INC="
                         (assoc-ref %build-inputs "utf8proc")
@@ -513,7 +516,9 @@ (define-public julia
        ("llvm" ,llvm-julia)
        ("mbedtls-apache" ,mbedtls-apache)
        ("mpfr" ,mpfr)
-       ("openblas" ,openblas)
+       ,@(if (target-64bit?)
+             `(("openblas" ,openblas-ilp64))
+             `(("openblas" ,openblas)))
        ("openlibm" ,openlibm)
        ("p7zip" ,p7zip)
        ("pcre2" ,pcre2)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index f5a2181905..2d3ce41cb7 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -4645,7 +4645,9 @@ (define-public openblas-ilp64
     (arguments
      (substitute-keyword-arguments (package-arguments openblas)
        ((#:make-flags flags #~'())
-        #~(append (list "INTERFACE64=1" "LIBNAMESUFFIX=ilp64")
+        #~(append (list "INTERFACE64=1"
+                        "SYMBOLSUFFIX=64_"
+                        "LIBPREFIX=libopenblas64_")
                  #$flags))))
     (synopsis "Optimized BLAS library based on GotoBLAS (ILP64 version)")
     (license license:bsd-3)))
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index b650b71f3b..deeffb67ae 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -6953,19 +6953,36 @@ (define-public python-numpy
             (lambda _
               (setenv "NPY_NUM_BUILD_JOBS"
                       (number->string (parallel-job-count)))))
-          (add-before 'build 'configure-blas
-            (lambda* (#:key inputs #:allow-other-keys)
-              (call-with-output-file "site.cfg"
-                (lambda (port)
-                  (format port
-                          "\
+          #$@(if (target-64bit?)
+               #~((add-before 'build 'configure-blas
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (setenv "NPY_USE_BLAS_ILP64" "1")
+                      (setenv "NPY_BLAS_ILP64_ORDER" "openblas64_")
+                      (setenv "NPY_LAPACK_ILP64_ORDER" "openblas64_")
+                      (call-with-output-file "site.cfg"
+                        (lambda (port)
+                          (format port
+                                  "\
+[openblas64_]
+libraries = openblas64_
+library_dirs = ~a/lib
+include_dirs = ~:*~a/include~%"
+                          (dirname (dirname
+                                    (search-input-file
+                                     inputs 
"include/openblas_config.h")))))))))
+               #~((add-before 'build 'configure-blas
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (call-with-output-file "site.cfg"
+                        (lambda (port)
+                          (format port
+                                  "\
 [openblas]
 libraries = openblas
 library_dirs = ~a/lib
 include_dirs = ~:*~a/include~%"
                           (dirname (dirname
                                     (search-input-file
-                                     inputs "include/openblas_config.h"))))))))
+                                     inputs 
"include/openblas_config.h"))))))))))
           (add-before 'build 'fix-executable-paths
             (lambda* (#:key inputs #:allow-other-keys)
               ;; Make /gnu/store/...-bash-.../bin/sh the default shell,
@@ -7021,7 +7038,11 @@ (define-public python-numpy
            python-pytest-xdist
            python-typing-extensions
            gfortran))
-    (inputs (list bash openblas))
+    (inputs
+     (list bash
+           (if (target-64bit?)
+             openblas-ilp64
+             openblas)))
     (home-page "https://numpy.org";)
     (synopsis "Fundamental package for scientific computing with Python")
     (description "NumPy is the fundamental package for scientific computing

Attachment: signature.asc
Description: PGP signature

Reply via email to