User:Aisha/eselect library
eselect library is an eselect module for managing runtime loading of libraries by manipulating the ld.so runtime library search paths.
It is primarily used by the BLAS/LAPACK/64 runtime switch for switching the provider libraries during runtime, by managing the libblas.so, libblas64.so, libcblas.so, libcblas64.so ...
runtime load paths using the ld.so.conf search file.
List managed libraries
To view all libraries that have runtime alternatives available using eselect library:
root #
eselect library managed
Managed libraries: [1] blas [2] blas64 [3] lapack [4] lapack64
List providers
To list library providers for the BLAS library, libblas.so
:
root #
eselect library list blas
Available blas library (lib) candidates: (none found) Available blas library (lib64) candidates: [1] blis [2] openblas * [3] reference
Adding provider
Suppose that the package sci-libs/openblas has been installed in the system but the library installed is not an optimized one.
The system administrator can compile a local version of the library in a folder /var/library/package/openblas, which now contains the created library libblas.so
.
To allow the usage of this library during runtime by add it to eselect library.
root #
eselect library add blas lib64 /var/library/package/openblas admin-provided
root #
eselect library list blas
Available blas library (lib) candidates: (none found) Available blas library (lib64) candidates: [1] blis [2] openblas * [3] reference [4] admin-provided
This adds and registers the library provider with eselect library but does not activate it for use.
Setting providers
To set a provider for libblas.so
:
root #
eselect library set blas admin-provided
root #
eselect library list blas
Available blas library (lib) candidates: (none found) Available blas library (lib64) candidates: [1] blis [2] openblas [3] reference [4] admin-provided *
Unset providers
It is also trivial to restore the system back to its original settings:
root #
eselect library unset blas
root #
eselect library list blas
Available blas library (lib) candidates: (none found) Available blas library (lib64) candidates: [1] blis [2] openblas [3] reference [4] admin-provided
Now the system will be reverted back to using the libblas.so
present in /usr/lib64
Build-time vs Runtime
It is important to know that building of all software will be done by linking and resolving symbols from the libblas.so
present in the default /usr/${libdir}.
It is only during runtime that the eselected provider will be used.
Some points of consideration to keep in mind:
- Make sure that the library is present in paths search by the linker during build time.
- Try to keep API compatibility of provider libraries with system-wide libraries.
- If using chain-loading, make sure no
dlopen/dlsym
is going to take place on providers.