GalacticDynamics-Oxford / Agama

Action-based galaxy modeling framework
Other
72 stars 35 forks source link

Compilation error of test_fortran on Apple Sequoia 15.0 Apple M3 Pro #47

Open mromerog opened 21 hours ago

mromerog commented 21 hours ago

Hi Eugene I successfully install Agama in the new Mac, but now I have issues when compiling fortran: _gfortran -o "exe/test_fortran.exe" tests/test_fortran.f agama.so -fPIC -Wall -O2 -I/opt/anaconda3/include -Xpreprocessor -fopenmp -std=c++11 -arch arm64 -Wno-missing-field-initializers -Wno-cast-function-type -Isrc /opt/anaconda3/lib/libiomp5.dylib -Wl,-rpath,/opt/anaconda3/lib /opt/anaconda3/lib/libpython3.12.dylib gfortran: error: this compiler does not support arm64 make: [exe/testfortran.exe] Error 1 (ignored)

Any idea? gfortran works well in this laptop.

mromerog commented 19 hours ago

If I remove -arch arm64 from the compilation line, then I obtain the following lines: _gfortran -o "exe/test_fortran.exe" tests/test_fortran.f agama.so -fPIC -Wall -O2 -I/opt/anaconda3/include -Xpreprocessor -fopenmp -std=c++11 -Wno-missing-field-initializers -Wno-cast-function-type -Isrc /opt/anaconda3/lib/libiomp5.dylib -Wl,-rpath,/opt/anaconda3/lib /opt/anaconda3/lib/libpython3.12.dylib f951: Warning: command line option ‘-Wno-missing-field-initializers’ is valid for C/C++/ObjC/ObjC++ but not for Fortran f951: Warning: command line option ‘-Wno-cast-function-type’ is valid for C/C++/ObjC/ObjC++ but not for Fortran f951: Warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for Fortran ld: warning: ignoring file agama.so, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/anaconda3/lib/libiomp5.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/anaconda3/lib/libpython3.12.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: can't re-map file, errno=22 file '/usr/local/gfortran/lib/libgcc_ext.10.5.dylib' for architecture x86_64 collect2: error: ld returned 1 exit status make: [exe/testfortran.exe] Error 1 (ignored)

eugvas commented 19 hours ago

hi Merce, you might be the only person who still needs the fortran interface:) the error is self-explanatory: for some reason, your gfortran does not support compilation for the arm64 architecture. (Weirdly enough, on my machine it is the opposite – gfortran can only compile arm64, not x86_64). Agama itself can be compiled for either arm64 and x86_64 architectures, but not both simultaneously (at least for now). If you build it using the setup.py script, the choice depends on the architecture of your Python interpreter (and in fact, I have both variants on my M2 Mac). You could change the architecture for the entire library by editing CXXFLAGS in Makefile.local, then running make, but this alone will likely fail, because it uses third-party libraries (at least GSL), which will also need to be recompiled for x86_64. And you will need to disable the Python interface by removing -DHAVE_PYTHON from COMPILE_FLAGS. Or perhaps install a version of gcc/gfortran that supports arm64?

mromerog commented 18 hours ago

hahahah fortran is not dead yet! I'll try to install a gfortran version that supports arm64. Keep you posted! Thanks for the quick reply!