sagemath/sage

openblas spkg-configure.m4: Fix the check for lapack/cblas functions

mkoeppe opened this issue · 17 comments

This line (introduced in #29071):

        AC_FC_FREEFORM([AC_FC_FUNC([dgeqrf])])

is not executed at all because AC_FC_FREEFORM is AC_DEFUN_ONCE and is called already in gfortran/spkg-configure.m4

As a result:

Checking whether SageMath should install SPKG openblas...
checking BLAS library... openblas
checking whether any of gfortran is installed or will be installed as SPKG... no
checking for openblas >= 0.2.20... yes
checking for cblas_dgemm... yes
checking for ... no
checking for lapack... no
configure: no suitable system package found for SPKG openblas

In this ticket, we fix the check by avoiding AC_FC_FUNC altogether, which is not suitable to be used in a configure that must work if no Fortran compiler is available.

(Factored out from #29104.)

CC: @dimpase

Component: build: configure

Author: Matthias Koeppe

Branch/Commit: 71ac6a5

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/29361

Author: Matthias Koeppe

Commit: 71ac6a5

New commits:

bb89447build/pkgs/openblas/spkg-configure.m4: Use OPENBLAS_{LIBS,CFLAGS} while checking for cblas/lapack functions
71ac6a5build/pkgs/openblas/spkg-configure.m4: Do not use AC_FC_FUNC.
comment:3

good, it works.

Reviewer: Dima Pasechnik

comment:4

Thanks.

comment:5

Again, with Fedora there is a subsequent problem installing cblas.pc, but it is fixed by #29082

comment:6

This does not seem to work for me with Homebrew. I still get

Checking whether SageMath should install SPKG openblas...
checking BLAS library... openblas
checking whether any of gfortran is installed or will be installed as SPKG... no
checking for OPENBLAS... yes
checking for library containing cblas_dgemm... -lopenblas
checking for library containing ... no
checking for LAPACK... no
configure: no suitable system package found for SPKG openblas

after a distclean and running

./configure \
     LDFLAGS="-L/usr/local/opt/readline/lib -L/usr/local/opt/openblas/lib" \
     CPPFLAGS="-I/usr/local/opt/readline/include -I/usr/local/opt/openblas/include" \
     PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/openblas/lib/pkgconfig"
comment:7

Did you run bootstrap?

comment:8

Ok, running bootstrap solves this. My bad.

I do get an error running bootstrap though, but probably not from this ticket.

build/pkgs/iconv/spkg-configure.m4:2: warning: macro 'AM_ICONV' not found in library
...
configure:18231: error: possibly undefined macro: AM_ICONV
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
comment:9

Need to add to ACLOCAL_PATH.
See .homebrew-build-env in #29104

comment:10

I thought I had done that, but must have messed it up. All good now. Thank you.

comment:11

I still see problems with finding openblas on fedora-32-standard at https://github.com/mkoeppe/sage/runs/524868616 (which has #29082): Does not find openblas, installs its own openblas, then openblas-dependent packages such as iml, gsl fail to compile. This is in contrast to fedora-32-minimal (which has no system openblas) - where iml builds successfully

comment:12

it cannot find openblas, as Fedora does not install openblas.pc

it is out of scope of this ticket.

It is possible to get around this by either shipping or generating one, though.

comment:13

OK I have created #29393 for the Fedora issue.