156.4. fftw-3.3.11
Fast Fourier transform library
| Version | 3.3.11, release 1 |
| Shelf | sci-libs — Numerical and scientific-data libraries, and the unprefixed core Python science stack |
| Phase | 41_system (System), 136 of 1047 in build order |
| Licence | GPL-2.0-or-later |
| Homepage | https://www.fftw.org/ |
| Build time | 8.0 SBU |
| Installed size | 9.2 MiB in 54 files |
| Recipe | ports/core/sci-libs/fftw/kpkgbuild |
About
FFTW computes discrete Fourier transforms of any size and dimension. Its consumers in KDOS include pipewire, alsa-utils, ardour, gnuradio, hackrf, imagemagick, krita and octave. FFTW builds one floating-point precision per configure run, so build.sh configures, builds and installs three times into the same package: double precision (libfftw3), single (libfftw3f) and long double (libfftw3l), each with its threads and OpenMP companion libraries.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/sci-libs.txt:
Three precisions, three configure runs: double for octave and scipy, single for every SDR and audio path, long double for a few C2 solvers.
Sources
fftw-3.3.11.tar.gz(4.1 MiB)
sha2565630c24cdeb33b131612f7eb4b1a9934234754f9f388ff8617458d0be6f239a1
upstream: https://www.fftw.org/fftw-3.3.11.tar.gz
archive copy: sources-4/sci-libs--fftw-3.3.11.tar.gz
Dependencies
Depends on: gcc.
Required by (35): alsa-utils, ardour, aubio, blender, chromaprint, furnace, gnuradio, gr-iqbal, hackrf, imagemagick, inspectrum, js8call, krita, kwave, labplot, libdab, libosmo-dsp, libvips, liquid-dsp, lmms, mlt, movit, ngspice, octave, pipewire, powder-toy, qsstv, rawtherapee, rubberband, satdump, sdrangel, sdrpp, shotcut, strawberry, wsjtx.
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 fftw'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/sci-libs/fftw.
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/fftw
echo '5630c24cdeb33b131612f7eb4b1a9934234754f9f388ff8617458d0be6f239a1 fftw-3.3.11.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/fftw
SRC=$SRC_ROOT/fftw-3.3.11
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf fftw-3.3.11.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:
FORTRAN="--enable-fortran F77=gfortran"
COMMON="--prefix=/usr --libdir=/usr/lib --disable-static --enable-shared
--enable-threads --enable-openmp --enable-sse2 --enable-avx --enable-avx2
--enable-avx512 $FORTRAN"
./configure $COMMON
make
make DESTDIR=$PKG install
make clean
./configure $COMMON --enable-float
make
make DESTDIR=$PKG install
make clean
./configure --prefix=/usr --libdir=/usr/lib --disable-static --enable-shared \
--enable-threads --enable-openmp --enable-long-double $FORTRAN
make
make DESTDIR=$PKG install
The switches, and why each is set:
--enable-threads— Also build and install the threads library (libfftw3_threadsand its single and long-double siblings), which runs one transform across several threads with pthreads. Upstream builds none by default.--enable-openmp— The same again with OpenMP, as a separatelibfftw3_omp; the two libraries have different names, so both are installed and each consumer links the one it was written for.--enable-sse2,--enable-avx,--enable-avx2,--enable-avx512— Compile FFTW’s SIMD codelets for each of these instruction sets. FFTW checks at run time which of them the processor has and uses only those, so the library still runs on a processor with none of the newer ones; this is the run-time dispatch the tree prefers to a build for one processor (see Every port).--enable-fortran— Build the Fortran-callable wrapper routines into the libraries, which is upstream’s default;F77=gfortrannames the compiler configure reads the Fortran symbol naming from. With no Fortran compiler found, configure warns and builds the wrappers with default names instead.--enable-float— The second run: single precision,libfftw3f.--enable-long-double— The third run: long-double precision,libfftw3l.
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/fftw, 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 fftw-3.3.11-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/fftw, and runs the triggers its paths call for.
Contents
Installed programs: fftw-wisdom, fftw-wisdom-to-conf, fftwf-wisdom, fftwl-wisdom.
Installed libraries: libfftw3.so, libfftw3_omp.so, libfftw3_threads.so, libfftw3f.so, libfftw3f_omp.so, libfftw3f_threads.so, libfftw3l.so, libfftw3l_omp.so, libfftw3l_threads.so.
Installed directories: /usr/lib/cmake/fftw3, /usr/share/licenses/fftw.
Short descriptions
fftw-wisdom |
create wisdom (pre-optimized FFTs) |
fftw-wisdom-to-conf |
generate FFTW wisdom (pre-planned transforms) |
fftwf-wisdom |
create wisdom (pre-optimized FFTs) |
fftwl-wisdom |
create wisdom (pre-optimized FFTs) |
fftw3.pc |
fast Fourier transform library |
fftw3f.pc |
fast Fourier transform library |
fftw3l.pc |
fast Fourier transform library |
Notes
The third configure line is written out rather than built from $COMMON because it must leave out the four SIMD switches. FFTW’s SIMD code exists for single and double precision only, and configure stops with “SSE2 requires single or double precision” (and the same for each AVX switch) when one is given with --enable-long-double.
make clean between the runs is what keeps the second and third builds from linking objects compiled for the precision before. All three runs install into the same $PKG, and their files differ in name by the f and l suffixes, so none overwrites another’s library. The headers, fftw3.h and the Fortran include files, do not depend on the precision and are installed three times over.