https://gcc.gnu.org/bugzilla/show_bug.cgi?id=74755

            Bug ID: 74755
           Summary: libgfortran: build breaks if localtime_r prototype is
                    present, but definition is not
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
                CC: cesar at gcc dot gnu.org
  Target Milestone: ---
            Target: nvptx

As of GCC trunk r239356 "Replace KISS PRNG with xorshift1024* using per-thread
state", libgfortran/intrinsics/random.c fails to build when using nvptx-newlib,
<https://github.com/MentorEmbedded/nvptx-newlib>:

    In file included from
[...]/source-gcc/libgfortran/intrinsics/random.c:41:0:
    [...]/source-gcc/libgfortran/intrinsics/time_1.h:92:1: error: static
declaration of 'localtime_r' follows non-static declaration
     localtime_r (const time_t * timep, struct tm * result)
     ^~~~~~~~~~~
    In file included from [...]/source-gcc/newlib/libc/include/stdio.h:29:0,
                     from [...]/source-gcc/libgfortran/libgfortran.h:42,
                     from [...]/source-gcc/libgfortran/intrinsics/random.c:27:
    [...]/source-gcc/newlib/libc/include/time.h:69:12: note: previous
declaration of 'localtime_r' was here
     struct tm *_EXFUN(localtime_r, (const time_t *__restrict,
                ^
    make[3]: *** [random.lo] Error 1

libgfortran/configure doesn't "#define HAVE_LOCALTIME_R", because of:

    unresolved symbol localtime_r
    collect2: error: ld returned 1 exit status

..., and thus libgfortran/intrinsics/time_1.h attempts to provide "static
inline" replacement code, but that (unsurprisingly; "static inline" vs.
"extern") has a conflicting signature to the prototype in nvptx-newlib header
files, where a prototype of localtime_r is declared despite not providing a
definition.

I suppose that needs to be fixed in nvptx-newlib, unless this (localtime_r
prototype present, but definition not) is a configuration that needs to be
supported in libgfortran?

Reply via email to