https://sourceware.org/bugzilla/show_bug.cgi?id=33801

--- Comment #6 from Sam James <sam at gentoo dot org> ---
With `bootstrap-lto`, GCC sets a special command in config/bootstrap-lto.mk:
```
do-compare = $(SHELL) $(srcdir)/contrib/compare-lto $$f1 $$f2
```

With a small patch to respect $OBJCOPY and $STRIP and add `set -x`, on master:
```
$ cp /tmp/toon/stage2-libiberty/pic/argv.o /tmp/argv.o.stage2 ; cp
/tmp/toon/stage3-libiberty/pic/argv.o /tmp/argv.o.stage3 ;
STRIP="/usr/x86_64-pc-linux-gnu/binutils-bin/999/strip"
OBJCOPY="/usr/x86_64-pc-linux-gnu/binutils-bin/9999/objcopy"
~/git/gcc/contrib/compare-lto argv.o.stage2 argv.o.stage3 ; echo $?
+ rm='rm -f'
+ case $1 in
+ test 2 '!=' 2
+ test '!' -f argv.o.stage2
+ test '!' -f argv.o.stage3
+ suf1=stripped
+ test -f argv.o.stage2.stripped
+ suf2=stripped
+ test -f argv.o.stage3.stripped
+ trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15
+ : /usr/x86_64-pc-linux-gnu/binutils-bin/999/strip
+ : /usr/x86_64-pc-linux-gnu/binutils-bin/9999/objcopy
+ cmp argv.o.stage2 argv.o.stage3
argv.o.stage2 argv.o.stage3 differ: byte 41, line 1
+ status=1
+ cmd=
+ for t in objdump readelf eu--remove-sectioneadelf
+ grep ' --\[*section-\]*headers'
+ cmd=objdump
+ break
+ test xobjdump = x
+ objdump --section-headers argv.o.stage2
+ grep .gnu.lto_.opts
+ echo stripping off LTO option section, then retrying
stripping off LTO option section, then retrying
+ seclist=.gnu.lto_.opts
++ for sec in $seclist
++ echo ' --remove-section .gnu.lto_.opts'
+ rsopts=' --remove-section .gnu.lto_.opts'
+ grep ' --remove-section'
+ /usr/x86_64-pc-linux-gnu/binutils-bin/9999/objcopy --remove-section
.gnu.lto_.opts argv.o.stage2 argv.o.stage2.stripped
+ /usr/x86_64-pc-linux-gnu/binutils-bin/9999/objcopy --remove-section
.gnu.lto_.opts argv.o.stage3 argv.o.stage3.stripped
+ trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15
+ cmp argv.o.stage2.stripped argv.o.stage3.stripped
argv.o.stage2.stripped argv.o.stage3.stripped differ: byte 41, line 1
+ status=1
+ rm -f argv.o.stage2.stripped argv.o.stage3.stripped
+ trap 'exit 1; exit' 0 1 2 15
+ exit 1
+ exit 1
1
```

vs 2.45.1:
```
$ cp /tmp/toon/stage2-libiberty/pic/argv.o /tmp/argv.o.stage2 ; cp
/tmp/toon/stage3-libiberty/pic/argv.o /tmp/argv.o.stage3 ;
STRIP="/usr/x86_64-pc-linux-gnu/binutils-bin/2.45.1/strip"
OBJCOPY="/usr/x86_64-pc-linux-gnu/binutils-bin/2.45.1/objcopy"
~/git/gcc/contrib/compare-lto argv.o.stage2 argv.o.stage3
+ rm='rm -f'
+ case $1 in
+ test 2 '!=' 2
+ test '!' -f argv.o.stage2
+ test '!' -f argv.o.stage3
+ suf1=stripped
+ test -f argv.o.stage2.stripped
+ suf2=stripped
+ test -f argv.o.stage3.stripped
+ trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15
+ : /usr/x86_64-pc-linux-gnu/binutils-bin/2.45.1/strip
+ : /usr/x86_64-pc-linux-gnu/binutils-bin/2.45.1/objcopy
+ cmp argv.o.stage2 argv.o.stage3
argv.o.stage2 argv.o.stage3 differ: byte 41, line 1
+ status=1
+ cmd=
+ for t in objdump readelf eu--remove-sectioneadelf
+ grep ' --\[*section-\]*headers'
+ cmd=objdump
+ break
+ test xobjdump = x
+ objdump --section-headers argv.o.stage2
+ grep .gnu.lto_.opts
+ echo stripping off LTO option section, then retrying
stripping off LTO option section, then retrying
+ seclist=.gnu.lto_.opts
++ for sec in $seclist
++ echo ' --remove-section .gnu.lto_.opts'
+ rsopts=' --remove-section .gnu.lto_.opts'
+ grep ' --remove-section'
+ /usr/x86_64-pc-linux-gnu/binutils-bin/2.45.1/objcopy --remove-section
.gnu.lto_.opts argv.o.stage2 argv.o.stage2.stripped
+ /usr/x86_64-pc-linux-gnu/binutils-bin/2.45.1/objcopy --remove-section
.gnu.lto_.opts argv.o.stage3 argv.o.stage3.stripped
+ trap 'rm -f "$1.$suf1" "$2.$suf2"' 0 1 2 15
+ cmp argv.o.stage2.stripped argv.o.stage3.stripped
+ status=0
+ rm -f argv.o.stage2.stripped argv.o.stage3.stripped
+ trap 'exit 0; exit' 0 1 2 15
+ exit 0
+ exit 0
```

Do we need to change GCC's compare-lto?

Right now, it tries to strip (only) .gnu.lto_.opts because we know options will
differ (-fno-checking vs -fchecking=1) but the rest should be identical, so we
do not strip all LTO sections.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to