GSL cannot find CBLAS symbols

  • Open
  • quality assurance status badge
Details
2 participants
  • Artyom Bologov
  • Richard Sent
Owner
unassigned
Submitted by
Artyom Bologov
Severity
normal

Debbugs page

Artyom Bologov wrote 1 years ago
(address . bug-guix@gnu.org)
87edcgqtfw.fsf@aartaka.me
Hi y'all,

I'm working on Guile bindings for GNU Scientific Library (GSL), and I
encountered a bug: GSL cannot find CBLAS functions when invoked directly
from Guile.

I'm attaching a script, gslcblas.scm, ran (given that you replace the
path to libgsl.so in it with a machine-specific one) with

guile gslcblas.scm
(use-modules (system foreign) (system foreign-library)) (define libgsl (load-foreign-library "/gnu/store/zfxs8xbh68nb8smvsdf9i6aj6hbzgix4-profile/lib/libgsl.so")) (define gsl-vector-alloc (foreign-library-function libgsl "gsl_vector_alloc" #:return-type '* #:arg-types (list size_t))) (define gsl-vector-set (foreign-library-function libgsl "gsl_vector_set" #:return-type void #:arg-types (list '* size_t double))) (define gsl-vector-get (foreign-library-function libgsl "gsl_vector_get" #:return-type double #:arg-types (list '* size_t))) (define gsl-blas-dscal (foreign-library-function libgsl "gsl_blas_dscal" #:return-type void #:arg-types (list double '*))) (let* ((n 3) (x (gsl-vector-alloc n))) (for-each (lambda (i) (gsl-vector-set x i i)) (iota n)) (gsl-blas-dscal 10 x))
It errors out with

guile: symbol lookup error: [...]/libgsl.so: undefined symbol: cblas_dscal

Loading libgslcblas.so into the Scheme image doesn't help, it errors out
the same. That's why I'm thinking it's not a Guile Scheme problem, but a
library one: GSL C code breaks with no knowledge of CBLAS.

The suggested fix is to link libgsl.so against libgslcblas.so (or any
other CBLAS library?), so that the functions from the latter are
available in the former. that seems to be what Arch package does
admit this is a strange circular behavior, it makes sense too: CBLAS is
an implementation detail for BLAS support in GSL, and should be linked
as such.

I'm not knowledgeable enough in the ways of building GSL (or any complex
C software really), so I cannot come up with a proper patch. Hopefully
that's enough info for someone to act on.

Acknowledgements: Huge thanks to Arun Isaac who helped me debug this
problem!

Thanks,
--
Artyom Bologov.
Artyom Bologov wrote 1 years ago
(address . 69737@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
87le6ndr92.fsf@aartaka.me
CC-ing Arun Isaac to keep him in the loop.
--
Artyom.
Richard Sent wrote 1 years ago
(name . Artyom Bologov)(address . mail@aartaka.me)(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 69737@debbugs.gnu.org)
87bk7j0yzd.fsf@freakingpenguin.com
Hi Artyom,

I found your code ran when I added

Toggle snippet (6 lines)
(define libcblas
;; Your store path may differ
(load-foreign-library "/gnu/store/dzx94b3xv4h1ik1bfrbxaw7n84y9r8zz-gsl-2.7.1/lib/libgslcblas.so"
#:global? #t))

before (define libgsl ...)

Toggle quote (3 lines)
> If global? is true, symbols defined by the loaded library will be
> available when other modules need to resolve symbols; the default is
> #f, which keeps symbols local.

I have not tested if the calculation is correct.

--
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.
Artyom Bologov wrote 12 months ago
(name . Richard Sent)(address . richard@freakingpenguin.com)(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 69737@debbugs.gnu.org)(name . Artyom Bologov)(address . mail@aartaka.me)
87y1alalcz.fsf@aartaka.me
Hi Richard!

Thanks a lot, that solved it! I guess no actionable things for this
issue anymore. Sorry for the false lead on GSL 😅

--
Artyom.
?
Your comment

Commenting via the web interface is currently disabled.

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

To respond to this issue using the mumi CLI, first switch to it
mumi current 69737
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
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help