diff mbox

Re-use cc1-checksum.c for stage-final

Message ID alpine.LSU.2.11.1604281043180.13384@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener April 28, 2016, 8:49 a.m. UTC
The following prototype patch re-uses cc1-checksum.c from the
previous stage when compiling stage-final.  This eventually
allows to compare cc1 from the last two stages to fix the
lack of a true comparison when doing LTO bootstrap (it
compiles LTO bytecode from the compile-stage there, not the
final optimization result).

Bootstrapped on x86_64-unknown-linux-gnu.

When stripping gcc/cc1 and prev-gcc/cc1 after the bootstrap
they now compare identical (with LTO bootstrap it should
not require stripping as that doesn't do a bootstrap-debug AFAIK).

Is sth like this acceptable?  (consider it also done for cp/Make-lang.in)

In theory we can compare all stage1 languages but I guess comparing
the required ones for a LTO bootstrap, cc1, cc1plus and lto1 would
be sufficient (or even just comparing one binary in which case
comparing lto1 would not require any patches).

This also gets rid of the annoying warning that cc1-checksum.o
differs (obviously).

Thanks,
Richard.

2016-04-28  Richard Biener  <rguenther@suse.de>

	c/
	* Make-lang.in (cc1-checksum.c): For stage-final re-use
	the checksum from the previous stage.

Comments

Jeff Law April 28, 2016, 10:20 p.m. UTC | #1
On 04/28/2016 02:49 AM, Richard Biener wrote:
>
> The following prototype patch re-uses cc1-checksum.c from the
> previous stage when compiling stage-final.  This eventually
> allows to compare cc1 from the last two stages to fix the
> lack of a true comparison when doing LTO bootstrap (it
> compiles LTO bytecode from the compile-stage there, not the
> final optimization result).
>
> Bootstrapped on x86_64-unknown-linux-gnu.
>
> When stripping gcc/cc1 and prev-gcc/cc1 after the bootstrap
> they now compare identical (with LTO bootstrap it should
> not require stripping as that doesn't do a bootstrap-debug AFAIK).
>
> Is sth like this acceptable?  (consider it also done for cp/Make-lang.in)
>
> In theory we can compare all stage1 languages but I guess comparing
> the required ones for a LTO bootstrap, cc1, cc1plus and lto1 would
> be sufficient (or even just comparing one binary in which case
> comparing lto1 would not require any patches).
>
> This also gets rid of the annoying warning that cc1-checksum.o
> differs (obviously).
>
> Thanks,
> Richard.
>
> 2016-04-28  Richard Biener  <rguenther@suse.de>
>
> 	c/
> 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
> 	the checksum from the previous stage.
I won't object if you add a comment into the fragment indicating why 
you're doing this.

jeff
Richard Biener April 29, 2016, 11:36 a.m. UTC | #2
On Thu, 28 Apr 2016, Jeff Law wrote:

> On 04/28/2016 02:49 AM, Richard Biener wrote:
> > 
> > The following prototype patch re-uses cc1-checksum.c from the
> > previous stage when compiling stage-final.  This eventually
> > allows to compare cc1 from the last two stages to fix the
> > lack of a true comparison when doing LTO bootstrap (it
> > compiles LTO bytecode from the compile-stage there, not the
> > final optimization result).
> > 
> > Bootstrapped on x86_64-unknown-linux-gnu.
> > 
> > When stripping gcc/cc1 and prev-gcc/cc1 after the bootstrap
> > they now compare identical (with LTO bootstrap it should
> > not require stripping as that doesn't do a bootstrap-debug AFAIK).
> > 
> > Is sth like this acceptable?  (consider it also done for cp/Make-lang.in)
> > 
> > In theory we can compare all stage1 languages but I guess comparing
> > the required ones for a LTO bootstrap, cc1, cc1plus and lto1 would
> > be sufficient (or even just comparing one binary in which case
> > comparing lto1 would not require any patches).
> > 
> > This also gets rid of the annoying warning that cc1-checksum.o
> > differs (obviously).
> > 
> > Thanks,
> > Richard.
> > 
> > 2016-04-28  Richard Biener  <rguenther@suse.de>
> > 
> > 	c/
> > 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
> > 	the checksum from the previous stage.
> I won't object if you add a comment into the fragment indicating why you're
> doing this.

So the following is a complete patch (not considering people may
add objc or obj-c++ to stage1 languages).  Build with --disable-bootstrap,
bootstrapped and profilebootstrapped with verifying it works as
intended (looks like we don't compare with profiledbootstrap - huh,
we're building stagefeedback only once)

Ok for trunk?

Step 2 will now be to figure out how to also compare cc1 (for example)
when using bootstrap-lto ... (we don't want to do this unconditionally
as it is a waste of time when the objects are not only LTO bytecode).

Thanks,
Richard.

2016-04-29  Richard Biener  <rguenther@suse.de>

	c/
	* Make-lang.in (cc1-checksum.c): For stage-final re-use
	the checksum from the previous stage.

	cp/
	* Make-lang.in (cc1plus-checksum.c): For stage-final re-use
	the checksum from the previous stage.

Index: gcc/c/Make-lang.in
===================================================================
*** gcc/c/Make-lang.in	(revision 235623)
--- gcc/c/Make-lang.in	(working copy)
*************** c_OBJS = $(C_OBJS) cc1-checksum.o c/gccs
*** 61,71 ****
  c-warn = $(STRICT_WARN)
  
  # compute checksum over all object files and the options
  cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \
  	$(C_OBJS) $(BACKEND) $(LIBDEPS) 
! 	build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
                       checksum-options > cc1-checksum.c.tmp && 		 \
! 	$(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c
  
  cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS)
  	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
--- 61,78 ----
  c-warn = $(STRICT_WARN)
  
  # compute checksum over all object files and the options
+ # re-use the checksum from the prev-final stage so it passes
+ # the bootstrap comparison and allows comparing of the cc1 binary
  cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \
  	$(C_OBJS) $(BACKEND) $(LIBDEPS) 
! 	if [ -f ../stage_final ] \
! 	   && cmp -s ../stage_current ../stage_final; then \
! 	  cp ../prev-gcc/cc1-checksum.c cc1-checksum.c; \
! 	else \
! 	  build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
                       checksum-options > cc1-checksum.c.tmp && 		 \
! 	  $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c; \
! 	fi
  
  cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS)
  	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
Index: gcc/cp/Make-lang.in
===================================================================
*** gcc/cp/Make-lang.in	(revision 235623)
--- gcc/cp/Make-lang.in	(working copy)
*************** c++_OBJS = $(CXX_OBJS) cc1plus-checksum.
*** 90,100 ****
  cp-warn = $(STRICT_WARN)
  
  # compute checksum over all object files and the options
  cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
  	$(CXX_OBJS) $(BACKEND) $(LIBDEPS) 
! 	build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
                       checksum-options > cc1plus-checksum.c.tmp &&	   \
! 	$(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c
  
  cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
  	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
--- 90,107 ----
  cp-warn = $(STRICT_WARN)
  
  # compute checksum over all object files and the options
+ # re-use the checksum from the prev-final stage so it passes
+ # the bootstrap comparison and allows comparing of the cc1 binary
  cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
  	$(CXX_OBJS) $(BACKEND) $(LIBDEPS) 
! 	if [ -f ../stage_final ] \
! 	   && cmp -s ../stage_current ../stage_final; then \
! 	   cp ../prev-gcc/cc1plus-checksum.c cc1plus-checksum.c; \
! 	else \
! 	  build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
                       checksum-options > cc1plus-checksum.c.tmp &&	   \
! 	  $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c; \
! 	fi
  
  cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
  	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
Jeff Law May 2, 2016, 3:55 p.m. UTC | #3
On 04/29/2016 05:36 AM, Richard Biener wrote:
> On Thu, 28 Apr 2016, Jeff Law wrote:
>
>> On 04/28/2016 02:49 AM, Richard Biener wrote:
>>>
>>> The following prototype patch re-uses cc1-checksum.c from the
>>> previous stage when compiling stage-final.  This eventually
>>> allows to compare cc1 from the last two stages to fix the
>>> lack of a true comparison when doing LTO bootstrap (it
>>> compiles LTO bytecode from the compile-stage there, not the
>>> final optimization result).
>>>
>>> Bootstrapped on x86_64-unknown-linux-gnu.
>>>
>>> When stripping gcc/cc1 and prev-gcc/cc1 after the bootstrap
>>> they now compare identical (with LTO bootstrap it should
>>> not require stripping as that doesn't do a bootstrap-debug AFAIK).
>>>
>>> Is sth like this acceptable?  (consider it also done for cp/Make-lang.in)
>>>
>>> In theory we can compare all stage1 languages but I guess comparing
>>> the required ones for a LTO bootstrap, cc1, cc1plus and lto1 would
>>> be sufficient (or even just comparing one binary in which case
>>> comparing lto1 would not require any patches).
>>>
>>> This also gets rid of the annoying warning that cc1-checksum.o
>>> differs (obviously).
>>>
>>> Thanks,
>>> Richard.
>>>
>>> 2016-04-28  Richard Biener  <rguenther@suse.de>
>>>
>>> 	c/
>>> 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
>>> 	the checksum from the previous stage.
>> I won't object if you add a comment into the fragment indicating why you're
>> doing this.
>
> So the following is a complete patch (not considering people may
> add objc or obj-c++ to stage1 languages).  Build with --disable-bootstrap,
> bootstrapped and profilebootstrapped with verifying it works as
> intended (looks like we don't compare with profiledbootstrap - huh,
> we're building stagefeedback only once)
>
> Ok for trunk?
>
> Step 2 will now be to figure out how to also compare cc1 (for example)
> when using bootstrap-lto ... (we don't want to do this unconditionally
> as it is a waste of time when the objects are not only LTO bytecode).
>
> Thanks,
> Richard.
>
> 2016-04-29  Richard Biener  <rguenther@suse.de>
>
> 	c/
> 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
> 	the checksum from the previous stage.
>
> 	cp/
> 	* Make-lang.in (cc1plus-checksum.c): For stage-final re-use
> 	the checksum from the previous stage.
LGTM.
jeff
Richard Biener May 3, 2016, 8:18 a.m. UTC | #4
On Mon, 2 May 2016, Jeff Law wrote:

> On 04/29/2016 05:36 AM, Richard Biener wrote:
> > On Thu, 28 Apr 2016, Jeff Law wrote:
> > 
> > > On 04/28/2016 02:49 AM, Richard Biener wrote:
> > > > 
> > > > The following prototype patch re-uses cc1-checksum.c from the
> > > > previous stage when compiling stage-final.  This eventually
> > > > allows to compare cc1 from the last two stages to fix the
> > > > lack of a true comparison when doing LTO bootstrap (it
> > > > compiles LTO bytecode from the compile-stage there, not the
> > > > final optimization result).
> > > > 
> > > > Bootstrapped on x86_64-unknown-linux-gnu.
> > > > 
> > > > When stripping gcc/cc1 and prev-gcc/cc1 after the bootstrap
> > > > they now compare identical (with LTO bootstrap it should
> > > > not require stripping as that doesn't do a bootstrap-debug AFAIK).
> > > > 
> > > > Is sth like this acceptable?  (consider it also done for
> > > > cp/Make-lang.in)
> > > > 
> > > > In theory we can compare all stage1 languages but I guess comparing
> > > > the required ones for a LTO bootstrap, cc1, cc1plus and lto1 would
> > > > be sufficient (or even just comparing one binary in which case
> > > > comparing lto1 would not require any patches).
> > > > 
> > > > This also gets rid of the annoying warning that cc1-checksum.o
> > > > differs (obviously).
> > > > 
> > > > Thanks,
> > > > Richard.
> > > > 
> > > > 2016-04-28  Richard Biener  <rguenther@suse.de>
> > > > 
> > > > 	c/
> > > > 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
> > > > 	the checksum from the previous stage.
> > > I won't object if you add a comment into the fragment indicating why
> > > you're
> > > doing this.
> > 
> > So the following is a complete patch (not considering people may
> > add objc or obj-c++ to stage1 languages).  Build with --disable-bootstrap,
> > bootstrapped and profilebootstrapped with verifying it works as
> > intended (looks like we don't compare with profiledbootstrap - huh,
> > we're building stagefeedback only once)
> > 
> > Ok for trunk?
> > 
> > Step 2 will now be to figure out how to also compare cc1 (for example)
> > when using bootstrap-lto ... (we don't want to do this unconditionally
> > as it is a waste of time when the objects are not only LTO bytecode).
> > 
> > Thanks,
> > Richard.
> > 
> > 2016-04-29  Richard Biener  <rguenther@suse.de>
> > 
> > 	c/
> > 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
> > 	the checksum from the previous stage.
> > 
> > 	cp/
> > 	* Make-lang.in (cc1plus-checksum.c): For stage-final re-use
> > 	the checksum from the previous stage.
> LGTM.
> jeff

Thanks - applied as rev. 235804.

I'll now play with some way to add additional compare objects.  Thinking
of adding sth like

EXTRA_COMPARE_OBJS = lto1 cc1 cc1plus

to bootstrap-lto.mk for example.

Richard.
Richard Biener May 3, 2016, 10:32 a.m. UTC | #5
On Tue, 3 May 2016, Richard Biener wrote:

> On Mon, 2 May 2016, Jeff Law wrote:
> 
> > On 04/29/2016 05:36 AM, Richard Biener wrote:
> > > On Thu, 28 Apr 2016, Jeff Law wrote:
> > > 
> > > > On 04/28/2016 02:49 AM, Richard Biener wrote:
> > > > > 
> > > > > The following prototype patch re-uses cc1-checksum.c from the
> > > > > previous stage when compiling stage-final.  This eventually
> > > > > allows to compare cc1 from the last two stages to fix the
> > > > > lack of a true comparison when doing LTO bootstrap (it
> > > > > compiles LTO bytecode from the compile-stage there, not the
> > > > > final optimization result).
> > > > > 
> > > > > Bootstrapped on x86_64-unknown-linux-gnu.
> > > > > 
> > > > > When stripping gcc/cc1 and prev-gcc/cc1 after the bootstrap
> > > > > they now compare identical (with LTO bootstrap it should
> > > > > not require stripping as that doesn't do a bootstrap-debug AFAIK).
> > > > > 
> > > > > Is sth like this acceptable?  (consider it also done for
> > > > > cp/Make-lang.in)
> > > > > 
> > > > > In theory we can compare all stage1 languages but I guess comparing
> > > > > the required ones for a LTO bootstrap, cc1, cc1plus and lto1 would
> > > > > be sufficient (or even just comparing one binary in which case
> > > > > comparing lto1 would not require any patches).
> > > > > 
> > > > > This also gets rid of the annoying warning that cc1-checksum.o
> > > > > differs (obviously).
> > > > > 
> > > > > Thanks,
> > > > > Richard.
> > > > > 
> > > > > 2016-04-28  Richard Biener  <rguenther@suse.de>
> > > > > 
> > > > > 	c/
> > > > > 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
> > > > > 	the checksum from the previous stage.
> > > > I won't object if you add a comment into the fragment indicating why
> > > > you're
> > > > doing this.
> > > 
> > > So the following is a complete patch (not considering people may
> > > add objc or obj-c++ to stage1 languages).  Build with --disable-bootstrap,
> > > bootstrapped and profilebootstrapped with verifying it works as
> > > intended (looks like we don't compare with profiledbootstrap - huh,
> > > we're building stagefeedback only once)
> > > 
> > > Ok for trunk?
> > > 
> > > Step 2 will now be to figure out how to also compare cc1 (for example)
> > > when using bootstrap-lto ... (we don't want to do this unconditionally
> > > as it is a waste of time when the objects are not only LTO bytecode).
> > > 
> > > Thanks,
> > > Richard.
> > > 
> > > 2016-04-29  Richard Biener  <rguenther@suse.de>
> > > 
> > > 	c/
> > > 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
> > > 	the checksum from the previous stage.
> > > 
> > > 	cp/
> > > 	* Make-lang.in (cc1plus-checksum.c): For stage-final re-use
> > > 	the checksum from the previous stage.
> > LGTM.
> > jeff
> 
> Thanks - applied as rev. 235804.
> 
> I'll now play with some way to add additional compare objects.  Thinking
> of adding sth like
> 
> EXTRA_COMPARE_OBJS = lto1 cc1 cc1plus
> 
> to bootstrap-lto.mk for example.

To my surprise this works.

LTO bootstrapped on x86_64-unknown-linux-gnu - I've added an additional
echo comparing $$f1 $$f2 which then shows

...
comparing /abuild/rguenther/obj/stage2-zlib/libz_a-inftrees.o 
/abuild/rguenther/obj/stage3-zlib/libz_a-inftrees.o
comparing /abuild/rguenther/obj/stage2-cc1 
/abuild/rguenther/obj/stage3-cc1
comparing /abuild/rguenther/obj/stage2-cc1plus 
/abuild/rguenther/obj/stage3-cc1plus
comparing /abuild/rguenther/obj/stage2-lto1 
/abuild/rguenther/obj/stage3-lto1
Comparison successful.

Ok for trunk?  This probably slows down the compare phase for
LTO bootstrap a bit (and LTO IL of the .o files is still compared).
I'm also not 100% sure that what works on .o files works on
executables on all targets (hmm, and I suppose I might miss
some exec-suffix?  Ah, there is $(exeext) but not available in
the toplevel makefile yet.).

Thanks,
Richard.

2016-05-03  Richard Biener  <rguenther@suse.de>

	* Makefile.tpl: Also compare EXTRA_COMPARE_OBJS.
	* Makefile.in: Regenerate.
	
	config/
	* bootstrap-lto.mk: Add cc1, cc1plus and lto1 to EXTRA_COMPARE_OBJS.

Index: Makefile.tpl
===================================================================
*** Makefile.tpl	(revision 235804)
--- Makefile.tpl	(working copy)
*************** do-clean: clean-stage[+id+]
*** 1630,1636 ****
          sed=`echo stage[+id+] | sed 's,^stage,,;s,.,.,g'`; \
  	files=`find stage[+id+]-* -name "*$(objext)" -print | \
  		 sed -n s,^stage$$sed-,,p`; \
! 	for file in $${files}; do \
  	  f1=$$r/stage[+prev+]-$$file; f2=$$r/stage[+id+]-$$file; \
  	  if test ! -f $$f1; then continue; fi; \
  	  $(do-[+compare-target+]) > /dev/null 2>&1; \
--- 1630,1636 ----
          sed=`echo stage[+id+] | sed 's,^stage,,;s,.,.,g'`; \
  	files=`find stage[+id+]-* -name "*$(objext)" -print | \
  		 sed -n s,^stage$$sed-,,p`; \
! 	for file in $${files} $(EXTRA_COMPARE_OBJS); do \
  	  f1=$$r/stage[+prev+]-$$file; f2=$$r/stage[+id+]-$$file; \
  	  if test ! -f $$f1; then continue; fi; \
  	  $(do-[+compare-target+]) > /dev/null 2>&1; \
Index: config/bootstrap-lto.mk
===================================================================
*** config/bootstrap-lto.mk	(revision 235804)
--- config/bootstrap-lto.mk	(working copy)
*************** LTO_RANLIB = $$r/$(HOST_SUBDIR)/prev-gcc
*** 11,13 ****
--- 11,15 ----
  LTO_EXPORTS = AR="$(LTO_AR)"; export AR; \
  	      RANLIB="$(LTO_RANLIB)"; export RANLIB;
  LTO_FLAGS_TO_PASS = AR="$(LTO_AR)" RANLIB="$(LTO_RANLIB)"
+ 
+ EXTRA_COMPARE_OBJS = cc1 cc1plus lto1
Index: Makefile.in
===================================================================
*** Makefile.in	(revision 235804)
--- Makefile.in	(working copy)
*************** compare:
*** 48785,48791 ****
          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; \
--- 48785,48791 ----
          sed=`echo stage3 | sed 's,^stage,,;s,.,.,g'`; \
  	files=`find stage3-* -name "*$(objext)" -print | \
  		 sed -n s,^stage$$sed-,,p`; \
! 	for file in $${files} $(EXTRA_COMPARE_OBJS); do \
  	  f1=$$r/stage2-$$file; f2=$$r/stage3-$$file; \
  	  if test ! -f $$f1; then continue; fi; \
  	  $(do-compare) > /dev/null 2>&1; \
*************** compare3:
*** 49183,49189 ****
          sed=`echo stage4 | sed 's,^stage,,;s,.,.,g'`; \
  	files=`find stage4-* -name "*$(objext)" -print | \
  		 sed -n s,^stage$$sed-,,p`; \
! 	for file in $${files}; do \
  	  f1=$$r/stage3-$$file; f2=$$r/stage4-$$file; \
  	  if test ! -f $$f1; then continue; fi; \
  	  $(do-compare3) > /dev/null 2>&1; \
--- 49183,49189 ----
          sed=`echo stage4 | sed 's,^stage,,;s,.,.,g'`; \
  	files=`find stage4-* -name "*$(objext)" -print | \
  		 sed -n s,^stage$$sed-,,p`; \
! 	for file in $${files} $(EXTRA_COMPARE_OBJS); do \
  	  f1=$$r/stage3-$$file; f2=$$r/stage4-$$file; \
  	  if test ! -f $$f1; then continue; fi; \
  	  $(do-compare3) > /dev/null 2>&1; \
Jeff Law May 18, 2016, 10:01 p.m. UTC | #6
On 05/03/2016 04:32 AM, Richard Biener wrote:
> On Tue, 3 May 2016, Richard Biener wrote:
>
>> On Mon, 2 May 2016, Jeff Law wrote:
>>
>>> On 04/29/2016 05:36 AM, Richard Biener wrote:
>>>> On Thu, 28 Apr 2016, Jeff Law wrote:
>>>>
>>>>> On 04/28/2016 02:49 AM, Richard Biener wrote:
>>>>>>
>>>>>> The following prototype patch re-uses cc1-checksum.c from the
>>>>>> previous stage when compiling stage-final.  This eventually
>>>>>> allows to compare cc1 from the last two stages to fix the
>>>>>> lack of a true comparison when doing LTO bootstrap (it
>>>>>> compiles LTO bytecode from the compile-stage there, not the
>>>>>> final optimization result).
>>>>>>
>>>>>> Bootstrapped on x86_64-unknown-linux-gnu.
>>>>>>
>>>>>> When stripping gcc/cc1 and prev-gcc/cc1 after the bootstrap
>>>>>> they now compare identical (with LTO bootstrap it should
>>>>>> not require stripping as that doesn't do a bootstrap-debug AFAIK).
>>>>>>
>>>>>> Is sth like this acceptable?  (consider it also done for
>>>>>> cp/Make-lang.in)
>>>>>>
>>>>>> In theory we can compare all stage1 languages but I guess comparing
>>>>>> the required ones for a LTO bootstrap, cc1, cc1plus and lto1 would
>>>>>> be sufficient (or even just comparing one binary in which case
>>>>>> comparing lto1 would not require any patches).
>>>>>>
>>>>>> This also gets rid of the annoying warning that cc1-checksum.o
>>>>>> differs (obviously).
>>>>>>
>>>>>> Thanks,
>>>>>> Richard.
>>>>>>
>>>>>> 2016-04-28  Richard Biener  <rguenther@suse.de>
>>>>>>
>>>>>> 	c/
>>>>>> 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
>>>>>> 	the checksum from the previous stage.
>>>>> I won't object if you add a comment into the fragment indicating why
>>>>> you're
>>>>> doing this.
>>>>
>>>> So the following is a complete patch (not considering people may
>>>> add objc or obj-c++ to stage1 languages).  Build with --disable-bootstrap,
>>>> bootstrapped and profilebootstrapped with verifying it works as
>>>> intended (looks like we don't compare with profiledbootstrap - huh,
>>>> we're building stagefeedback only once)
>>>>
>>>> Ok for trunk?
>>>>
>>>> Step 2 will now be to figure out how to also compare cc1 (for example)
>>>> when using bootstrap-lto ... (we don't want to do this unconditionally
>>>> as it is a waste of time when the objects are not only LTO bytecode).
>>>>
>>>> Thanks,
>>>> Richard.
>>>>
>>>> 2016-04-29  Richard Biener  <rguenther@suse.de>
>>>>
>>>> 	c/
>>>> 	* Make-lang.in (cc1-checksum.c): For stage-final re-use
>>>> 	the checksum from the previous stage.
>>>>
>>>> 	cp/
>>>> 	* Make-lang.in (cc1plus-checksum.c): For stage-final re-use
>>>> 	the checksum from the previous stage.
>>> LGTM.
>>> jeff
>>
>> Thanks - applied as rev. 235804.
>>
>> I'll now play with some way to add additional compare objects.  Thinking
>> of adding sth like
>>
>> EXTRA_COMPARE_OBJS = lto1 cc1 cc1plus
>>
>> to bootstrap-lto.mk for example.
>
> To my surprise this works.
>
> LTO bootstrapped on x86_64-unknown-linux-gnu - I've added an additional
> echo comparing $$f1 $$f2 which then shows
>
> ...
> comparing /abuild/rguenther/obj/stage2-zlib/libz_a-inftrees.o
> /abuild/rguenther/obj/stage3-zlib/libz_a-inftrees.o
> comparing /abuild/rguenther/obj/stage2-cc1
> /abuild/rguenther/obj/stage3-cc1
> comparing /abuild/rguenther/obj/stage2-cc1plus
> /abuild/rguenther/obj/stage3-cc1plus
> comparing /abuild/rguenther/obj/stage2-lto1
> /abuild/rguenther/obj/stage3-lto1
> Comparison successful.
>
> Ok for trunk?  This probably slows down the compare phase for
> LTO bootstrap a bit (and LTO IL of the .o files is still compared).
> I'm also not 100% sure that what works on .o files works on
> executables on all targets (hmm, and I suppose I might miss
> some exec-suffix?  Ah, there is $(exeext) but not available in
> the toplevel makefile yet.).
>
> Thanks,
> Richard.
>
> 2016-05-03  Richard Biener  <rguenther@suse.de>
>
> 	* Makefile.tpl: Also compare EXTRA_COMPARE_OBJS.
> 	* Makefile.in: Regenerate.
> 	
> 	config/
> 	* bootstrap-lto.mk: Add cc1, cc1plus and lto1 to EXTRA_COMPARE_OBJS.
LGTM.
jeff
diff mbox

Patch

Index: gcc/c/Make-lang.in
===================================================================
--- gcc/c/Make-lang.in	(revision 235499)
+++ gcc/c/Make-lang.in	(working copy)
@@ -63,9 +63,14 @@  c-warn = $(STRICT_WARN)
 # compute checksum over all object files and the options
 cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \
 	$(C_OBJS) $(BACKEND) $(LIBDEPS) 
-	build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
+	if [ -f ../stage_final ] \
+	   && cmp -s ../stage_current ../stage_final; then \
+	  cp ../prev-gcc/cc1-checksum.c cc1-checksum.c; \
+	else \
+	  build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
                      checksum-options > cc1-checksum.c.tmp && 		 \
-	$(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c
+	  $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c; \
+	fi
 
 cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS)
 	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \