Note for packages linking against GSL [ACTION NEEDED]

Richard W.M. Jones rjones at
Sun Feb 22 22:09:20 UTC 2015

On Sat, Feb 21, 2015 at 03:50:16PM -0800, Susi Lehtola wrote:
> Hi,
> the GNU Scientific Library (GSL) contains some linear algebra
> routines that need a CBLAS library to work.
> GSL contains a compatibility CBLAS library (gslcblas) that provides
> a version of these routines. In 2010, we started to link libgsl by a
> Fedora patch to libgslcblas, so linking to libgsl could be done just
> by -lgsl instead of -lgsl -lgslcblas.
> However, the GSL CBLAS library is far from optimal, and you can
> typically get an order of magnitude more performance by using an
> optimized library. In 2011, the default link in libgsl was changed
> to be against ATLAS.
> This default, Fedora specific link was removed in Fedora 22 in
> December, because
> a) there are more CBLAS libraries available than just GSL CBLAS or
>    ATLAS; e.g. OpenBLAS, Intel MKL or AMD ACML being good examples
> b) upstream clearly intended the choice of the library to be made upon
>    link time
> c) a project linking multiple libraries must use the same BLAS/CBLAS
>    library in all of its components
> Because libgsl is no longer linked to a CBLAS library, packages
> linking to GSL need to also link to a CBLAS library, ATLAS probably
> being the best candidate since OpenBLAS is not available for all
> Fedora architectures. The following trick should be enough to handle
> the link
> %if 0%{?fedora} > 20 || 0%{?rhel} > 6
> export LIBS="-lgsl -L%{_libdir}/atlas -lsatlas"
> %else
> export LIBS="-lgsl L%{_libdir}/atlas -lcblas -latlas"
> %endif

I'm not really sure I understood all of that, but anyway.

ocaml-gsl appears to use the output of `gsl-config --libs` which in
effect means that it's using on x86-64: '-lgsl -lgslcblas -lm'

It's possible to override this by exporting GSL_CBLAS_LIB to a value
like the one above.

However my questions is why doesn't `gsl-config --libs` appear to
produce the optimal link command?

Also it looks like to use atlas, spec files would need an additional:

  BuildRequires: atlas-devel

Proposed patch for ocaml-gsl.spec attached.


Richard Jones, Virtualization Group, Red Hat
Read my programming and virtualization blog:
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
-------------- next part --------------
>From 3aaf673d7a9b106a2b79dacbbf7ae41f7fbb129c Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones at>
Date: Sun, 22 Feb 2015 22:08:36 +0000
Subject: [PATCH] Link against ATLAS for improved performance.

 ocaml-gsl.spec | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ocaml-gsl.spec b/ocaml-gsl.spec
index ee3a0ef..cedfa42 100644
--- a/ocaml-gsl.spec
+++ b/ocaml-gsl.spec
@@ -2,7 +2,7 @@
 Name:           ocaml-gsl
 Version:        1.18.2
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Interface to GSL (GNU scientific library) for OCaml
 License:        GPLv2
@@ -17,6 +17,7 @@ BuildRequires:  ocaml-ocamldoc
 BuildRequires:  ocaml-camlp4-devel
 BuildRequires:  gsl-devel >= 1.9
 BuildRequires:  /usr/bin/awk
+BuildRequires:  atlas-devel
@@ -40,6 +41,7 @@ developing applications that use %{name}.
+export GSL_CBLAS_LIB="-lgsl -L%{_libdir}/atlas -lsatlas"
@@ -74,9 +76,10 @@ make install
-* Sun Feb 22 2015 Richard W.M. Jones <rjones at> - 1.18.2-1
+* Sun Feb 22 2015 Richard W.M. Jones <rjones at> - 1.18.2-2
 - New upstream version 1.18.2.
 - Remove the patch, now upstream.
+- Link against ATLAS for improved performance.
 * Tue Feb 17 2015 Richard W.M. Jones <rjones at> - 1.18.1-1
 - New upstream version 1.18.1.

More information about the devel mailing list