Problem for compilation/installation of SHTns 3.4.4

Issue #40 resolved
Former user created an issue

Yesterday I tried to compile and install shtns 3.4.4 (from https://bitbucket.org/nschaeff/shtns/downloads/) for use with python 3.7.6 (on a custom anaconda environment), following the instructions on https://nschaeff.bitbucket.io/shtns/compil.html, but it did not finish. While the

./configure

command worked fine,

make 

gave an error message:

(proxconda3) proxauf@seismo1:~/shtns/shtns-3.4.4> ./configure --prefix=/scratch/seismo/proxauf/shtns_344 --enable-openmp --enable-python
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... -std=gnu99
checking for a sed that does not truncate output... /usr/bin/sed
checking whether gcc accepts -march=native... yes
checking whether gcc accepts -mtune=skylake... no
checking whether gcc accepts -qopt-zmm-usage=high... no
checking whether gcc accepts -ffast-math... yes
checking whether gcc accepts -std=gnu99... yes
checking whether gcc accepts -fopenmp-simd... no
checking whether gcc accepts -qopenmp-simd... no
checking whether gcc accepts -fno-tree-loop-distribute-patterns... yes
checking whether gcc accepts -mno-vzeroupper... yes
checking whether gcc -std=gnu99 accepts -march=native... yes
checking whether gcc -std=gnu99 accepts -mtune=skylake... no
checking whether gcc -std=gnu99 accepts -qopt-zmm-usage=high... no
checking whether gcc -std=gnu99 accepts -ffast-math... yes
checking whether gcc -std=gnu99 accepts -std=gnu99... yes
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for string.h... (cached) yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking complex.h usability... yes
checking complex.h presence... yes
checking for complex.h... yes
checking for cos in -lm... yes
checking for gcc -std=gnu99 option to support OpenMP... -fopenmp
checking for fftw_plan_many_dft in -lfftw3... yes
checking for fftw_init_threads in -lfftw3_omp... yes
checking for python with numpy package... python
  python include path = /scratch/seismo/proxauf/.conda/envs/proxconda3/include/python3.7m
  numpy include path = /scratch/seismo/proxauf/.conda/envs/proxconda3/lib/python3.7/site-packages/numpy/core/include
  verbose level = 1
checking for size_t... yes
checking for fftw_cost... yes
checking for inline... inline
checking whether time.h and sys/time.h may both be included... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking c_asm.h usability... no
checking c_asm.h presence... no
checking for c_asm.h... no
checking intrinsics.h usability... no
checking intrinsics.h presence... no
checking for intrinsics.h... no
checking mach/mach_time.h usability... no
checking mach/mach_time.h presence... no
checking for mach/mach_time.h... no
checking for hrtime_t... no
checking for gethrtime... no
checking for read_real_time... no
checking for time_base_to_time... no
checking for clock_gettime... yes
checking for mach_absolute_time... no
checking for _rtc intrinsic... no
checking for gfortran... gfortran
checking whether we are using the GNU Fortran compiler... yes
checking whether gfortran accepts -g... yes
prefix=/scratch/seismo/proxauf/shtns_344
configure: creating ./config.status
config.status: creating Makefile
config.status: creating setup.py
config.status: creating sht_config.h
config.status: sht_config.h is unchanged
(proxconda3) proxauf@seismo1:~/shtns/shtns-3.4.4> make
gcc -std=gnu99 -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -ffast-math -std=gnu99 -fopenmp -fpic -D_GNU_SOURCE  -c sht_init.c -o sht_init.o
gcc -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -O3 -ffast-math -std=gnu99 -fno-tree-loop-distribute-patterns -mno-vzeroupper -D_GNU_SOURCE -c sht_kernels_a.c -o sht_kernels_a.o
gcc -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -O3 -ffast-math -std=gnu99 -fno-tree-loop-distribute-patterns -mno-vzeroupper -D_GNU_SOURCE -c sht_kernels_s.c -o sht_kernels_s.o
gcc -std=gnu99 -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -ffast-math -std=gnu99 -fopenmp -fpic -D_GNU_SOURCE  -c sht_fly.c -o sht_fly.o
gcc -std=gnu99 -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -ffast-math -std=gnu99 -fopenmp -fpic -D_GNU_SOURCE  -c sht_omp.c -o sht_omp.o
CC="cc" python setup.py build
running build
running build_py
creating build/lib.linux-x86_64-3.7
copying shtns.py -> build/lib.linux-x86_64-3.7
running build_ext
building '_shtns' extension
creating build/temp.linux-x86_64-3.7
cc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/scratch/seismo/proxauf/.conda/envs/proxconda3/lib/python3.7/site-packages/numpy/core/include -I/scratch/seismo/proxauf/.conda/envs/proxconda3/include/python3.7m -c shtns_numpy_wrap.c -o build/temp.linux-x86_64-3.7/shtns_numpy_wrap.o -fopenmp
In file included from shtns_numpy_wrap.c:2679:0:
sht_private.h: In function \u2018SH_2scal_to_vect_reduce\u2019:
sht_private.h:260:2: error: \u2018for\u2019 loop initial declarations are only allowed in C99 mode
  for (int l=0; l<=llim-m; l++) {
  ^
sht_private.h:260:2: note: use option -std=c99 or -std=gnu99 to compile your code
sht_private.h: In function \u2018SH_2scal_to_vect\u2019:
sht_private.h:289:2: error: \u2018for\u2019 loop initial declarations are only allowed in C99 mode
  for (int l=0; l<=llim-m; l++) {
  ^
sht_private.h: In function \u2018zero_poles4_vect\u2019:
sht_private.h:710:0: warning: ignoring #pragma omp simd [-Wunknown-pragmas]
  #pragma omp simd
 ^
sht_private.h:711:2: error: \u2018for\u2019 loop initial declarations are only allowed in C99 mode
  for (long i=0; i<n*VSIZE2; i++) {
  ^
sht_private.h: In function \u2018zero_poles2_vect\u2019:
sht_private.h:720:0: warning: ignoring #pragma omp simd [-Wunknown-pragmas]
  #pragma omp simd
 ^
sht_private.h:721:2: error: \u2018for\u2019 loop initial declarations are only allowed in C99 mode
  for (long i=0; i<n*VSIZE2; i++) {
  ^
sht_private.h: In function \u2018zero_mem\u2019:
sht_private.h:728:0: warning: ignoring #pragma omp simd [-Wunknown-pragmas]
  #pragma omp simd
 ^
sht_private.h:729:2: error: \u2018for\u2019 loop initial declarations are only allowed in C99 mode
  for (long i=0; i<n*VSIZE2; i++) {
  ^
shtns_numpy_wrap.c: In function \u2018shtns_info___ct\u2019:
shtns_numpy_wrap.c:3060:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (i=0; i<self->nlat; i++)  ct[i] = self->ct[i];  // copy
              ^
shtns_numpy_wrap.c: In function \u2018shtns_info_idx\u2019:
shtns_numpy_wrap.c:3097:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if ( (m > l) || (m > self->mmax * self->mres) || (m % self->mres != 0) ) {
                      ^
In file included from shtns_numpy_wrap.c:2679:0:
shtns_numpy_wrap.c: At top level:
sht_private.h:252:13: warning: \u2018SH_2scal_to_vect_reduce\u2019 defined but not used [-Wunused-function]
 static void SH_2scal_to_vect_reduce(const double *mx, const double* l_2, int llim, int m, rnd* vw, v2d* Sl, v2d* Tl)
             ^
sht_private.h:280:13: warning: \u2018SH_2scal_to_vect\u2019 defined but not used [-Wunused-function]
 static void SH_2scal_to_vect(const double *mx, const double* l_2, int llim, int m, v2d* vw, v2d* Sl, v2d* Tl)
             ^
sht_private.h:329:13: warning: \u2018ishioka_to_SH\u2019 defined but not used [-Wunused-function]
 static void ishioka_to_SH(const double* xlm, const v2d* qq, const int llim_m, v2d* Ql)
             ^
sht_private.h:378:13: warning: \u2018ishioka_to_SH2\u2019 defined but not used [-Wunused-function]
 static void ishioka_to_SH2(const double* xlm, const v2d* vw, const int llim_m, v2d* VWl)
             ^
sht_private.h:426:13: warning: \u2018SH_to_ishioka\u2019 defined but not used [-Wunused-function]
 static void SH_to_ishioka(const double* xlm, const v2d* Ql, const int llim_m, v2d* ql)
             ^
sht_private.h:471:13: warning: \u2018SH2_to_ishioka\u2019 defined but not used [-Wunused-function]
 static void SH2_to_ishioka(const double* xlm, v2d* VWl, const int llim_m)
             ^
sht_private.h:518:13: warning: \u2018SH_vect_to_2scal\u2019 defined but not used [-Wunused-function]
 static void SH_vect_to_2scal(const double *mx, int llim, int m, cplx* Sl, cplx* Tl, cplx* VWl)
             ^
sht_private.h:570:13: warning: \u2018SH_vect_to_2scal_alt\u2019 defined but not used [-Wunused-function]
 static void SH_vect_to_2scal_alt(const double *mx, int llim, int m, const cplx* Sl, const cplx* Tl, cplx* VWl)
             ^
sht_private.h:655:13: warning: \u2018SHsph_to_2scal\u2019 defined but not used [-Wunused-function]
 static void SHsph_to_2scal(const double *mx, int llim, int m, cplx* Sl, cplx* VWl)
             ^
sht_private.h:682:13: warning: \u2018SHtor_to_2scal\u2019 defined but not used [-Wunused-function]
 static void SHtor_to_2scal(const double *mx, int llim, int m, cplx* Tl, cplx* VWl)
             ^
sht_private.h:709:13: warning: \u2018zero_poles4_vect\u2019 defined but not used [-Wunused-function]
 static void zero_poles4_vect(v2d* F0, long ofsm, long ofs1, long n) {
             ^
sht_private.h:719:13: warning: \u2018zero_poles2_vect\u2019 defined but not used [-Wunused-function]
 static void zero_poles2_vect(v2d* F0, long ofsm, long n) {
             ^
sht_private.h:727:13: warning: \u2018zero_mem\u2019 defined but not used [-Wunused-function]
 static void zero_mem(v2d* F0, long n) {
             ^
error: command 'cc' failed with exit status 1
Makefile:112: recipe for target '_shtns.so' failed
make: *** [_shtns.so] Error 1

I had some other issues with compilation/installation of other versions of SHTns for different python versions before as well. The whole story:

About a year ago I had tried to install shtns 3.1-r633 (don't recall with which python version), but the make or make install broke down so after some time I had given up there. Yesterday I also had tried installing shtns 3.4.2 to with python 3.7.6 via anaconda (https://anaconda.org/conda-forge/shtns). While the installation and the import shtns python command worked, a simple sh = shtns.sht(10) would give an error

Process finished with exit code 132 (interrupted by signal 4: SIGILL).

During the execution of a script from a colleague, it managed to go beyond the creation of the SHT object, but broke down probably somewhere during the call of sh.analys() with the error

Illegal instruction (core dumped)

I did not install shtns 3.4.2. via anaconda under my other custom anaconda environment (python 2.7.15), since anaconda wanted to update to python 3.9 (and I want to keep python 2 for backwards compatibility among my regular python 3 environment). Finally I managed to install and run shtns 2.6.5 from https://bitbucket.org/nschaeff/shtns/downloads/?tab=tags under the python 2.7.15 anaconda environment without issues.

To summarize, I could install the older version shtns 2.6.5 under python 2.7.15, but had issues installing various newer versions of shtns under newer versions of python. I might still try to install shtns 2.6.5 under python 3.7.6, but of course it would be great to be able to use the latest version (3.4.4.). Any ideas why the compilation gave the above error log? Thanks in advance for your help!

Official response

Comments (10)

  1. Bastian Proxauf

    I had submitted this issue, but did not have a Bitbucket account yet, so I created one for further communication.

  2. Nathanaël Schaeffer repo owner

    Hello, thanks for reporting.
    There are many things in your issue, but one quick fix for the compilation error would be to edit the setup.py file and change the cargs= line to cargs = "-std=gnu99"

    Please tell me if it works for you, in which case I will fix that in the next release.

    Regarding the illegal instruction from the anconda package, I’m not familiar enough with anconda, but if it includes a pre-compiled library, such thing can happen if your machine is different from the one it has been compiled on.

  3. Bastian Proxauf

    Thanks for your quick reply! Indeed there are a couple of different points in the issue (I intended to give some context about former installation attempts). Regarding your comment, while I saw gnu99 mentioned among the errors, I had thought it was already activated somehow when I looked at the first two lines (gcc ….). I assume you mean running only make after editing setup.py. I still get a similar error message / log for

    #cargs = "-fopenmp"
    cargs = "-std=gnu99"

    , see below:

    (proxconda3) proxauf@seismo1:~/shtns/shtns-3.4.4> make
    gcc -std=gnu99 -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -ffast-math -std=gnu99 -fopenmp -fpic -D_GNU_SOURCE -c sht_init.c -o sht_init.o
    gcc -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -O3 -ffast-math -std=gnu99 -fno-tree-loop-distribute-patterns -mno-vzeroupper -D_GNU_SOURCE -c sht_kernels_a.c -o sht_kernels_a.o
    gcc -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -O3 -ffast-math -std=gnu99 -fno-tree-loop-distribute-patterns -mno-vzeroupper -D_GNU_SOURCE -c sht_kernels_s.c -o sht_kernels_s.o
    gcc -std=gnu99 -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -ffast-math -std=gnu99 -fopenmp -fpic -D_GNU_SOURCE -c sht_fly.c -o sht_fly.o
    gcc -std=gnu99 -O2 -I/scratch/seismo/proxauf/shtns_344/include -L/scratch/seismo/proxauf/shtns_344/lib -march=native -ffast-math -std=gnu99 -fopenmp -fpic -D_GNU_SOURCE -c sht_omp.c -o sht_omp.o
    CC="cc" python setup.py build
    running build
    running build_py
    running build_ext
    building '_shtns' extension
    cc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/scratch/seismo/proxauf/.conda/envs/proxconda3/lib/python3.7/site-packages/numpy/core/include -I/scratch/seismo/proxauf/.conda/envs/proxconda3/include/python3.7m -c shtns_numpy_wrap.c -o build/temp.linux-x86_64-3.7/shtns_numpy_wrap.o -std=gnu99
    In file included from shtns_numpy_wrap.c:2679:0:
    sht_private.h: In function \u2018zero_poles4_vect\u2019:
    sht_private.h:710:0: warning: ignoring #pragma omp simd [-Wunknown-pragmas]
    #pragma omp simd
    ^
    sht_private.h: In function \u2018zero_poles2_vect\u2019:
    sht_private.h:720:0: warning: ignoring #pragma omp simd [-Wunknown-pragmas]
    #pragma omp simd
    ^
    sht_private.h: In function \u2018zero_mem\u2019:
    sht_private.h:728:0: warning: ignoring #pragma omp simd [-Wunknown-pragmas]
    #pragma omp simd
    ^
    shtns_numpy_wrap.c: In function \u2018shtns_info___ct\u2019:
    shtns_numpy_wrap.c:3060:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (i=0; i<self->nlat; i++) ct[i] = self->ct[i]; // copy
    ^
    shtns_numpy_wrap.c: In function \u2018shtns_info_idx\u2019:
    shtns_numpy_wrap.c:3097:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if ( (m > l) || (m > self->mmax * self->mres) || (m % self->mres != 0) ) {
    ^
    In file included from shtns_numpy_wrap.c:2679:0:
    shtns_numpy_wrap.c: At top level:
    sht_private.h:252:13: warning: \u2018SH_2scal_to_vect_reduce\u2019 defined but not used [-Wunused-function]
    static void SH_2scal_to_vect_reduce(const double mx, const double l_2, int llim, int m, rnd* vw, v2d* Sl, v2d* Tl)
    ^
    sht_private.h:280:13: warning: \u2018SH_2scal_to_vect\u2019 defined but not used [-Wunused-function]
    static void SH_2scal_to_vect(const double mx, const double l_2, int llim, int m, v2d* vw, v2d* Sl, v2d* Tl)
    ^
    sht_private.h:329:13: warning: \u2018ishioka_to_SH\u2019 defined but not used [-Wunused-function]
    static void ishioka_to_SH(const double* xlm, const v2d* qq, const int llim_m, v2d* Ql)
    ^
    sht_private.h:378:13: warning: \u2018ishioka_to_SH2\u2019 defined but not used [-Wunused-function]
    static void ishioka_to_SH2(const double* xlm, const v2d* vw, const int llim_m, v2d* VWl)
    ^
    sht_private.h:426:13: warning: \u2018SH_to_ishioka\u2019 defined but not used [-Wunused-function]
    static void SH_to_ishioka(const double* xlm, const v2d* Ql, const int llim_m, v2d* ql)
    ^
    sht_private.h:471:13: warning: \u2018SH2_to_ishioka\u2019 defined but not used [-Wunused-function]
    static void SH2_to_ishioka(const double* xlm, v2d* VWl, const int llim_m)
    ^
    sht_private.h:518:13: warning: \u2018SH_vect_to_2scal\u2019 defined but not used [-Wunused-function]
    static void SH_vect_to_2scal(const double mx, int llim, int m, cplx Sl, cplx* Tl, cplx* VWl)
    ^
    sht_private.h:570:13: warning: \u2018SH_vect_to_2scal_alt\u2019 defined but not used [-Wunused-function]
    static void SH_vect_to_2scal_alt(const double mx, int llim, int m, const cplx Sl, const cplx* Tl, cplx* VWl)
    ^
    sht_private.h:655:13: warning: \u2018SHsph_to_2scal\u2019 defined but not used [-Wunused-function]
    static void SHsph_to_2scal(const double mx, int llim, int m, cplx Sl, cplx* VWl)
    ^
    sht_private.h:682:13: warning: \u2018SHtor_to_2scal\u2019 defined but not used [-Wunused-function]
    static void SHtor_to_2scal(const double mx, int llim, int m, cplx Tl, cplx* VWl)
    ^
    sht_private.h:709:13: warning: \u2018zero_poles4_vect\u2019 defined but not used [-Wunused-function]
    static void zero_poles4_vect(v2d* F0, long ofsm, long ofs1, long n) {
    ^
    sht_private.h:719:13: warning: \u2018zero_poles2_vect\u2019 defined but not used [-Wunused-function]
    static void zero_poles2_vect(v2d* F0, long ofsm, long n) {
    ^
    sht_private.h:727:13: warning: \u2018zero_mem\u2019 defined but not used [-Wunused-function]
    static void zero_mem(v2d* F0, long n) {
    ^
    gcc -pthread -shared -B /scratch/seismo/proxauf/.conda/envs/proxconda3/compiler_compat -L/scratch/seismo/proxauf/.conda/envs/proxconda3/lib -Wl,-rpath=/scratch/seismo/proxauf/.conda/envs/proxconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.7/shtns_numpy_wrap.o sht_init.o sht_kernels_a.o sht_kernels_s.o sht_fly.o sht_omp.o -L/scratch/seismo/proxauf/shtns_344/lib -lfftw3_omp -lfftw3 -lm -o build/lib.linux-x86_64-3.7/_shtns.cpython-37m-x86_64-linux-gnu.so
    /scratch/seismo/proxauf/.conda/envs/proxconda3/compiler_compat/ld: sht_kernels_s.o: relocation R_X86_64_PC32 against symbol `memset@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
    /scratch/seismo/proxauf/.conda/envs/proxconda3/compiler_compat/ld: final link failed: bad value
    collect2: error: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1
    Makefile:112: recipe for target '_shtns.so' failed
    make: *** [_shtns.so] Error 1

  4. Nathanaël Schaeffer repo owner

    ok, another fix: edit the Makefile and add -fpic at the end of the line starting with shtcc=

  5. Nathanaël Schaeffer repo owner

    The same issue has been raised by a collaborator last week. I thought it was specific to a machine, because I have no such issue on my system…
    I will fix it properly in the next release. Can you tell me what gcc --version reports ?

  6. Bastian Proxauf

    (proxconda3) proxauf@seismo1:~/shtns/shtns-3.4.4> gcc --version
    gcc (SUSE Linux) 4.8.5
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  7. Log in to comment