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

--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
(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?

Reply via email to