Bug 67156 - config/bootstrap-debug.mk: STAGE2_CFLAGS += -gtoggle
Summary: config/bootstrap-debug.mk: STAGE2_CFLAGS += -gtoggle
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2015-08-08 13:58 UTC by Дилян Палаузов
Modified: 2015-12-17 00:36 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Дилян Палаузов 2015-08-08 13:58:43 UTC
config/bootstrap-debug.mk contains:
  STAGE2_CFLAGS += -gtoggle
and in turn stage2 is compiled with -gtoggle, while stage3 is compile without -gtoggle. This can be seen by comparing stage{2,3}-gcc/Makefile .  After finishing stage3, the build process compares the binaries from stage2 and stage3, which differ, because they were compiled with/out -gtoggle.

Removing  -gtoggle from config/bootstrap-debug.mk:STAGE2_CFLAGS enables to finish the compilation without errors (during the final comparison)

I compile gcc with 

/git/gcc/configure --enable-host-shared --enable-threads=posix --with-arch=haswell --enable-__cxa_atexit --enable-languages=c,c++,lto,jit --enable-targets=all --enable-nls --with-linker-hash-style=gnu --with-system-zlib --disable-multilib

and the gcc-git repository is at the newest state.
Comment 1 Andrew Pinski 2015-08-08 14:11:31 UTC
What target is this on?  Because debugging information generate should not change the code generation.
Comment 2 Дилян Палаузов 2015-08-08 14:26:37 UTC
It is x86_64-pc-linux-gnu == host == target == build.

To what I see in the root Makefile (copied below) at the end of the build files in stage2 and stage3 are compared with `cmp', which fails, if one file has debugging information and the other does not, even if both files have identical text/data/bss sections.
do-compare = cmp --ignore-initial=16 $$f1 $$f2

        @r=`${PWD_COMMAND}`; export r; \
        s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
        if test -f stage2-lean; then \
          echo Cannot compare object files as stage 2 was deleted.; \
          exit 0; \
        fi; \
        : $(MAKE); $(stage); \
        rm -f .bad_compare; \
        echo Comparing stages 2 and 3; \
        sed=`echo stage3 | sed 's,^stage,,;s,.,.,g'`; \
        files=`find stage3-* -name "*$(objext)" -print | \                                                                                        
                 sed -n s,^stage$$sed-,,p`; \
        for file in $${files}; do \
          f1=$$r/stage2-$$file; f2=$$r/stage3-$$file; \
          if test ! -f $$f1; then continue; fi; \
          $(do-compare) > /dev/null 2>&1; \
          if test $$? -eq 1; then \
            case $$file in \
              gcc/cc*-checksum$(objext) | gcc/ada/*tools/*) \
                echo warning: $$file differs ;; \
              *) \
                echo $$file differs >> .bad_compare ;; \
            esac; \
          fi; \
        done; \
        if [ -f .bad_compare ]; then \
          echo "Bootstrap comparison failure!"; \
          cat .bad_compare; \
          exit 1; \
        else \
          echo Comparison successful.; \
        fi; \
        $(STAMP) compare
        if $(LEAN); then \
          rm -rf stage2-*; \
          $(STAMP) stage2-lean; \
Comment 3 Andrew Pinski 2015-08-08 14:35:31 UTC
It should have stripped out the debugging info before doing the cmp.

That is do-compare gets to be:
do-compare = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
From bootstrap-debug.mk.
Comment 4 Markus Trippelsdorf 2015-08-08 14:38:35 UTC
Of course the object files are stripped before the comparison.
See: contrib/compare-debug script.

You should open a new bug with the list of files that differ.
Comment 5 Дилян Палаузов 2015-08-08 15:35:57 UTC
If do-compare in /Makefile.in is substituted with "$(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2" from "config/bootstrap-debug-big.mk" or "config/bootstrap-debug-lib.mk" or "config/bootstrap-debug.mk", then comparing files ignores debug information.  However in my case, do-compare is substituted with "cmp --ignore-initial=16 $$f1 $$f2" from config/acx.m4 . Effectively the latter executes
  gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
and ./configure contains:

configure-5351-$as_echo_n "checking how to compare bootstrapped objects... " >&6; }
configure:5352:if test "${gcc_cv_prog_cmp_skip+set}" = set; then :
configure-5353-  $as_echo_n "(cached) " >&6
configure-5355-   echo abfoo >t1
configure-5356-  echo cdfoo >t2
configure:5357:  gcc_cv_prog_cmp_skip='tail +16c $$f1 > tmp-foo1; tail +16c $$f2 > tmp-foo2; cmp tmp-foo1 tmp-foo2'
configure-5358-  if cmp t1 t2 2 2 > /dev/null 2>&1; then
configure-5359-    if cmp t1 t2 1 1 > /dev/null 2>&1; then
configure-5360-      :
configure-5361-    else
configure:5362:      gcc_cv_prog_cmp_skip='cmp $$f1 $$f2 16 16'
configure-5363-    fi
configure-5364-  fi
configure-5365-  if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
configure-5366-    if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
configure-5367-      :
configure-5368-    else
configure:5369:      gcc_cv_prog_cmp_skip='cmp --ignore-initial=16 $$f1 $$f2'
configure-5370-    fi
configure-5371-  fi
configure-5372-  rm t1 t2
configure:5375:{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_prog_cmp_skip" >&5
configure:5376:$as_echo "$gcc_cv_prog_cmp_skip" >&6; }

after ./configure config.log contains:

configure:5350: checking how to compare bootstrapped objects
configure:5375: result: cmp --ignore-initial=16 $$f1 $$f2
do_compare='cmp --ignore-initial=16 $$f1 $$f2'

and config.status contains:
S["do_compare"]="cmp --ignore-initial=16 $$f1 $$f2"

So the problem is why do_compare is cmp and not contrib/compare-debug .
Comment 6 Bernd Schmidt 2015-12-17 00:36:13 UTC
This PR is not making much sense to me. The autodetection seems right, but you're quoting config/bootstrap-debug.mk, which also contains an override for do-compare, and your configure line does not include an --enable-build-config. So the contents of that file should be entirely irrelevant. A bootstrap with --enable-build-config=bootstrap-debug works for me.

Please verify you do not have local changes, ensure you start from a clean build directory, and try again.

I suspect some kind of pilot error, so closing for the moment. Feel free to add more information if you still have the issue.