public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: Fix Solaris bootstraps across midnight
@ 2023-04-11  8:12 Jakub Jelinek
  2023-04-11 22:06 ` Nathan Sidwell
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2023-04-11  8:12 UTC (permalink / raw)
  To: Jason Merrill, Nathan Sidwell; +Cc: gcc-patches

Hi!

When working on the PR109040 fix, I wanted to test it on some
WORD_REGISTER_OPERATIONS target and tried sparc-solaris on GCC Farm.
My bootstrap failed in comparison failure on cp/module.o, because
Solaris date doesn't support the -r option and one stage's cp/module.o
was built before midnight and next stage's cp/module.o after midnight,
so they had different -DMODULE_VERSION= value.

Now, I think the advice (don't bootstrap at midnight) is something
we shouldn't have, so the following patch stores the module version
(still generated through the same way, date -r cp/module.cc
if it works, otherwise just date) into a temporary file, makes sure
that temporary file is updated when cp/module.cc source is updated
and when date -r doesn't work copies file from previous stage
if it is newer than cp/module.cc.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2023-04-11  Jakub Jelinek  <jakub@redhat.com>

	* Make-lang.in (s-cp-module-version): New target.
	(cp/module.o): Depend on it.
	(MODULE_VERSION): Remove variable.
	(CFLAGS-cp/module.o): For -DMODULE_VERSION= argument just
	cat s-cp-module-version.

--- gcc/cp/Make-lang.in.jj	2023-01-16 11:52:16.057734447 +0100
+++ gcc/cp/Make-lang.in	2023-04-06 10:03:34.344469067 +0200
@@ -59,12 +59,21 @@ CFLAGS-cp/module.o += -DHOST_MACHINE=\"$
 
 # In non-release builds, use a date-related module version.
 ifneq ($(DEVPHASE_c),)
-# Some date's don't grok 'r', if so, simply use today's
-# date (don't bootstrap at midnight).
-MODULE_VERSION := $(shell date -r $(srcdir)/cp/module.cc '+%y%m%d-%H%M' \
-  2>/dev/null || date '+%y%m%d-0000' 2>/dev/null || echo 0)
-
-CFLAGS-cp/module.o += -DMODULE_VERSION='($(subst -,,$(MODULE_VERSION))U)'
+# Some date's don't grok 'r', if so, simply use today's date,
+# but use date from previous stage if bootstrapping to avoid breaking
+# bootstraps across midnight.
+s-cp-module-version: $(srcdir)/cp/module.cc
+	MODULE_VERSION=`if date -r $(srcdir)/cp/module.cc '+%y%m%d%H%M' \
+			  2>/dev/null; then :; \
+			elif test ../prev-gcc/s-cp-module-version -nt \
+			       $(srcdir)/cp/module.cc; then \
+			  cat ../prev-gcc/s-cp-module-version; \
+			else \
+			  date '+%y%m%d0000' 2>/dev/null; \
+			fi`; \
+	echo $${MODULE_VERSION}U > s-cp-module-version
+cp/module.o: s-cp-module-version
+CFLAGS-cp/module.o += -DMODULE_VERSION='$(shell cat s-cp-module-version)'
 endif
 
 # Create the compiler driver for g++.

	Jakub


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] c++: Fix Solaris bootstraps across midnight
  2023-04-11  8:12 [PATCH] c++: Fix Solaris bootstraps across midnight Jakub Jelinek
@ 2023-04-11 22:06 ` Nathan Sidwell
  2023-04-11 22:55   ` Nathan Sidwell
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Sidwell @ 2023-04-11 22:06 UTC (permalink / raw)
  To: Jakub Jelinek, Jason Merrill; +Cc: gcc-patches

On 4/11/23 04:12, Jakub Jelinek wrote:
> Hi!
> 
> When working on the PR109040 fix, I wanted to test it on some
> WORD_REGISTER_OPERATIONS target and tried sparc-solaris on GCC Farm.
> My bootstrap failed in comparison failure on cp/module.o, because
> Solaris date doesn't support the -r option and one stage's cp/module.o
> was built before midnight and next stage's cp/module.o after midnight,
> so they had different -DMODULE_VERSION= value.
> 
> Now, I think the advice (don't bootstrap at midnight) is something
> we shouldn't have, so the following patch stores the module version
> (still generated through the same way, date -r cp/module.cc
> if it works, otherwise just date) into a temporary file, makes sure
> that temporary file is updated when cp/module.cc source is updated
> and when date -r doesn't work copies file from previous stage
> if it is newer than cp/module.cc.

looks good.  one could tweak it slightly to avoid the MODULE_VERSION variable 
(but then I was the original lazy one!) Something like:

....
s-cp-module-version: $(srcdir)/cp/module.cc
	if date -r $(srcdir)/cp/module.cc '+%y%m%d%H%MU' \
	  2>/dev/null >$@; then :; \
	elif test ../prev-gcc/$@ -nt \
	  $(srcdir)/cp/module.cc; then \
	  cp ../prev-gcc/$@ $@; \
	else \
	  date '+%y%m%d0000U' 2>/dev/null >$@; \
	fi`; \
....

nathan

-- 
Nathan Sidwell


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] c++: Fix Solaris bootstraps across midnight
  2023-04-11 22:06 ` Nathan Sidwell
@ 2023-04-11 22:55   ` Nathan Sidwell
  0 siblings, 0 replies; 3+ messages in thread
From: Nathan Sidwell @ 2023-04-11 22:55 UTC (permalink / raw)
  To: Jakub Jelinek, Jason Merrill; +Cc: gcc-patches

Jakub,
for avoidance of doubt, your version is fine.

nathan


On 4/11/23 18:06, Nathan Sidwell wrote:
> On 4/11/23 04:12, Jakub Jelinek wrote:
>> Hi!
>>
>> When working on the PR109040 fix, I wanted to test it on some
>> WORD_REGISTER_OPERATIONS target and tried sparc-solaris on GCC Farm.
>> My bootstrap failed in comparison failure on cp/module.o, because
>> Solaris date doesn't support the -r option and one stage's cp/module.o
>> was built before midnight and next stage's cp/module.o after midnight,
>> so they had different -DMODULE_VERSION= value.
>>
>> Now, I think the advice (don't bootstrap at midnight) is something
>> we shouldn't have, so the following patch stores the module version
>> (still generated through the same way, date -r cp/module.cc
>> if it works, otherwise just date) into a temporary file, makes sure
>> that temporary file is updated when cp/module.cc source is updated
>> and when date -r doesn't work copies file from previous stage
>> if it is newer than cp/module.cc.
> 
> looks good.  one could tweak it slightly to avoid the MODULE_VERSION variable 
> (but then I was the original lazy one!) Something like:
> 
> ....
> s-cp-module-version: $(srcdir)/cp/module.cc
>      if date -r $(srcdir)/cp/module.cc '+%y%m%d%H%MU' \
>        2>/dev/null >$@; then :; \
>      elif test ../prev-gcc/$@ -nt \
>        $(srcdir)/cp/module.cc; then \
>        cp ../prev-gcc/$@ $@; \
>      else \
>        date '+%y%m%d0000U' 2>/dev/null >$@; \
>      fi`; \
> ....
> 
> nathan
> 

-- 
Nathan Sidwell


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-11 22:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11  8:12 [PATCH] c++: Fix Solaris bootstraps across midnight Jakub Jelinek
2023-04-11 22:06 ` Nathan Sidwell
2023-04-11 22:55   ` Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).