[Bug fortran/94016] New: Debug info produced by gfortran contains the wrong path for included files

John.Bollinger at StJude dot org gcc-bugzilla@gcc.gnu.org
Tue Mar 3 16:42:00 GMT 2020


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

            Bug ID: 94016
           Summary: Debug info produced by gfortran contains the wrong
                    path for included files
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: John.Bollinger at StJude dot org
  Target Milestone: ---

Created attachment 47958
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47958&action=edit
Example project that demonstrates the issue

The debug info generated by gfortran always indicates that INCLUDEd files were
located in the root of the build tree.  In the event that they in fact are
elsewhere -- in the case of an out-of-source build, for example -- the
resulting debug info is wrong.  I frequently observe this when building RPMs,
in which case RPM complains, and the affected include files are omitted from
the automatically produced -debuginfo / -debugsource RPMs.

Dumping the debug info via GNU readelf shows the problem pretty clearly, and I
attach a simple test case with which it can be reproduced.  Unpack the tarball,
change to directory gfortran-debuginfo-bug/, and run "make" or "make demo". 
(In addition to a GCC toolchain including gfortran, it uses readelf, make, and
sed to examine the generated debug info.)  The output is:
====
gfortran -g -o example src/example.f
readelf -wl example | sed -n '1,/The Directory Table/{h;d};/Line Number
Statements/q;{x;p;d}'
 The Directory Table (offset 0x1b):
  1     src

 The File Name Table (offset 0x20):
  Entry Dir     Time    Size    Name
  1     1       0       0       example.f
  2     0       0       0       decl.inc
====

The compiler emits no warnings or errors, and the executable works as expected.
But the "Dir" attribute of file name table entry 2 is incorrect: the file it
describes resides in the "src" directory alongside the file described by entry
1, so both should have the same "Dir" attribute (1).

This is a longstanding bug.  I have tagged it for compiler version 8.3.1, as
that is the one I am currently using, but in the past I have observed it also
on versions 4.8.5, 4.4.7, and I think 4.2.1.  Here are my present gfortran
details:

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-shared --enable-threads=posix --enable-checking=release
--enable-multilib --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id --with-gcc-major-version-only
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl
--disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --enable-cet --with-tune=generic
--with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)


More information about the Gcc-bugs mailing list