https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100725
Bug ID: 100725 Summary: dwarf error with --whole-program Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: fx at gnu dot org Target Milestone: --- Extending my example in #100724 with -g, I see a dwarf error, which I assume is a separate issue: $ cat test.f90 module tw interface real function twice (x) end function twice end interface end module tw real function twice (x) twice = 2*x end function twice use tw read *, x print *, twice (x) end $ gfortran-11 -O2 -g -fwhole-program test.f90 /usr/bin/ld: /usr/bin/ld: DWARF error: can't find .debug_ranges section. /tmp/cc8sFtAX.o: in function `MAIN__': test.f90:(.text+0x7f): undefined reference to `twice_' collect2: error: ld returned 1 exit status Changing -g to -gdwarf-4 avoids the error, as does removing -fwhole-program. It also works with gcc-10 and -gdwarf-5. The system is Debian 10 amd64 (binutils 2.31.1, if that matters).