ahay / src

Main Madagascar source
Other
267 stars 174 forks source link

[BUG] configure fails to find FFTW, SuiteSparse, OpenMP, BLAS, LAPACK, OpenGL #302

Open yurivict opened 11 months ago

yurivict commented 11 months ago

:bug: Bug report

Description of the bug

checking for Python ... /usr/ports/misc/madagascar/work/.bin/python
checking Python version ... 3.9.18
checking for RSFROOT ... /usr/local
checking for SCons ... /usr/local/bin/scons
checking SCons version ... v4.4.0.fc8d0ec215ee6cba8bc158ad40c099be0b598297
Running RSFROOT=/usr/local /usr/local/bin/scons  config ...
------------------------
scons: Reading SConscript files ...
checking platform ... (cached) posix [unknown]
checking for C compiler ... (cached) cc
checking if cc works ... yes
checking for ar ... (cached) ar
checking for rpc ... ['m']
checking complex support ... yes
checking for X11 headers ... /usr/X11R6/include
checking for X11 libraries ... /usr/X11R6/lib
checking for OpenGL ... no
checking for sfpen ... (cached) xtpen
checking for ppm ... no
checking for tiff ... no

  sfbyte2tif, sftif2byte, and tiffpen will not be built.
checking for GD (PNG) ... no

  gdpen will not be built.
checking for plplot ... no
checking for ffmpeg ... no
checking for cairo (PNG) ... no
checking for jpeg ... no

  sfbyte2jpg, sfjpg2byte, and jpegpen will not be built.
checking for BLAS ... no
checking for LAPACK ... no
checking for SWIG ... (cached) /usr/local/bin/swig
checking for numpy ... (cached) yes
checking API options ... (cached) []
checking for C++ compiler ... (cached) CC
checking if CC works ... yes
checking for MPICC ... (cached) /usr/local/bin/mpicc
checking if /usr/local/bin/mpicc works ... yes
checking for MPICXX ... (cached) /usr/local/bin/mpicxx
checking if /usr/local/bin/mpicxx works ... yes
checking for MPIRUN ... (cached) /usr/local/bin/mpirun
checking for Posix threads ... no
checking for OpenMP ... no
checking for CUDA ... (cached) no
checking for FFTW ... no
checking for SuiteSparse ... no
scons: done reading SConscript files.
usage: scons [OPTIONS] [VARIABLES] [TARGETS]

SCons Error: no such option: --build
------------------------
Done with configuration.

All these packages are installed and are easily discoverable.

Include and lib paths are set correctly in CFLAGS, CXXFLAGS, LDFLAGS, which is a convention.

I see that you wrote 2600+ lines in framework/configure.py to detect some of these packages and this code fails in SCons. SCons is an anachronism, I recommend that you should use cmake. With cmake finding all these packages would have been done correctly with fewer than 100 lines of cmake code.

To Reproduce Run configure.

Revision: d729968 FreeBSD 13.2

sfomel commented 11 months ago

Please check the file config.log to find specific errors that prevent the configure script from detecting the optional extra packages.

yurivict commented 11 months ago

for example:

scons: Configure: checking for FFTW ...
.sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.c <-
  |
  |    #include <fftw3.h>
  |    int main(int argc,char* argv[]) {
  |    fftwf_complex *in;
  |    fftwf_plan p;
  |    in = (fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex) * 10);
  |    p = fftwf_plan_dft_1d(10, in, in, FFTW_FORWARD, FFTW_ESTIMATE);
  |    fftwf_destroy_plan(p);
  |    fftwf_free(in);
  |    return 0;
  |    }
  |
cc -o .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.o -c -O2 -DNO_BLAS -I/usr/include/cblas .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.c
.sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.c:2:14: fatal error: 'fftw3.h' file not found
    #include <fftw3.h>
             ^~~~~~~~~
1 error generated.

It fails to find fftw3.h despite its path (-isystem /usr/local/include) being in the CXXFLAGS and CFLAGS environment variables.

sfomel commented 11 months ago

SCons does not inherit the environment. You can specify parameters to configure as follows:

./configure CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS

Run scons --help to see other options.

yurivict commented 11 months ago

Configure still fails to find FFTW with ./configure CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS:

scons: Configure: checking for FFTW ...
.sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.c <-
  |
  |    #include <fftw3.h>
  |    int main(int argc,char* argv[]) {
  |    fftwf_complex *in;
  |    fftwf_plan p;
  |    in = (fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex) * 10);
  |    p = fftwf_plan_dft_1d(10, in, in, FFTW_FORWARD, FFTW_ESTIMATE);
  |    fftwf_destroy_plan(p);
  |    fftwf_free(in);
  |    return 0;
  |    }
  |
cc -o .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.o -c -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DNO_BLAS -I/usr/include/cblas .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.c
cc -o .sconf_temp/sfconftest_0c46a2a96952db7f43919c6fc31987be_0_25260cce507de1f1d4e4fc265dc8e16f .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.o -lm
ld: error: undefined symbol: fftwf_malloc
>>> referenced by conftest_0c46a2a96952db7f43919c6fc31987be_0.c
>>>               .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.o:(main)

ld: error: undefined symbol: fftwf_plan_dft_1d
>>> referenced by conftest_0c46a2a96952db7f43919c6fc31987be_0.c
>>>               .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.o:(main)

ld: error: undefined symbol: fftwf_destroy_plan
>>> referenced by conftest_0c46a2a96952db7f43919c6fc31987be_0.c
>>>               .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.o:(main)

ld: error: undefined symbol: fftwf_free
>>> referenced by conftest_0c46a2a96952db7f43919c6fc31987be_0.c
>>>               .sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_0.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
.sconf_temp/conftest_0c46a2a96952db7f43919c6fc31987be_1.c <-

pkg-config does return the correct link flags:

 pkg-config --libs fftw3
-L/usr/local/lib -lfftw3

but they don't appear in the above link line which leads to the missing symbols problem. The required argument -lfftw3 does not appear in the link line.

yurivict commented 11 months ago

It's not necessary to compile a snippet of code using FFTW. pkg-config returns proper flags, and the cmake script returns correct flags as well.