aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/Make-lang.in
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-04-12 16:22:28 +0200
committerJakub Jelinek <jakub@redhat.com>2023-04-12 16:22:28 +0200
commit56529056cb42baa382c40de7d239d02dbf72c94f (patch)
treea72043e954c209f76bde8e534d79b82412c8a392 /gcc/cp/Make-lang.in
parent14f0ea22413fe3e64306c57fbfd2ae7b5769c1a1 (diff)
downloadgcc-56529056cb42baa382c40de7d239d02dbf72c94f.zip
gcc-56529056cb42baa382c40de7d239d02dbf72c94f.tar.gz
gcc-56529056cb42baa382c40de7d239d02dbf72c94f.tar.bz2
c++: Fix Solaris bootstraps across midnight
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. 2023-04-12 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.
Diffstat (limited to 'gcc/cp/Make-lang.in')
-rw-r--r--gcc/cp/Make-lang.in21
1 files changed, 15 insertions, 6 deletions
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index f7ba12e..4ee26fa 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -59,12 +59,21 @@ CFLAGS-cp/module.o += -DHOST_MACHINE=\"$(host)\" \
# 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%MU' \
+ 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%d0000U' 2>/dev/null; \
+ fi`; \
+ echo $${MODULE_VERSION} > 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++.