llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[flang] Does not support dtime call

Open arrowd opened this issue 1 year ago • 5 comments

The following program fails to link with an undefined symbol, but works with gfortran:

program test_dtime
    integer(8) :: i, j
    real, dimension(2) :: tarray
    real :: result
    call dtime(tarray, result)
    print *, result
    print *, tarray(1)
    print *, tarray(2)   
    do i=1,100000000    ! Just a delay
        j = i * i - i
    end do
    call dtime(tarray, result)
    print *, result
    print *, tarray(1)
    print *, tarray(2)
end program test_dtime

It seems to be a GNU extensions, so I'm not sure if Flang should actually support this.

arrowd avatar Oct 01 '25 17:10 arrowd

It is indeed a GNU extension: https://gcc.gnu.org/onlinedocs/gfortran/DTIME.html

eugeneepshteyn avatar Oct 01 '25 20:10 eugeneepshteyn

I don't know, if flang should support it. FWIW, Intel compiler supports it: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2025-2/dtime.html

eugeneepshteyn avatar Oct 01 '25 20:10 eugeneepshteyn

Probably related issue in a different project:

ld: error: undefined symbol: idate_
>>> referenced by FIRModule
>>>               CMakeFiles/cif2hkl.dir/libs/cif2hkl/cif2hkl.F90.o:(cfml_cif2hkl_)
>>> did you mean: fdate_
>>> defined in: /usr/local/llvm21/lib/clang/21/lib/x86_64-portbld-freebsd14.2/libflang_rt.runtime.a(extensions.cpp.o)

ld: error: undefined symbol: itime_
>>> referenced by FIRModule
>>>               CMakeFiles/cif2hkl.dir/libs/cif2hkl/cif2hkl.F90.o:(cfml_cif2hkl_)

arrowd avatar Oct 15 '25 13:10 arrowd

Yes, these are also GNU extensions:

  • https://gcc.gnu.org/onlinedocs/gfortran/IDATE.html
  • https://gcc.gnu.org/onlinedocs/gfortran/ITIME.html

eugeneepshteyn avatar Oct 16 '25 03:10 eugeneepshteyn

The Fortran Standard is quite clear: A compiler must contain the capability to detect and report the use within a submitted program unit of a non-standard intrinsic procedure (including one with the same name as a standard intrinsic procedure but with different requirements).

The GNU compiler will issue a warning with -Wintrinsics-std -std=f2018.

The Intel compiler takes care to NOT have this non-standard intrinsic procedure, but instead makes DTIME available in a non-standard intrinsic module, IFPORT. According to the Standard, the compiler must contain the capability to detect and report the use within a submitted program unit of a non-standard intrinsic module. I am not sure how to force the Intel compiler to report this.

I think a flang portability (non-standard intrinsic) module, as a "home" for such extensions, would be a good idea. Documenting clearly the option that will put flang in a mode where it reports such things is also a good idea.

amd-thtsikas avatar Oct 22 '25 17:10 amd-thtsikas