Add documentation about how we link against BLAS/LAPACK

This commit is contained in:
Greg Lin 2022-08-17 18:07:33 -05:00
commit 979efa5b32

View file

@ -8,13 +8,29 @@ if [[ "${R_VERSION}" =~ ^3 ]]; then
pcre_lib='pcre-devel'
fi
# Create post-install script required for OpenBLAS
# Create post-install script required for OpenBLAS.
#
# On RHEL and SUSE, we link R against the internal shared BLAS to make the
# R binaries more portable and allow users to switch BLAS implementations without
# having to recompile R. We default to OpenBLAS, but users may prefer other implementations.
#
# Binary packages built against the shared BLAS are also more portable and may be used
# with the default R distributed by RHEL/SUSE, or other R installations using
# shared BLAS and configured with a different BLAS (such as Microsoft R Open with MKL).
# This is especially important for RSPM's binary packages.
#
# On Ubuntu/Debian, we link R against the external BLAS instead (--with-blas/--with-lapack),
# as those distributions use the alternatives system to swap BLAS libraries at runtime.
# The default R distributions on Ubuntu/Debian use the external BLAS, so we do as well
# for portability.
#
# https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Shared-BLAS
cat <<EOF >> /post-install.sh
mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep
ln -s /usr/lib64/libopenblasp.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so
EOF
# Create after-remove script to remove internal BLAS
# Create after-remove script to remove internal BLAS, which won't be cleaned up automatically.
cat <<EOF >> /after-remove.sh
if [ -d /opt/R/${R_VERSION} ]; then
rm -r /opt/R/${R_VERSION}