21cmfast / 21cmFAST

Official repository for 21cmFAST: a code for generating fast simulations of the cosmological 21cm signal
MIT License
56 stars 37 forks source link

Error in compilation with clang on M3 Mac [BUG] #398

Open elykovetz opened 1 month ago

elykovetz commented 1 month ago

Compiling 21cmFAST (v>=3.1.3), I get the following errors in the compilation stage:

  gcc -fno-strict-overflow -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /Users/elymini/opt/anaconda3/envs/21FC/include -fPIC -O2 -isystem /Users/elymini/opt/anaconda3/envs/21FC/include -I/Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src -I/Users/elymini/opt/anaconda3/envs/21FC/include/python3.12 -c build/temp.macosx-10.9-x86_64-cpython-312/py21cmfast.c_21cmfast.c -o build/temp.macosx-10.9-x86_64-cpython-312/build/temp.macosx-10.9-x86_64-cpython-312/py21cmfast.c_21cmfast.o -Ofast -w
  In file included from build/temp.macosx-10.9-x86_64-cpython-312/py21cmfast.c_21cmfast.c:572:
  In file included from /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/GenerateICs.c:39:
  /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/ps.c:87:25: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
  double *log10phi_MINI; *M_uv_z_MINI, *M_h_z_MINI;
                          ^
                         int
  /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/ps.c:87:39: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
  double *log10phi_MINI; *M_uv_z_MINI, *M_h_z_MINI;
                                        ^
                         int
  In file included from build/temp.macosx-10.9-x86_64-cpython-312/py21cmfast.c_21cmfast.c:572:
  In file included from /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/GenerateICs.c:44:
  /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/heating_helper_progs.c:1407:44: error: function definition is not allowed here
          double integrand (double z, void * params){
                                                    ^
  /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/heating_helper_progs.c:1420:17: error: use of undeclared identifier 'integrand'
    F.function = &integrand;
                  ^
  /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/heating_helper_progs.c:1527:69: error: function definition is not allowed here
          int find_nearest_point(double min, double max, int n, double value){
                                                                             ^
  /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/heating_helper_progs.c:1541:76: error: function definition is not allowed here
          int find_xyz_pos(int xpos, int ypos, int zpos, int len_yarr, int len_zarr){
                                                                                    ^
  /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/heating_helper_progs.c:1549:8: error: call to undeclared function 'find_nearest_point'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
          itk = find_nearest_point(Tk_min, Tk_max, nT, tk);
                ^
  /Users/elymini/Dropbox/21cmFirstCLASS/src/py21cmfast/src/heating_helper_progs.c:1553:9: error: call to undeclared function 'find_xyz_pos'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
          idec = find_xyz_pos(itk, its, itaugp, nT, ngp);
                 ^
  8 errors generated.
  error: command '/usr/bin/gcc' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

steven-murray commented 1 month ago

Thanks @elykovetz. A note that this was compiled under the following environment (correct me if I'm wrong):

I do not have access to macos or arm64, but I will get clang-15 to figure out the compilation issues at least. I will work in #321.

steven-murray commented 1 month ago

@elykovetz can you check out the branch on #321 and see if it compiles fine for you? Hopefully the changes there are simple to port over to first class.