fortran-lang / stdlib

Fortran Standard Library
https://stdlib.fortran-lang.org
MIT License
1.07k stars 164 forks source link

Build on PowerPC fails due to missing ieee_arithmetic #690

Closed barracuda156 closed 1 month ago

barracuda156 commented 1 year ago

Description

FAILED: src/CMakeFiles/fortran_stdlib.dir/stdlib_stats_cov.f90.o src/mod_files/stdlib_stats@stdlib_stats_cov.smod 
/opt/local/bin/gfortran-mp-12 -I/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_fortran-stdlib/fortran-stdlib/work/build/src -I/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_fortran-stdlib/fortran-stdlib/work/build/src/mod_files -pipe -Os -m32 -fimplicit-none -ffree-line-length-132 -mmacosx-version-min=10.6 -Jsrc/mod_files/ -fPIC -fpreprocessed -c src/CMakeFiles/fortran_stdlib.dir/stdlib_stats_cov.f90-pp.f90 -o src/CMakeFiles/fortran_stdlib.dir/stdlib_stats_cov.f90.o
/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_fortran-stdlib/fortran-stdlib/work/build/src/stdlib_stats_cov.f90:3:19:

    3 |   use, intrinsic:: ieee_arithmetic, only: ieee_value, ieee_quiet_nan
      |                   1
Fatal Error: Cannot find an intrinsic module named 'ieee_arithmetic' at (1)
compilation terminated.

FAILED: src/CMakeFiles/fortran_stdlib.dir/stdlib_stats_mean.f90.o src/mod_files/stdlib_stats@stdlib_stats_mean.smod 
/opt/local/bin/gfortran-mp-12 -I/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_fortran-stdlib/fortran-stdlib/work/build/src -I/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_fortran-stdlib/fortran-stdlib/work/build/src/mod_files -pipe -Os -m32 -fimplicit-none -ffree-line-length-132 -mmacosx-version-min=10.6 -Jsrc/mod_files/ -fPIC -fpreprocessed -c src/CMakeFiles/fortran_stdlib.dir/stdlib_stats_mean.f90-pp.f90 -o src/CMakeFiles/fortran_stdlib.dir/stdlib_stats_mean.f90.o
/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_fortran-stdlib/fortran-stdlib/work/build/src/stdlib_stats_mean.f90:3:19:

    3 |   use, intrinsic:: ieee_arithmetic, only: ieee_value, ieee_quiet_nan
      |                   1
Fatal Error: Cannot find an intrinsic module named 'ieee_arithmetic' at (1)
compilation terminated.

There may be two solutions: if it is not required, for now fix compilation without it. If it is required, we need to implement ieee_arithmetic for PPC :) Relevant discussion: https://github.com/iains/darwin-toolchains-start-here/discussions/40

Expected Behaviour

We want Fortran stdlib to build successfully on PowerPC.

Version of stdlib

0.2.1

Platform and Architecture

MacOS/ppc

Additional Information

GCC 12.2.0 10.6.8 Rosetta (ppc32), but the failure applied to all macOS ppc/ppc64

jvdp1 commented 1 year ago

Thanks for reporting this issue. This seems to be an issue related to the OS/compiler. Is the fix proposed in this thread working?

barracuda156 commented 1 year ago

Thanks for reporting this issue. This seems to be an issue related to the OS/compiler. Is the fix proposed in this thread working?

@jvdp1 You are right, it is compiler-related, GCC does not have ieee_arithmetic module for Darwin PPC (as well as for a number of other systems and archs). Optimal solution would be implement that in GCC, of course. However it is not a trivial thing to do. If anyone is interested and can help with that, it would be awesome. There are some details in the discussion I have referred to above with GCC developers.

FreeBSD solution is not applicable, since Darwin does not use glibc.

barracuda156 commented 1 year ago

@jvdp1 Could we come up with a temporary fix?

While I kinda have ieee_arithmetic fixed for PPC, it is still WIP, and even when completed, may take ages to get merged into GCC. It is desirable to have stdlib available prior to that. I do not ask for the fix to be here in master branch, if it is too intrusive. I rather mean a local patch for Macports.

jvdp1 commented 1 year ago

Could the fix be a minimal implementation of ieee_arithmetic inside stdlib?

barracuda156 commented 1 year ago

Could the fix be a minimal implementation of ieee_arithmetic inside stdlib?

@jvdp1 That would be awesome. It would also fix the build for some other platforms (perhaps something like Irix and VxWorks). (If that is done, it is desirable for it to be non-conflicting with compilers that do support ieee_arithmetic, including PowerPC case, so that we do not have to fix that again later on.)

barracuda156 commented 1 month ago

@jvdp1 Closing this, since my PR to GCC has been merged, and gcc 15 will have ieee_arithmetic support on macOS PowerPC.

Ref: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=1cfe4a4d0d4447b364815d5e5c889deb2e533669 https://github.com/gcc-mirror/gcc/commit/1cfe4a4d0d4447b364815d5e5c889deb2e533669

P. S. While this issue is resolved, it may still be worth having a fallback, because there are still platforms without ieee_arithmetic support, and that is not likely to change.