stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

PGI / Flang compilers not working

Open scivision opened this issue 5 years ago • 8 comments

Due to bug(s) in PGI / Flang, the stdlib io and optval don't build. There are spurious errors like

PGF90-F-0000-Internal compiler error. interf:new_symbol, symbol not found     630  (src/tests/io/test_loadtxt.f90: 2)

fiddling around with the code, PGI will even give a similar error for implicit none

Basically this seems a lot like other cases where there were bugs in PGI / Flang and not something wrong with stdlib. I did some attempts at workarounds in https://github.com/scivision/stdlib/tree/qp_opt

One could file a bug report with each of PGI and Flang, as the error is effectively identical, perhaps boiling it down to a minimum working example.

scivision avatar Jan 05 '20 05:01 scivision

Is the issue around quadruple precision?

certik avatar Jan 05 '20 06:01 certik

Quadruple precision was part of the issue which I fixed with the #ifdef REAL128. However this remaining issue seems to be an actual compiler bug.

scivision avatar Jan 05 '20 06:01 scivision

If it's too much of a hassle, we can wait with officially supporting Flang until they fix such issues.

certik avatar Jan 05 '20 06:01 certik

I've had similar issues with PGI and flang. I tried compiling my hashMap routines and both gave the same error (but with different equally confusing messages). I reported this to PGI about 1.5 years ago and haven't heard anything from them. Hopefully, flang/f18 will be more robust but I wouldn't rely on current PGI building anything that uses any OO features.

rweed avatar Jan 05 '20 16:01 rweed

My opinion on PGI & Flang re: stdlib is to wait for the next releases of PGI & Flang. They've each made a lot of progress in 2019 w.r.t. Fortran 2008 support.

  • expect no-charge PGI 20.4 in April-May 2020 if prior years' release schedule holds
  • F18 is anticipated to come with LLVM 11 (F18 just missed the LLVM 10 merge window in Jan 2020)

scivision avatar Feb 05 '20 20:02 scivision

I tried to compile the 0.7.0 release with Flang 21. Here are some errors that I got:

error: Semantic errors in /wrkdirs/usr/ports/devel/fortran-stdlib/work/.build/src/stdlib_specialfunctions_gamma.f90
/wrkdirs/usr/ports/devel/fortran-stdlib/work/.build/src/stdlib_specialfunctions_gamma.f90:16:5: error: REAL(KIND=-1) is not a supported type
      real(qp), parameter :: tol_qp = epsilon(1.0_qp)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/wrkdirs/usr/ports/devel/fortran-stdlib/work/.build/src/stdlib_specialfunctions_gamma.f90:16:45: error: Unsupported REAL(KIND=-1)
      real(qp), parameter :: tol_qp = epsilon(1.0_qp)
                                              ^^^
/wrkdirs/usr/ports/devel/fortran-stdlib/work/.build/src/stdlib_specialfunctions_gamma.f90:384:49: error: Value of named constant 'pi' (acos(-one)) cannot be computed as a constant value
                               one = 1.0_qp, pi = acos(- one), sqpi = sqrt(pi)
                                                  ^^^^^^^^^^^
/wrkdirs/usr/ports/devel/fortran-stdlib/work/.build/src/stdlib_specialfunctions_gamma.f90:384:69: error: Value of named constant 'sqpi' (sqrt(pi)) cannot be computed as a constant value
                               one = 1.0_qp, pi = acos(- one), sqpi = sqrt(pi)
                                                                      ^^^^^^^^

arrowd avatar Sep 14 '25 10:09 arrowd

I tried to compile the 0.7.0 release with Flang 21. Here are some errors that I got:

error: Semantic errors in /wrkdirs/usr/ports/devel/fortran-stdlib/work/.build/src/stdlib_specialfunctions_gamma.f90
/wrkdirs/usr/ports/devel/fortran-stdlib/work/.build/src/stdlib_specialfunctions_gamma.f90:16:5: error: REAL(KIND=-1) is not a supported type

This shows that flang doesn't support quadruple precision. One should disable quadruple precision for that compiler.

Romendakil avatar Sep 14 '25 11:09 Romendakil

Right, here's the explanation from upstream: https://github.com/llvm/llvm-project/issues/158444#issuecomment-3289580940

I will retry with quadmath enabled and report back.

arrowd avatar Sep 16 '25 06:09 arrowd