Hi,
I have encountered an internal compiler error in nvfortran, version 22.3.0, from the HPC SDK. Compiling the small code snippet
function cpp_to_str () bind (C) result (c)
use iso_c_binding
character(c_char) :: c
end function cpp_to_str
leads to this error message:
pgfortran-Fatal-/home/cweiss/build/pgi_sdk/Linux_x86_64/22.3/compilers/bin/tools/fort2 TERMINATED by signal 11
Arguments to /home/cweiss/build/pgi_sdk/Linux_x86_64/22.3/compilers/bin/tools/fort2
/home/cweiss/build/pgi_sdk/Linux_x86_64/22.3/compilers/bin/tools/fort2 /tmp/nvfortranaWl_arhSwM9q.ilm -fn test_iso_c_binding.f90 -opt 1 -terse 1 -inform warn -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp skylake-avx512 -x 120 0x1000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -astype 0 -x 121 1 -x 183 4 -x 121 0x800 -x 68 0x1 -x 8 0x40000000 -x 70 0x40000000 -x 56 0x10 -x 54 0x10 -x 249 130 -x 68 0x20 -x 70 0x40000000 -x 8 0x40000000 -x 164 0x800000 -x 85 0x2000 -x 85 0x4000 -x 34 0x40000000 -x 53 0x800000 -x 83 0x1 -x 84 0x3c7 -x 85 0x1 -x 206 0x02 -x 68 0x1 -x 39 4 -x 56 0x10 -x 26 0x10 -x 26 1 -x 56 0x4000 -x 124 1 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -cci /tmp/nvfortranaWl_azbTtESt.cci -cmdline '+pgfortran test_iso_c_binding.f90 -c' -stbfile /tmp/nvfortranaWl_aHm1F2nR.stb -asm /tmp/nvfortranaWl_abdyLEHC.ll
Can you confirm this? Do you know if there is a workaround?
Best regards,
Christian
Thanks Christian, I was able to reproduce the error here and have filed a problem report, TPR #32289.
The error seems to only occur with the combination of both ‘bind(C)’ and a function returning a character. Not sure it would work in the context of your larger program, but one possible workaround would be to use a “integer(c_signed_char)” type instead of “character(c_char)”.
% cat test1.f90
function cpp_to_str () bind(C) result(c)
use iso_c_binding
integer(c_signed_char) :: c
end function cpp_to_str
% nvfortran test1.f90 -c -V22.3
%
-Mat
Hi Mat,
thanks for your reply and filing the problem report.
I will try out changing to integer types, but might be difficult to include in the rest of the code.
Best regards,
Christian
Hi Mat,
I came around the piece of code from which I extracted this post originally from with the newest nvfortran version 24.11. Unfortunately, the error still persists. On top of that, the workaround doesn’t work anymore either. I get this ICE:
[cweiss@gpu006 tmp]$ nvfortran -c nvfortran_ice_chars.f90
/home/cweiss/local/hpc_sdk/Linux_x86_64/24.11/compilers/share/llvm/bin/llc: error: /home/cweiss/local/hpc_sdk/Linux_x86_64/24.11/compilers/share/llvm/bin/llc: /tmp/nvfortranRTZUebiB5fqMV.ll:9:2: error: multiple definition of local value named 'c_310'
%c_310 = alloca [1 x i8], align 4
This is also the error for the original code, without the (not anymore) workaround.
Best,
Christian
It looks like TPR #32289 was assigned but only triaged, not fixed. I’m checking on status and see if we can bump the priority.
I talked with engineering. It seems that this one will take a significant effort to get working in nvfortran. The code does seem to compile as expected with our new LLVM based compiler currently under development which will eventually replace nvfortran. This new compiler was rebuilt from the ground up to better handle modern Fortran features.
Because of this, as well as interoperating with C chars is not a widely used feature, the consensus here is that we’ll defer this one until the LLVM based compiler is available.
Thanks for the information,
I would love to use the new flang compiler, but I could not make it work with CUDA Fortran yet. I guess that I have to wait until there’s an official release with CUDA Fortran support.
I would stop to report nvfortran bugs if I find some, or do you think otherwise?
If there are any new features or issues with F2008/F2018 features, probably not worth reporting. Though nvfortran will live on for some time as it will take awhile for the new flang based compiler to get through the beta period. Hence if you find things like internal compiler errors or other breaking bugs, then a report would be appreciated.
Thanks,
Mat