diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2020-03-31 14:53:02 -0400 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2020-04-17 16:24:25 -0500 |
commit | d83e9c95738df2e9f912c239201f50e53e40810b (patch) | |
tree | abbdc77aa8b581bf344b9f558ea6d36cefdeea6a /pkgs/build-support | |
parent | 7841b4290f72af6041163cc1bdcab6a710b0d4a5 (diff) | |
download | nixlib-d83e9c95738df2e9f912c239201f50e53e40810b.tar nixlib-d83e9c95738df2e9f912c239201f50e53e40810b.tar.gz nixlib-d83e9c95738df2e9f912c239201f50e53e40810b.tar.bz2 nixlib-d83e9c95738df2e9f912c239201f50e53e40810b.tar.lz nixlib-d83e9c95738df2e9f912c239201f50e53e40810b.tar.xz nixlib-d83e9c95738df2e9f912c239201f50e53e40810b.tar.zst nixlib-d83e9c95738df2e9f912c239201f50e53e40810b.zip |
setup-hooks/audit-blas.sh: init
Add a simple hook that makes sure blas and lapack are linked to the right place.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/setup-hooks/audit-blas.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/audit-blas.sh b/pkgs/build-support/setup-hooks/audit-blas.sh new file mode 100644 index 000000000000..6a40073fb234 --- /dev/null +++ b/pkgs/build-support/setup-hooks/audit-blas.sh @@ -0,0 +1,37 @@ +# Ensure that we are always linking against “libblas.so.3” and +# “liblapack.so.3”. + +auditBlas() { + local dir="$prefix" + [ -e "$dir" ] || return 0 + + local i + while IFS= read -r -d $'\0' i; do + if ! isELF "$i"; then continue; fi + + if $OBJDUMP -p "$i" | grep 'NEEDED' | awk '{ print $2; }' | grep -q '\(libmkl_rt.so\|libopenblas.so.0\)'; then + echo "$i refers to a specific implementation of BLAS or LAPACK." + echo "This prevents users from switching BLAS/LAPACK implementations." + echo "Add \`blas' or \`lapack' to buildInputs instead of \`mkl' or \`openblas'." + exit 1 + fi + + (IFS=: + for dir in "$(patchelf --print-rpath "$i")"; do + if [ -f "$dir/libblas.so.3" ] || [ -f "$dir/libblas.so" ]; then + if [ "$dir" != "@blas@/lib" ]; then + echo "$dir is not allowed to contain a library named libblas.so.3" + exit 1 + fi + fi + if [ -f "$dir/liblapack.so.3" ] || [ -f "$dir/liblapack.so" ]; then + if [ "$dir" != "@lapack@/lib" ]; then + echo "$dir is not allowed to contain a library named liblapack.so.3" + exit 1 + fi + fi + done) + done < <(find "$dir" -type f -print0) +} + +fixupOutputHooks+=(auditBlas) |