Closed ljlamarche closed 2 years ago
This is a good question, I've not explored many different versions of gfortran. Which compiler flags aren't recognized?
FYI I am using GNU Fortran (MacPorts gcc12 12.2.0_0+stdlib_flag) 12.2.0
I believe this is the pertinent part of the error produced from python -m build .
:
FAILED: lib_fortranobject.a.p/_tmp_build-env-7e74_pev_lib_python3.9_site-packages_numpy_f2py_src_fortranobject.c.o
cc -Ilib_fortranobject.a.p -I. -I../.. -I/tmp/build-env-7e74_pev/lib/python3.9/site-packages/numpy/core/include -I/tmp/build-env-7e74_pev/lib/python3.9/site-packages/numpy/f2py/src -I/opt/python/include/python3.9 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -Wno-unused-but-set-variable -Wno-unused-function -Wno-conversion -Wno-misleading-indentation -Wno-incompatible-pointer-types -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION -MD -MQ lib_fortranobject.a.p/_tmp_build-env-7e74_pev_lib_python3.9_site-packages_numpy_f2py_src_fortranobject.c.o -MF lib_fortranobject.a.p/_tmp_build-env-7e74_pev_lib_python3.9_site-packages_numpy_f2py_src_fortranobject.c.o.d -o lib_fortranobject.a.p/_tmp_build-env-7e74_pev_lib_python3.9_site-packages_numpy_f2py_src_fortranobject.c.o -c /tmp/build-env-7e74_pev/lib/python3.9/site-packages/numpy/f2py/src/fortranobject.c
/tmp/build-env-7e74_pev/lib/python3.9/site-packages/numpy/f2py/src/fortranobject.c: In function ‘find_first_negative_dimension’:
/tmp/build-env-7e74_pev/lib/python3.9/site-packages/numpy/f2py/src/fortranobject.c:707:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < rank; ++i) {
^
/tmp/build-env-7e74_pev/lib/python3.9/site-packages/numpy/f2py/src/fortranobject.c:707:5: note: use option -std=c99 or -std=gnu99 to compile your code
/tmp/build-env-7e74_pev/lib/python3.9/site-packages/numpy/f2py/src/fortranobject.c: At top level:
cc1: warning: unrecognized command line option "-Wno-incompatible-pointer-types" [enabled by default]
cc1: warning: unrecognized command line option "-Wno-misleading-indentation" [enabled by default]
I actually tried specifying the -std
flags as the error message suggests in the meson build file, and I think this got me past this particular problem, but there were still other issues. I had more luck just specifying which gfortran/gcc should be used to avoid the very old default one on this computer. That just works with pip install as well.
$ FC=/path/to/good/gfortran CC=/path/to/good/gcc pip install apexpy
I managed to get this working with GNU Fortran (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5), so the minimum version is somewhere between 4.8.5 and 7.3.1? I'm not sure if you want to try to revise the build file so it can handle this case, or just tell users to please not try to use an ancient version of gfortran.
This was the error message from pip install apexpy
:
error: Command "gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ibuild/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/src/fortranapex -I/tmp/pip-build-env-z8ddhh4b/overlay/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/numpy/distutils/include -I/opt/python/include/python3.9 -c build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/src/fortranapex/fortranobject.c -o build/temp.linux-x86_64-cpython-39/build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/src/fortranapex/fortranobject.o -MMD -MF build/temp.linux-x86_64-cpython-39/build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/src/fortranapex/fortranobject.o.d -msse -msse2 -msse3" failed with exit status 1
INFO:
########### EXT COMPILER OPTIMIZATION ###########
INFO: Platform :
Architecture: x64
Compiler : gcc
CPU baseline :
Requested : 'min'
Enabled : SSE SSE2 SSE3
Flags : -msse -msse2 -msse3
Extra checks: none
CPU dispatch :
Requested : 'max -xop -fma4'
Enabled : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2
Generated : none
INFO: CCompilerOpt.cache_flush[857] : write cache to path -> /tmp/pip-install-whvregnw/apexpy_997e9cd63fda4c6c980240829cd35f8d/build/temp.linux-x86_64-cpython-39/ccompiler_opt_cache_ext.py
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for apexpy
Failed to build apexpy
ERROR: Could not build wheels for apexpy, which is required to install pyproject.toml-based projects
I couldn't understand why it was failing just from that, which is why I started trying to build it.
just tell users to please not try to use an ancient version of gfortran.
I think this is the way to go. Do you want to put together the PR for that, or shall I?
I can - I had a number of clarifications I was going to request to the installation documentation for unusual cases. Do you know if there's an easy way to figure out when those flags were added? I was trying with google but not having much luck. If nothing else, I'll just write it as "has been tested successfully with gfortran 7, earlier versions may not work."
I also had no luck googling 😿 I would just say: "has been tested successfully with gfortran 7, earlier versions may not work.", as you suggested.
Describe the problem or ask the question What is the minimum required version of gfortran required to install the new build version of apexpy? I've had some issues attempting to install with gfortran v4.8.5, most seem to be related to unrecognized compiler flag options.
Desktop: