Fortran codes using intrinsic::ieee_arithmetic on aarch, powerpc architectures fail to compile. See details in this FreeBSD bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255890
Looks like an OS problem. Not sure GCC can do anything here.
intrinsic::ieee_arithmetic works fine on amd64/i386 architectures on the same OS. What do you think is missing/wrong in the OS that causes it?
On amd64 gcc installs the file finclude/ieee_arithmetic.mod and on aarch64 this file isn't installed. What is installed is defined by the gcc build process.
On Tue, May 18, 2021 at 10:47:30PM +0000, yuri at tsoft dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100662 > > --- Comment #3 from Yuri <yuri at tsoft dot com> --- > On amd64 gcc installs the file finclude/ieee_arithmetic.mod > and on aarch64 this file isn't installed. > > What is installed is defined by the gcc build process. > Does FreeBSD support IEEE754 on aarch64? What does config.log say about IEEE modules?
config.log doesn't contain the IEEE string even on amd64. libgfortran/configure.host seems to only enable IEEE modules on i?86 | x86_64 architectures through this code: > case "${host_cpu}" in > i?86 | x86_64) > if test "x${have_soft_float}" = "xyes"; then > fpu_host='fpu-generic' > else > fpu_host='fpu-387' > fi > ieee_support='yes' > ;; > esac What does gcc need from OS for IEEE754? Shouldn't it just compile with relevant to IEEE754 opcodes?
On Wed, May 19, 2021 at 12:56:57AM +0000, yuri at tsoft dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100662 > > --- Comment #5 from Yuri <yuri at tsoft dot com> --- > config.log doesn't contain the IEEE string even on amd64. > > libgfortran/configure.host seems to only enable IEEE modules on i?86 | x86_64 > architectures through this code: > > > case "${host_cpu}" in > > i?86 | x86_64) > > if test "x${have_soft_float}" = "xyes"; then > > fpu_host='fpu-generic' > > else > > fpu_host='fpu-387' > > fi > > ieee_support='yes' > > ;; > > esac > > What does gcc need from OS for IEEE754? > Shouldn't it just compile with relevant to IEEE754 opcodes? > In x86_64-unknown-freebsd14.0/libgfortran/config.log I see configure:26522: FPU dependent file will be fpu-387.h configure:26524: Support for IEEE modules: yes Looking at libgfortran/configure and libgfortran/configure.host and looking in libgfortran/config/, it seems you'll need to define an fpu-aarch64.h I don't have an aarch64 system nor access to such a system, so can't help you more.
fpu-387.h is in the gcc10 source tree: > $ find . -name "fpu-*" > ./work/gcc-10.3.0/libgfortran/config/fpu-generic.h > ./work/gcc-10.3.0/libgfortran/config/fpu-sysv.h > ./work/gcc-10.3.0/libgfortran/config/fpu-glibc.h > ./work/gcc-10.3.0/libgfortran/config/fpu-aix.h > ./work/gcc-10.3.0/libgfortran/config/fpu-387.h fpu-aarch64.h isn't in the gcc10 tree, and not among FreeBSD-installed headers. It seems that it is missing in gcc?
On Wed, May 19, 2021 at 01:43:28AM +0000, yuri at tsoft dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100662 > > --- Comment #7 from Yuri <yuri at tsoft dot com> --- > fpu-387.h is in the gcc10 source tree: > > $ find . -name "fpu-*" > > ./work/gcc-10.3.0/libgfortran/config/fpu-generic.h > > ./work/gcc-10.3.0/libgfortran/config/fpu-sysv.h > > ./work/gcc-10.3.0/libgfortran/config/fpu-glibc.h > > ./work/gcc-10.3.0/libgfortran/config/fpu-aix.h > > ./work/gcc-10.3.0/libgfortran/config/fpu-387.h > > fpu-aarch64.h isn't in the gcc10 tree, and not among FreeBSD-installed headers. > > It seems that it is missing in gcc? > Yes, you would need to write the fpu-aarch64.h header.
Steve, is this a GCC bug or a FreeBSD bug (or if it is something else, what side does this belong to)? Other OSs seem to be able to compile gfortran with these modules for these architectures, see, e.g., https://packages.ubuntu.com/focal/arm64/gfortran-10/filelist and https://packages.ubuntu.com/focal/ppc64el/gfortran-10/filelist). And they seem to have been able to do so since the introduction of the three Fortran IEEE intrinsic modules in GCC 5 (https://packages.ubuntu.com/bionic/amd64/gfortran-5/filelist and https://packages.ubuntu.com/bionic/ppc64el/gfortran-5/filelist). Therefore, some kind of solution must exist for this - and probably has been there for over half a decade. (Apologies for not being able to provide a better insight from the Ubuntu sources.) Thank you.
On Wed, May 19, 2021 at 09:45:12AM +0000, ripero84 at gmail dot com wrote: > --- Comment #9 from ripero84 at gmail dot com --- > Steve, is this a GCC bug or a FreeBSD bug (or if it is something else, what > side does this belong to)? I suppose it is both. AFAIK, there is no longer an active FreeBSD maintainer for GCC (if there were, the few non-gfortran PR/patches I submitted would have been committed). I no longer send patches to GCC for gfortran as I know virtually nothing about git. > Other OSs seem to be able to compile gfortran with these modules for these > architectures, see, e.g., > https://packages.ubuntu.com/focal/arm64/gfortran-10/filelist and > https://packages.ubuntu.com/focal/ppc64el/gfortran-10/filelist). And they seem > to have been able to do so since the introduction of the three Fortran IEEE > intrinsic modules in GCC 5 > (https://packages.ubuntu.com/bionic/amd64/gfortran-5/filelist and > https://packages.ubuntu.com/bionic/ppc64el/gfortran-5/filelist). Therefore, > some kind of solution must exist for this - and probably has been there for > over half a decade. (Apologies for not being able to provide a better insight > from the Ubuntu sources.) ubuntu is glibc. You (or something) needs to read libgfortran/configure.host, and add the needed logic for FreeBSD to pick up an appropriate fpu-*.h file on aarch64. The first 3 non-comment lines of that file are # DEFAULTS fpu_host='fpu-generic' ieee_support='no' which is what non-i386/amd64 FreeBSD systems likely use. It seems fpu-generic.h provides stubs for a few functions required to build gfortran. After gfortran is built, installation does not install useless ieee*.mod files. Note, a standard conforming Fortran compiler is not required to support the ieee modules. Furhter down in the file, there is a check for fenv compatibilities, if test "x${have_feenableexcept}" = "xyes"; then fpu_host='fpu-glibc' ieee_support='yes' fi but the name of the file seems too specific to glibc. If fenv facilities are available, I would have thought the file would be named fpu-fenv.h. My guess is that configure does not find fenv on aarch64 FreeBSD and/or aarch64 FreeBSD does not support fenv.
Thank you very much for the information and your help.
Andreas, is this something you may be able to have a look at? (It's about the architectures you used to "play" with on FreeBSD.)
I try to find some spare cycles to look into. But I can only investigate the aarch64 part. The powerpcs are gone here.
(In reply to Gerald Pfeifer from comment #12) > Andreas, is this something you may be able to have a look at? > (It's about the architectures you used to "play" with on FreeBSD.) There are other PRs that affect (all archs on) FreeBSD that have been orphaned. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89125
Regarding comment #10, Steve is right with his guess, configure doesn't find the fenv functionalities needed. The reason is pretty simple, for aarch64 and powerpc, they are not public. A quick trial showed that if they are visible, then gfortran is 'happy' and nearly all ieee testcases pass. I did not investigate the failing parts. The big issue is, how can we make them available to libm. This is an OS issue and not a gcc issue. The only thing I'm confused in gcc land, as Steve as well, why is the file named fpu-glibc and not fpu-fenv? Regarding the OS issue, it might take a while to (re)solve this.
This issue has been fixed in FreeBSD's main branch on powerpc* in https://cgit.freebsd.org/src/commit/?id=448c505c33cc334193590f3844406d6a74f26e2a Similar fix could be done for other affected architectures.
The same failure happens on MacOS PPC with GCC12: /opt/local/var/macports/build/_opt_PPCRosettaPorts_science_OpenCoarrays/OpenCoarrays/work/OpenCoarrays-2.10.0/src/tests/integration/pde_solvers/coarrayBurgers/main.F90:3:20: 3 | use, intrinsic :: ieee_arithmetic, only : ieee_is_nan | 1 Fatal Error: Cannot find an intrinsic module named 'ieee_arithmetic' at (1) compilation terminated. Error: command: `/opt/local/bin/mpif90-mpich-gcc12 -I/opt/local/var/macports/build/_opt_PPCRosettaPorts_science_OpenCoarrays/OpenCoarrays/work/build/include/OpenCoarrays-2.10.0_GNU-12.2.0 -fcoarray=lib -DGCC_GE_7 -DGCC_GE_8 -DHAVE_MPI -DMPI_WORKING_MODULE -DPREFIX_NAME=_gfortran_caf_ -I/opt/local/var/macports/build/_opt_PPCRosettaPorts_science_OpenCoarrays/OpenCoarrays/work/build/src/tests/integration/pde_solvers/coarrayBurgers/library -pipe -Os -m32 -mmacosx-version-min=10.6 -c /opt/local/var/macports/build/_opt_PPCRosettaPorts_science_OpenCoarrays/OpenCoarrays/work/OpenCoarrays-2.10.0/src/tests/integration/pde_solvers/coarrayBurgers/main.F90 -o CMakeFiles/coarray_burgers_pde.dir/main.F90.o` failed to compile.
(In reply to Piotr Kubaj from comment #16) > This issue has been fixed in FreeBSD's main branch on powerpc* in > https://cgit.freebsd.org/src/commit/ > ?id=448c505c33cc334193590f3844406d6a74f26e2a > > Similar fix could be done for other affected architectures. Piotr, could you say, are there test results for the current gfortran on FreeBSD ppc32 somewhere? To have some meaningful reference.