156.3. gsl-2.8
GNU Scientific Library — numerical routines outside linear algebra
| Version | 2.8, release 1 |
| Shelf | sci-libs — Numerical and scientific-data libraries, and the unprefixed core Python science stack |
| Phase | 41_system (System), 90 of 1047 in build order |
| Licence | GPL-3.0-or-later |
| Homepage | https://www.gnu.org/software/gsl/ |
| Build time | 2.2 SBU |
| Installed size | 7.4 MiB in 284 files |
| Recipe | ports/core/sci-libs/gsl/kpkgbuild |
About
The GNU Scientific Library is a C library of numerical routines outside dense linear algebra: special functions, random number distributions, integration, interpolation, root finding, minimisation, FFTs and statistics. gnuradio, inkscape, krita, labplot, qgis and bcftools link it. Its vector and matrix operations call CBLAS, and in KDOS that CBLAS is openblas.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/sci-libs.txt:
GSL's own reference CBLAS is correct and ~10x slower, so --with-external-cblas is what stops every consumer silently getting the slow one.
Sources
gsl-2.8.tar.gz(8.6 MiB)
sha2566a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190
upstream: https://ftp.gnu.org/gnu/gsl/gsl-2.8.tar.gz
archive copy: sources-4/sci-libs--gsl-2.8.tar.gz
Dependencies
Depends on: openblas.
Required by (11): bcftools, calligra, gnuastro, gnuradio, inkscape, krita, labplot, lib2geom, nco, qgis, step.
Patches
build.sh applies these; kpkg applies nothing by itself.
openblas-default-cblas.patch— Changes the CBLAS library a consumer is told to link from GSL’s own-lgslcblasto-lopenblas, in both places GSL hands it out: theGSL_CBLAS_LIBvariable ingsl.pc.in, whichpkg-config --libs gslexpands, and the default ofGSL_CBLAS_LIBingsl-config --libs, together with that script’s help text. A program can still choose another CBLAS by settingGSL_CBLAS_LIBwhen it runsgsl-config.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install gsl'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/sci-libs/gsl.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/sci-libs/gsl
echo '6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190 gsl-2.8.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/gsl
SRC=$SRC_ROOT/gsl-2.8
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf gsl-2.8.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/openblas-default-cblas.patch"
./configure \
--prefix=/usr \
--libdir=/usr/lib \
--disable-static
make
make DESTDIR=$PKG install
find "$PKG" -name '*.h' | while read -r h; do
iconv -f UTF-8 -t UTF-8 "$h" >/dev/null 2>&1 && continue
iconv -f ISO-8859-1 -t UTF-8 "$h" > "$h.utf8" && mv -f "$h.utf8" "$h"
done
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/gsl, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf gsl-2.8-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/gsl, and runs the triggers its paths call for.
Contents
Installed programs: gsl-config, gsl-histogram, gsl-randist.
Installed libraries: libgsl.so, libgslcblas.so.
Installed directories: /usr/include/gsl, /usr/share/licenses/gsl.
Short descriptions
gsl-config |
script to get version number and compiler flags of the installed GSL library |
gsl-histogram |
compute histogram of data on stdin |
gsl-randist |
generate random samples from various distributions |
gsl.pc |
GNU Scientific Library |
Notes
libgsl itself leaves the cblas_* symbols undefined, so every program that links it must link a CBLAS as well, and takes the name of that library from pkg-config or gsl-config.
GSL still builds and installs libgslcblas.so, its own reference CBLAS; the patch only changes what consumers are pointed at. A program that names -lgslcblas itself links the reference routines, not OpenBLAS.
The loop after the install re-encodes each installed header that is not valid UTF-8 from ISO-8859-1 to UTF-8, and leaves every valid one untouched: a consumer that reads a header as text fails on upstream’s. gsl_complex_math.h, whose copyright line spells a name in Latin-1, is one the loop rewrites.