[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #20 from rguenther at suse dot de --- On Tue, 13 Mar 2018, nickc at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 > > --- Comment #14 from Nick Clifton --- > Created attachment 43643 > --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43643=edit > Proposed patch > > Hi Guys. > > Here is a possible patch, although it is a bit hackish. > Richard might not like it because it changes gcc/lto-wrapper.c rather than > the linker, but I honestly think that the linker is doing the right thing > in this case. Note with all workarounds proposed they have to "work" (aka not break) with non-GNU ld including gold, Solaris ld, HPUX ld, etc. ... I presume the linker plugin API doesn't allow us to even tell whether --gc-sections was specified for the link or not. So I agree with HJ that this needs to be fixed in the linker. Given there's a known workaround for users that isn't too bad.
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #19 from H.J. Lu --- (In reply to rguent...@suse.de from comment #11) > Nah, just the following - you removed LTO testing of prettyprinters > > Index: libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp > === > --- libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp > (revision 258481) > +++ libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp > (working copy) > @@ -50,7 +50,7 @@ gdb-dg-runtest [lsort [glob $srcdir/$sub > if { [check_effective_target_lto] } { >append cxxflags " -flto" ># work around sourceware.org 20882 > - regsub {^(.*)-Wl,--gc-sections(.*)$} $cxxldflags {\1\2} cxxldflags > + #regsub {^(.*)-Wl,--gc-sections(.*)$} $cxxldflags {\1\2} cxxldflags >gdb-dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \ > "" "$DEFAULT_CXXFLAGS -flto $PCH_CXXFLAGS" > } With this patch applied: https://sourceware.org/ml/binutils/2018-03/msg00175.html I got # of expected passes140 === libstdc++ Summary === # of expected passes201
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #18 from rguenther at suse dot de --- On March 13, 2018 5:15:33 PM GMT+01:00, "nickc at gcc dot gnu.org"wrote: >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 > >--- Comment #16 from Nick Clifton --- >Hi H.J. > >(In reply to H.J. Lu from comment #15) >> It should be fixed in linker. > >OK - so how does the linker distinguish between a file that only >contains >debug information, none of which is needed, and a file that only >contains >debug information of which some/all actually is needed ? There are used symbols and associated debug sections need to be kept. If nothing references the debug it can be discarded. >Cheers > Nick
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 H.J. Lu changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |MOVED --- Comment #17 from H.J. Lu --- Moved to https://sourceware.org/bugzilla/show_bug.cgi?id=20882
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #16 from Nick Clifton --- Hi H.J. (In reply to H.J. Lu from comment #15) > It should be fixed in linker. OK - so how does the linker distinguish between a file that only contains debug information, none of which is needed, and a file that only contains debug information of which some/all actually is needed ? Cheers Nick
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #15 from H.J. Lu --- (In reply to Nick Clifton from comment #14) > Created attachment 43643 [details] > Proposed patch > > Hi Guys. > > Here is a possible patch, although it is a bit hackish. > Richard might not like it because it changes gcc/lto-wrapper.c rather than > the linker, but I honestly think that the linker is doing the right thing > in this case. > It should be fixed in linker.
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #14 from Nick Clifton --- Created attachment 43643 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43643=edit Proposed patch Hi Guys. Here is a possible patch, although it is a bit hackish. Richard might not like it because it changes gcc/lto-wrapper.c rather than the linker, but I honestly think that the linker is doing the right thing in this case. Cheers Nick
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #13 from David Malcolm --- (In reply to H.J. Lu from comment #12) > Need GCC 8 to reproduce: Thanks. What version of ld was this with?
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 H.J. Lu changed: What|Removed |Added Status|WAITING |NEW --- Comment #12 from H.J. Lu --- Need GCC 8 to reproduce: /usr/gcc-8.0.1-x32/bin/gcc -I ./src -flto -O2 -g -c src/bootchart.c -o build/bootchart.o /usr/gcc-8.0.1-x32/bin/gcc -I ./src -flto -O2 -g -c src/log.c -o build/log.o /usr/gcc-8.0.1-x32/bin/gcc -flto -g -Wl,--gc-sections -Wl,--print-gc-sections \ build/bootchart.o build/log.o \ -o build/systemd-bootchart /usr/local/bin/ld: removing unused section '.rodata.cst4' in file '/lib/../lib64/crt1.o' /usr/local/bin/ld: removing unused section '.data' in file '/lib/../lib64/crt1.o' /usr/local/bin/ld: removing unused section '.data' in file '/usr/gcc-8.0.1-x32/lib/gcc/x86_64-pc-linux-gnu/8.0.1/crtbegin.o' /usr/local/bin/ld: removing unused section '.debug_abbrev' in file '/tmp/ccpV3zjtdebugobj' /usr/local/bin/ld: removing unused section '.debug_str' in file '/tmp/ccpV3zjtdebugobj' /usr/lib/rpm/debugedit build/systemd-bootchart /usr/lib/rpm/debugedit: build/systemd-bootchart: Invalid .line_table offset 0x2b0803 make: *** [Makefile:23: test] Segmentation fault
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #11 from rguenther at suse dot de --- On Tue, 13 Mar 2018, hjl.tools at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 > > --- Comment #9 from H.J. Lu --- > (In reply to rguent...@suse.de from comment #6) > > > > make check-target-libstdc++-v3 RUNTESTFLAGS="prettyprinters.exp" > > I tried: > > diff --git > a/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp > b/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp > index c51b1ffb21c..fab6ef11947 100644 > --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp > +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp > @@ -47,14 +47,6 @@ global PCH_CXXFLAGS > gdb-dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \ >"" "$DEFAULT_CXXFLAGS $PCH_CXXFLAGS" > > -if { [check_effective_target_lto] } { > - append cxxflags " -flto" > - # work around sourceware.org 20882 > - regsub {^(.*)-Wl,--gc-sections(.*)$} $cxxldflags {\1\2} cxxldflags > - gdb-dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \ > -"" "$DEFAULT_CXXFLAGS -flto $PCH_CXXFLAGS" > -} > - > if [info exists guality_gdb_name] { > unsetenv GUALITY_GDB_NAME > } Nah, just the following - you removed LTO testing of prettyprinters Index: libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp === --- libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp (revision 258481) +++ libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp (working copy) @@ -50,7 +50,7 @@ gdb-dg-runtest [lsort [glob $srcdir/$sub if { [check_effective_target_lto] } { append cxxflags " -flto" # work around sourceware.org 20882 - regsub {^(.*)-Wl,--gc-sections(.*)$} $cxxldflags {\1\2} cxxldflags + #regsub {^(.*)-Wl,--gc-sections(.*)$} $cxxldflags {\1\2} cxxldflags gdb-dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \ "" "$DEFAULT_CXXFLAGS -flto $PCH_CXXFLAGS" }
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #10 from H.J. Lu --- (In reply to rguent...@suse.de from comment #8) > On Tue, 13 Mar 2018, hjl.tools at gmail dot com wrote: > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 > > > > --- Comment #7 from H.J. Lu --- > > Binutils 2.30 branch looks normal: > > I tried 2.30 branch at 4cd0043413 and that still has UNRESOLVED > libstdc++ prettyprinter tests. binutils-2_30-branch at commit ff7e1a287ace9c also works for me. Please show me the relevant libstdc++.log.
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #9 from H.J. Lu --- (In reply to rguent...@suse.de from comment #6) > > make check-target-libstdc++-v3 RUNTESTFLAGS="prettyprinters.exp" I tried: diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp b/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp index c51b1ffb21c..fab6ef11947 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/prettyprinters.exp @@ -47,14 +47,6 @@ global PCH_CXXFLAGS gdb-dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \ "" "$DEFAULT_CXXFLAGS $PCH_CXXFLAGS" -if { [check_effective_target_lto] } { - append cxxflags " -flto" - # work around sourceware.org 20882 - regsub {^(.*)-Wl,--gc-sections(.*)$} $cxxldflags {\1\2} cxxldflags - gdb-dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \ -"" "$DEFAULT_CXXFLAGS -flto $PCH_CXXFLAGS" -} - if [info exists guality_gdb_name] { unsetenv GUALITY_GDB_NAME } > with binutils master and the prettyprinters.exp hack removed? === libstdc++ Summary === # of expected passes140 > Do you know what fixed it on master? https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b7c871edcd83ccdc5fcd8148a7f433efd6b52255
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #8 from rguenther at suse dot de --- On Tue, 13 Mar 2018, hjl.tools at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 > > --- Comment #7 from H.J. Lu --- > Binutils 2.30 branch looks normal: I tried 2.30 branch at 4cd0043413 and that still has UNRESOLVED libstdc++ prettyprinter tests.
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #7 from H.J. Lu --- Binutils 2.30 branch looks normal: [hjl@gnu-cfl-1 rhbz-1543912]$ gcc -flto -g -Wl,--gc-sections -Wl,--print-gc-sections build/bootchart.o build/log.o -o build/systemd-bootchart -B./ -Wl,-v collect2 version 7.3.1 20180303 (Red Hat 7.3.1-5) ./ld -plugin /usr/libexec/gcc/x86_64-redhat-linux/7/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper -plugin-opt=-fresolution=/tmp/cc1PZVqG.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o build/systemd-bootchart /usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o -L. -L/usr/lib/gcc/x86_64-redhat-linux/7 -L/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/7/../../.. --gc-sections --print-gc-sections build/bootchart.o build/log.o -v -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/7/crtend.o /usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crtn.o GNU ld (GNU Binutils) 2.30.0.20180313 ./ld: Removing unused section '.rodata.cst4' in file '/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o' ./ld: Removing unused section '.data' in file '/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o' ./ld: Removing unused section '.rodata' in file '/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o' [hjl@gnu-cfl-1 rhbz-1543912]$ Please try FSF binutils 2.30, not from Fedora 28.
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #6 from rguenther at suse dot de --- On Tue, 13 Mar 2018, hjl.tools at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 > > --- Comment #5 from H.J. Lu --- > (In reply to David Malcolm from comment #0) > > The downstream bug report: > > https://bugzilla.redhat.com/show_bug.cgi?id=1543912 > > describes a problem building systemd and systemd-bootchart with gcc 8, which > > turned out to be due to those packages' configure scripts injecting both > > -flto > > and > > -Wl,--gc-sections > > > > They build fine with just one of them, but with both, the binaries have > > corrupt DWARF debuginfo. > > > > Adding "-Wl,--print-gc-sections" shows the issue more clearly. > > > > I created a minimal reproducer here: > > https://github.com/davidmalcolm/rhbz-1543912 > > with which I can reproduce the issue, using: > > gcc-8.0.1-0.16.fc29.x86_64 > > binutils-2.30-6.fc29.x86_64 > > (this is on Fedora in a chroot via "mock -r fedora-rawhide-x86_64 shell"; > > I'm still working on reproducing this outside a chroot) > > > > $ make > > gcc -I ./src -flto -O2 -g -c src/bootchart.c -o build/bootchart.o > > gcc -I ./src -flto -O2 -g -c src/log.c -o build/log.o > > gcc -flto -g -Wl,--gc-sections -Wl,--print-gc-sections \ > > build/bootchart.o build/log.o \ > > -o build/systemd-bootchart > > /usr/bin/ld: Removing unused section '.rodata.cst4' in file > > '/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o' > > /usr/bin/ld: Removing unused section '.data' in file > > '/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o' > > /usr/bin/ld: Removing unused section '.rodata' in file > > '/usr/lib/gcc/x86_64-redhat-linux/8/crtbegin.o' > > /usr/bin/ld: Removing unused section '.debug_abbrev' in file > > '/tmp/cc1vnNPxdebugobj' > > /usr/bin/ld: Removing unused section '.debug_str' in file > > '/tmp/cc1vnNPxdebugobj' > > /usr/lib/rpm/debugedit build/systemd-bootchart > > /usr/lib/rpm/debugedit: build/systemd-bootchart: Invalid .line_table offset > > 0x2b0803 > > /usr/lib/rpm/debugedit: build/systemd-bootchart: Could not find DWARF > > abbreviation 7 > > > > With binutils master branch, I got > > mkdir build > gcc -I ./src -flto -O2 -g -c src/bootchart.c -o build/bootchart.o > gcc -I ./src -flto -O2 -g -c src/log.c -o build/log.o > gcc -flto -g -Wl,--gc-sections -Wl,--print-gc-sections \ > build/bootchart.o build/log.o \ > -o build/systemd-bootchart > /usr/local/bin/ld: removing unused section '.rodata.cst4' in file > '/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o' > /usr/local/bin/ld: removing unused section '.data' in file > '/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o' > /usr/local/bin/ld: removing unused section '.rodata' in file > '/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o' > /usr/lib/rpm/debugedit build/systemd-bootchart > > Does it look OK? Can you try make check-target-libstdc++-v3 RUNTESTFLAGS="prettyprinters.exp" with binutils master and the prettyprinters.exp hack removed? Do you know what fixed it on master?
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 H.J. Lu changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2018-03-13 CC||hjl.tools at gmail dot com Ever confirmed|0 |1
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #5 from H.J. Lu --- (In reply to David Malcolm from comment #0) > The downstream bug report: > https://bugzilla.redhat.com/show_bug.cgi?id=1543912 > describes a problem building systemd and systemd-bootchart with gcc 8, which > turned out to be due to those packages' configure scripts injecting both > -flto > and > -Wl,--gc-sections > > They build fine with just one of them, but with both, the binaries have > corrupt DWARF debuginfo. > > Adding "-Wl,--print-gc-sections" shows the issue more clearly. > > I created a minimal reproducer here: > https://github.com/davidmalcolm/rhbz-1543912 > with which I can reproduce the issue, using: > gcc-8.0.1-0.16.fc29.x86_64 > binutils-2.30-6.fc29.x86_64 > (this is on Fedora in a chroot via "mock -r fedora-rawhide-x86_64 shell"; > I'm still working on reproducing this outside a chroot) > > $ make > gcc -I ./src -flto -O2 -g -c src/bootchart.c -o build/bootchart.o > gcc -I ./src -flto -O2 -g -c src/log.c -o build/log.o > gcc -flto -g -Wl,--gc-sections -Wl,--print-gc-sections \ > build/bootchart.o build/log.o \ > -o build/systemd-bootchart > /usr/bin/ld: Removing unused section '.rodata.cst4' in file > '/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o' > /usr/bin/ld: Removing unused section '.data' in file > '/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o' > /usr/bin/ld: Removing unused section '.rodata' in file > '/usr/lib/gcc/x86_64-redhat-linux/8/crtbegin.o' > /usr/bin/ld: Removing unused section '.debug_abbrev' in file > '/tmp/cc1vnNPxdebugobj' > /usr/bin/ld: Removing unused section '.debug_str' in file > '/tmp/cc1vnNPxdebugobj' > /usr/lib/rpm/debugedit build/systemd-bootchart > /usr/lib/rpm/debugedit: build/systemd-bootchart: Invalid .line_table offset > 0x2b0803 > /usr/lib/rpm/debugedit: build/systemd-bootchart: Could not find DWARF > abbreviation 7 > With binutils master branch, I got mkdir build gcc -I ./src -flto -O2 -g -c src/bootchart.c -o build/bootchart.o gcc -I ./src -flto -O2 -g -c src/log.c -o build/log.o gcc -flto -g -Wl,--gc-sections -Wl,--print-gc-sections \ build/bootchart.o build/log.o \ -o build/systemd-bootchart /usr/local/bin/ld: removing unused section '.rodata.cst4' in file '/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o' /usr/local/bin/ld: removing unused section '.data' in file '/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o' /usr/local/bin/ld: removing unused section '.rodata' in file '/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o' /usr/lib/rpm/debugedit build/systemd-bootchart Does it look OK?
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #4 from Richard Biener --- Note that back in time using gold made things work.
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 Richard Biener changed: What|Removed |Added See Also||https://sourceware.org/bugz ||illa/show_bug.cgi?id=20882 --- Comment #3 from Richard Biener --- I have re-opened the binutils bug.
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 Richard Biener changed: What|Removed |Added Keywords||lto Target Milestone|--- |8.0 --- Comment #2 from Richard Biener --- Note this is clearly a binutils bug, not a GCC one. Note I think we cannot work around this ld bug in GCC. The 20882 workaround cannot be removed from prettyprinters.exp when using binutils 2.29.1. I then still get === libstdc++ Summary === # of expected passes270 # of unsupported tests 14 instead of === libstdc++ Summary === # of expected passes512 errors are like Dwarf Error: could not find abbrev number 100 [in module /tmp/obj/x86_64-pc-linux-gnu/libstdc++-v3/testsuite/48362.exe]^M skipping: Dwarf Error: could not find abbrev number 100 [in module /tmp/obj/x86_64-pc-linux-gnu/libstdc++-v3/testsuite/48362.exe]^M 48362.gdb:5: Error in sourced command file:^M No symbol table is loaded. Use the "file" command.^M skipping: 48362.gdb:5: Error in sourced command file:^M skipping: No symbol table is loaded. Use the "file" command.^M UNSUPPORTED: libstdc++-prettyprinters/48362.cc
[Bug lto/84847] [8 Regression] Incompatibility between early LTO debug and "-Wl,--gc-sections" leads to corrupt DWARF debuginfo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 --- Comment #1 from rguenther at suse dot de --- On Tue, 13 Mar 2018, dmalcolm at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84847 > > Bug ID: 84847 >Summary: [8 Regression] Incompatibility between early LTO debug > and "-Wl,--gc-sections" leads to corrupt DWARF > debuginfo >Product: gcc >Version: 8.0 > Status: UNCONFIRMED > Severity: normal > Priority: P3 > Component: lto > Assignee: unassigned at gcc dot gnu.org > Reporter: dmalcolm at gcc dot gnu.org > CC: marxin at gcc dot gnu.org, nickc at gcc dot gnu.org, > rguenth at gcc dot gnu.org > Target Milestone: --- > > The downstream bug report: > https://bugzilla.redhat.com/show_bug.cgi?id=1543912 > describes a problem building systemd and systemd-bootchart with gcc 8, which > turned out to be due to those packages' configure scripts injecting both > -flto > and > -Wl,--gc-sections > > They build fine with just one of them, but with both, the binaries have > corrupt > DWARF debuginfo. > > Adding "-Wl,--print-gc-sections" shows the issue more clearly. > > I created a minimal reproducer here: > https://github.com/davidmalcolm/rhbz-1543912 > with which I can reproduce the issue, using: > gcc-8.0.1-0.16.fc29.x86_64 > binutils-2.30-6.fc29.x86_64 > (this is on Fedora in a chroot via "mock -r fedora-rawhide-x86_64 shell"; I'm > still working on reproducing this outside a chroot) > > $ make > gcc -I ./src -flto -O2 -g -c src/bootchart.c -o build/bootchart.o > gcc -I ./src -flto -O2 -g -c src/log.c -o build/log.o > gcc -flto -g -Wl,--gc-sections -Wl,--print-gc-sections \ > build/bootchart.o build/log.o \ > -o build/systemd-bootchart > /usr/bin/ld: Removing unused section '.rodata.cst4' in file > '/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o' > /usr/bin/ld: Removing unused section '.data' in file > '/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o' > /usr/bin/ld: Removing unused section '.rodata' in file > '/usr/lib/gcc/x86_64-redhat-linux/8/crtbegin.o' > /usr/bin/ld: Removing unused section '.debug_abbrev' in file > '/tmp/cc1vnNPxdebugobj' > /usr/bin/ld: Removing unused section '.debug_str' in file > '/tmp/cc1vnNPxdebugobj' > /usr/lib/rpm/debugedit build/systemd-bootchart > /usr/lib/rpm/debugedit: build/systemd-bootchart: Invalid .line_table offset > 0x2b0803 > /usr/lib/rpm/debugedit: build/systemd-bootchart: Could not find DWARF > abbreviation 7 > > In the above, note how ld has garbage-collected the '.debug_abbrev' and > '.debug_str' sections from the /tmp/cc*debugobj file. > > Examining the binary via > eu-readelf -w build/systemd-bootchart > shows bogus-looking compile_unit DIEs in the binary: > > DWARF section [23] '.debug_info' at offset 0x10a6: > [Offset] > Compilation unit at offset 0: > Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 > [ b] compile_unit >producer (strp) "/builddir/build/BUILD/minimizing-2" >language (data1) C99 (12) >name (strp) "/builddir/build/BUILD/minimizing-2" >comp_dir (strp) "/builddir/build/BUILD/minimizing-2" >ranges (sec_offset) range list [ 2] >low_pc (addr) 0x00250e030100 > Compilation unit at offset 105: > Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 > [74] compile_unit >producer (strp) "/builddir/build/BUILD/minimizing-2" >language (data1) C99 (12) >name (strp) "/builddir/build/BUILD/minimizing-2" >comp_dir (strp) "/builddir/build/BUILD/minimizing-2" >ranges (sec_offset) range list [ 2] >low_pc (addr) 0x870006030100 > > Note how every string is using string 0. > > Removing the -Wl,--gc-sections leads to sane-looking DIEs. > > The issue seems to be that lto-wrapper generates /tmp/cc*debugobj files > containing "early LTO debug info", but, quoting Nick in: > https://bugzilla.redhat.com/show_bug.cgi?id=1543912#c22 > > I have now found out what it happening, although I am still a little bit > > confused as to why it should be occurring. The LTO pass is producing an > > object file that only contains debug information: > > > > /dev/shm/ccqhNEybdebugobj > > > > (There was a clue in the filename, but I did not pay attention to this). > > > > The linker's garbage collection code reasons that any file that does not > > have *any* allocatable sections[1] can automatically be discarded, since > > it > > cannot have any effect on the execution of the resulting binary, right ? > > ... > > > > So this