public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Bump LTO_major_version to 11.
@ 2021-04-20  9:57 Martin Liška
  2021-04-20 12:46 ` Richard Biener
  0 siblings, 1 reply; 23+ messages in thread
From: Martin Liška @ 2021-04-20  9:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Richard Biener, Jan Hubicka

It seems we bumped LTO_major_version last time 2 years ago.

Right now, the following is seen when one links a GCC 10.2.x LTO object file:
$ gcc a.o

lto1: fatal error: bytecode stream in file ‘a.o’ generated with LTO version 9.2 instead of the expected 9.0


I suggest bumping LTO_major_version for releases/gcc-11 branch.
Can we please align it with a GCC release (version 11)? For the future, if e.g. GCC 12 consumes LTO
bytecode from GCC 11, we can leave LTO_major_version. Once e.g. GCC 13 needs bumping,
I would then change it to 13.

What do you think about the suggested scheme?
Ready for gcc-11 branch?
Martin

gcc/ChangeLog:

	* lto-streamer.h (LTO_major_version): Bump to 11.
---
 gcc/lto-streamer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 5c7cd84d46f..7a7be80dab8 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -120,7 +120,7 @@ along with GCC; see the file COPYING3.  If not see
      String are represented in the table as pairs, a length in ULEB128
      form followed by the data for the string.  */
 
-#define LTO_major_version 9
+#define LTO_major_version 11
 #define LTO_minor_version 0
 
 typedef unsigned char	lto_decl_flags_t;
-- 
2.31.1


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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-20  9:57 [PATCH] Bump LTO_major_version to 11 Martin Liška
@ 2021-04-20 12:46 ` Richard Biener
  2021-04-20 18:49   ` Martin Liška
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Biener @ 2021-04-20 12:46 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches, Jakub Jelinek, Jan Hubicka

On Tue, Apr 20, 2021 at 11:57 AM Martin Liška <mliska@suse.cz> wrote:
>
> It seems we bumped LTO_major_version last time 2 years ago.
>
> Right now, the following is seen when one links a GCC 10.2.x LTO object file:
> $ gcc a.o
>
> lto1: fatal error: bytecode stream in file ‘a.o’ generated with LTO version 9.2 instead of the expected 9.0
>
>
> I suggest bumping LTO_major_version for releases/gcc-11 branch.
> Can we please align it with a GCC release (version 11)? For the future, if e.g. GCC 12 consumes LTO
> bytecode from GCC 11, we can leave LTO_major_version. Once e.g. GCC 13 needs bumping,
> I would then change it to 13.
>
> What do you think about the suggested scheme?
> Ready for gcc-11 branch?

OK.  Can you somehow arrange for trunk to pick up LTO_major from GCC
major automagically then?

Thanks,
Richard.

> Martin
>
> gcc/ChangeLog:
>
>         * lto-streamer.h (LTO_major_version): Bump to 11.
> ---
>  gcc/lto-streamer.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
> index 5c7cd84d46f..7a7be80dab8 100644
> --- a/gcc/lto-streamer.h
> +++ b/gcc/lto-streamer.h
> @@ -120,7 +120,7 @@ along with GCC; see the file COPYING3.  If not see
>       String are represented in the table as pairs, a length in ULEB128
>       form followed by the data for the string.  */
>
> -#define LTO_major_version 9
> +#define LTO_major_version 11
>  #define LTO_minor_version 0
>
>  typedef unsigned char  lto_decl_flags_t;
> --
> 2.31.1
>

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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-20 12:46 ` Richard Biener
@ 2021-04-20 18:49   ` Martin Liška
  2021-04-23  7:28     ` Richard Biener
                       ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Martin Liška @ 2021-04-20 18:49 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches, Jakub Jelinek, Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]

On 4/20/21 2:46 PM, Richard Biener wrote:
> OK.  Can you somehow arrange for trunk to pick up LTO_major from GCC
> major automagically then?

I have a pretty nice solution for it where I extended (and simplified)
the existing gcov-iov.c generator. Doing that we can remove gcc/version.[ch].

Using the patch, the following version.h is generated:

#ifndef VERSION_H
#define VERSION_H

/* Generated automatically by genversion.  */

#define GCC_major_version 12

/* The complete version string, assembled from several pieces.
BASEVER, DATESTAMP, DEVPHASE, and REVISION are defined by the
Makefile.  */

#define version_string "12.0.0 20210420 (experimental)"
#define pkgversion_string "(GCC) "

/* This is the location of the online document giving instructions for
reporting bugs.  If you distribute a modified version of GCC,
please configure with --with-bugurl pointing to a document giving
instructions for reporting bugs to you, not us.  (You are of course
welcome to forward us bugs reported to you, if you determine that
they are not bugs in your modifications.)  */

#define bug_report_url "<https://gcc.gnu.org/bugs/>"

#define GCOV_VERSION ((gcov_unsigned_t)0x42323020)  /* B20  */

#endif /* VERSION_H */

Ready for master?
Thanks,
Martin

[-- Attachment #2: 0001-Use-genversion-to-generate-version.h.patch --]
[-- Type: text/x-patch, Size: 15825 bytes --]

From 86d1946449de8aec5e71030f6c7c48010e83cd67 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 20 Apr 2021 16:56:07 +0200
Subject: [PATCH] Use genversion to generate version.h.

c++tools/ChangeLog:

	* Makefile.in: Include also ../gcc folder.

gcc/ChangeLog:

	* Makefile.in: Rename gcov-iov to genversion and depend
	on version.h (instead of gcov-iov.h).
	* gcov-io.h: Include version.h instread of gcov-iov.h.
	* gengtype-state.c (read_state_version): Likewise.
	* gcov-iov.c: Moved to...
	* genversion.c: ...here.
	* lto-streamer.h (LTO_major_version): Define it with
	GCC_major_version.
	* version.c: Removed.
	* version.h: Removed.

libgcc/ChangeLog:

	* libgcov-driver.c (gcov_version): Use different name that does
	not clash with newly introduced macro.
---
 c++tools/Makefile.in             |  4 +--
 gcc/Makefile.in                  | 53 +++++++++++---------------------
 gcc/gcov-io.h                    |  6 +---
 gcc/gengtype-state.c             |  6 ++--
 gcc/{gcov-iov.c => genversion.c} | 42 ++++++++++++++++---------
 gcc/lto-streamer.h               |  3 +-
 gcc/version.c                    | 35 ---------------------
 gcc/version.h                    |  6 ----
 libgcc/libgcov-driver.c          |  4 +--
 9 files changed, 55 insertions(+), 104 deletions(-)
 rename gcc/{gcov-iov.c => genversion.c} (59%)
 delete mode 100644 gcc/version.c
 delete mode 100644 gcc/version.h

diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in
index 9700706206d..afc87d07ad9 100644
--- a/c++tools/Makefile.in
+++ b/c++tools/Makefile.in
@@ -89,9 +89,9 @@ all::g++-mapper-server$(exeext)
 
 MAPPER.O := server.o resolver.o
 CODYLIB = ../libcody/libcody.a
-CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I.
+CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc
 g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
-	+$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(VERSION.O) $(LIBIBERTY) $(NETLIBS)
+	+$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
 
 # copy to gcc dir so tests there can run
 all::../gcc/g++-mapper-server$(exeext)
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 8a5fb3fd99c..e5d07fb98b0 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -960,7 +960,7 @@ BASIC_BLOCK_H = basic-block.h $(PREDICT_H) $(VEC_H) $(FUNCTION_H) \
 GIMPLE_H = gimple.h gimple.def gsstruct.def $(VEC_H) \
 	$(GGC_H) $(BASIC_BLOCK_H) $(TREE_H) tree-ssa-operands.h \
 	tree-ssa-alias.h $(INTERNAL_FN_H) $(HASH_TABLE_H) is-a.h
-GCOV_IO_H = gcov-io.h gcov-iov.h auto-host.h gcov-counter.def
+GCOV_IO_H = gcov-io.h version.h auto-host.h gcov-counter.def
 RECOG_H = recog.h
 EMIT_RTL_H = emit-rtl.h
 FLAGS_H = flags.h flag-types.h $(OPTIONS_H)
@@ -1711,7 +1711,7 @@ OBJS-libcommon = diagnostic.o diagnostic-color.o diagnostic-show-locus.o \
 	edit-context.o \
 	pretty-print.o intl.o \
 	sbitmap.o \
-	vec.o input.o version.o hash-table.o ggc-none.o memory-block.o \
+	vec.o input.o hash-table.o ggc-none.o memory-block.o \
 	selftest.o selftest-diagnostic.o sort.o
 
 # Objects in libcommon-target.a, used by drivers and by the core
@@ -1763,7 +1763,7 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
  $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
  $(SPECS) collect2$(exeext) gcc-ar$(exeext) gcc-nm$(exeext) \
  gcc-ranlib$(exeext) \
- gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
+ genversion$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
  gcov-tool$(exeect) \
  gengtype$(exeext) *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a \
  libcommon-target.a libcommon.a libgcc.mk perf.data
@@ -2144,7 +2144,7 @@ checksum-options:
 # Build libgcc.a.
 
 libgcc-support: libgcc.mvars stmp-int-hdrs $(TCONFIG_H) \
-	$(MACHMODE_H) gcov-iov.h
+	$(MACHMODE_H) version.h
 
 libgcc.mvars: config.status Makefile specs xgcc$(exeext)
 	: > tmp-libgcc.mvars
@@ -2333,12 +2333,6 @@ s-options-h: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \
 
 dumpvers: dumpvers.c
 
-CFLAGS-version.o += -DBASEVER=$(BASEVER_s) -DDATESTAMP=$(DATESTAMP_s) \
-	-DREVISION=$(REVISION_s) \
-	-DDEVPHASE=$(DEVPHASE_s) -DPKGVERSION=$(PKGVERSION_s) \
-	-DBUGURL=$(BUGURL_s)
-version.o: $(REVISION) $(DATESTAMP) $(BASEVER) $(DEVPHASE)
-
 # lto-compress.o needs $(ZLIBINC) added to the include flags.
 CFLAGS-lto-compress.o += $(ZLIBINC) $(ZSTD_INC)
 
@@ -2755,7 +2749,7 @@ generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_H) multilib.h \
        $(simple_generated_h) specs.h \
        tree-check.h genrtl.h insn-modes.h insn-modes-inline.h \
        tm-preds.h tm-constrs.h \
-       $(ALL_GTFILES_H) gtype-desc.c gtype-desc.h gcov-iov.h \
+       $(ALL_GTFILES_H) gtype-desc.c gtype-desc.h version.h \
        options.h target-hooks-def.h insn-opinit.h \
        common/common-target-hooks-def.h pass-instances.def \
        c-family/c-target-hooks-def.h d/d-target-hooks-def.h \
@@ -2769,16 +2763,6 @@ build/%.o :  # dependencies provided by explicit rule later
 	$(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) $(BUILD_CPPFLAGS) \
 		-o $@ $<
 
-## build/version.o is compiled by the $(COMPILER_FOR_BUILD) but needs
-## several C macro definitions, just like version.o
-build/version.o:  version.c version.h \
-                  $(REVISION) $(DATESTAMP) $(BASEVER) $(DEVPHASE)
-	$(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) $(BUILD_CPPFLAGS) \
-	-DBASEVER=$(BASEVER_s) -DDATESTAMP=$(DATESTAMP_s) \
-	-DREVISION=$(REVISION_s) \
-	-DDEVPHASE=$(DEVPHASE_s) -DPKGVERSION=$(PKGVERSION_s) \
-	-DBUGURL=$(BUGURL_s) -o $@ $<
-
 # Header dependencies for the programs that generate source code.
 # These are library modules...
 build/errors.o : errors.c $(BCONFIG_H) $(SYSTEM_H) errors.h
@@ -2957,10 +2941,10 @@ build/genmatch$(build_exeext) : $(BUILD_CPPLIB) \
 
 # These programs are not linked with the MD reader.
 build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
-              build/gengtype-state.o build/version.o build/errors.o
+              build/gengtype-state.o version.h build/errors.o
 
 gengtype$(exeext) : gengtype.o gengtype-lex.o gengtype-parse.o \
-              gengtype-state.o version.o errors.o $(LIBDEPS)
+              gengtype-state.o version.h errors.o $(LIBDEPS)
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	    $(filter-out ($LIBDEPS), $^) $(LIBS)
 
@@ -3039,20 +3023,19 @@ CFLAGS-cppdefault.o += $(PREPROCESSOR_DEFINES)
 # Note for the stamp targets, we run the program `true' instead of
 # having an empty command (nothing following the semicolon).
 
-# gcov-iov.c is run on the build machine to generate gcov-iov.h from version.c
-build/gcov-iov.o: gcov-iov.c $(BCONFIG_H) $(CORETYPES_H) $(GTM_H) \
-  $(SYSTEM_H) $(CORETYPES_H) $(TM_H)
+# genversion.c is run on the build machine to generate version.h
+CFLAGS-build/genversion.o += -DBASEVER=$(BASEVER_s) -DDATESTAMP=$(DATESTAMP_s) \
+	-DREVISION=$(REVISION_s) \
+	-DDEVPHASE=$(DEVPHASE_s) -DPKGVERSION=$(PKGVERSION_s) \
+	-DBUGURL=$(BUGURL_s)
 
-build/gcov-iov$(build_exeext): build/gcov-iov.o
-	+$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) \
-		build/gcov-iov.o -o $@
+build/genversion.o: genversion.c $(BCONFIG_H) $(SYSTEM_H)
 
-gcov-iov.h: s-iov; @true
-s-iov: build/gcov-iov$(build_exeext) $(BASEVER) $(DEVPHASE)
-	build/gcov-iov$(build_exeext) '$(BASEVER_c)' '$(DEVPHASE_c)' \
-	    > tmp-gcov-iov.h
-	$(SHELL) $(srcdir)/../move-if-change tmp-gcov-iov.h gcov-iov.h
-	$(STAMP) s-iov
+version.h: s-version; @true
+s-version: build/genversion$(build_exeext)
+	build/genversion$(build_exeext) > tmp-version.h
+	$(SHELL) $(srcdir)/../move-if-change tmp-version.h version.h
+	$(STAMP) s-version
 
 # gcov.o needs $(ZLIBINC) added to the include flags.
 CFLAGS-gcov.o += $(ZLIBINC)
diff --git a/gcc/gcov-io.h b/gcc/gcov-io.h
index 75f16a274c7..1f7f4d65a2d 100644
--- a/gcc/gcov-io.h
+++ b/gcc/gcov-io.h
@@ -225,11 +225,7 @@ typedef uint64_t gcov_type_unsigned;
 #define GCOV_DATA_MAGIC ((gcov_unsigned_t)0x67636461) /* "gcda" */
 #define GCOV_NOTE_MAGIC ((gcov_unsigned_t)0x67636e6f) /* "gcno" */
 
-/* gcov-iov.h is automatically generated by the makefile from
-   version.c, it looks like
-   	#define GCOV_VERSION ((gcov_unsigned_t)0x89abcdef)
-*/
-#include "gcov-iov.h"
+#include "version.h"
 
 /* Convert a magic or version number to a 4 character string.  */
 #define GCOV_UNSIGNED2STRING(ARRAY,VALUE)	\
diff --git a/gcc/gengtype-state.c b/gcc/gengtype-state.c
index 891f2e18a61..5a95455352b 100644
--- a/gcc/gengtype-state.c
+++ b/gcc/gengtype-state.c
@@ -2150,7 +2150,7 @@ read_state_options (options_p *opt)
 
 /* Read a version, and check against the version of the gengtype.  */
 static void
-read_state_version (const char *version_string)
+read_state_version (const char *ver_string)
 {
   struct state_token_st *t0 = peek_state_token (0);
   struct state_token_st *t1 = peek_state_token (1);
@@ -2166,10 +2166,10 @@ read_state_version (const char *version_string)
 	{
 	  /* Check that the read version string is the same as current
 	     version.  */
-	  if (strcmp (version_string, t0->stok_un.stok_string))
+	  if (strcmp (ver_string, t0->stok_un.stok_string))
 	    fatal_reading_state_printf (t0,
 					"version string mismatch; expecting %s but got %s",
-					version_string,
+					ver_string,
 					t0->stok_un.stok_string);
 	  next_state_tokens (2);
 	}
diff --git a/gcc/gcov-iov.c b/gcc/genversion.c
similarity index 59%
rename from gcc/gcov-iov.c
rename to gcc/genversion.c
index 32bf8dedb7c..22d8e349de5 100644
--- a/gcc/gcov-iov.c
+++ b/gcc/genversion.c
@@ -1,4 +1,4 @@
-/* Generate gcov version string from version.c. See gcov-io.h for
+/* Generate version strings. See gcov-io.h for
    description of how the version string is generated.
    Copyright (C) 2002-2021 Free Software Foundation, Inc.
    Contributed by Nathan Sidwell <nathan@codesourcery.com>
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3.  If not see
    phase (the latter may be an empty string).  */
 
 int
-main (int argc, char **argv)
+main (void)
 {
   unsigned int version = 0;
   unsigned char v[4];
@@ -34,15 +34,9 @@ main (int argc, char **argv)
   unsigned long major;
   unsigned long minor = 0;
   char phase = 0;
-  char *ptr;
+  char basever[] = BASEVER;
+  char *ptr = basever;
 
-  if (argc != 3)
-    {
-      fprintf (stderr, "usage: %s 'version' 'phase'\n", argv[0]);
-      return 1;
-    }
-
-  ptr = argv[1];
   major = strtoul (ptr, &ptr, 10);
 
   if (*ptr == '.')
@@ -53,9 +47,9 @@ main (int argc, char **argv)
      Consider both equal as patch-level releases do not change
      the GCOV version either.
      On the trunk the development phase is "experimental".  */
-  phase = argv[2][0];
+  phase = DEVPHASE[0];
   if (phase == '\0'
-      || strcmp (argv[2], "prerelease") == 0)
+      || strcmp (DEVPHASE, "prerelease") == 0)
     phase = '*';
 
   v[0] = (major / 10) + 'A';
@@ -66,12 +60,30 @@ main (int argc, char **argv)
   for (ix = 0; ix != 4; ix++)
     version = (version << 8) | v[ix];
 
-  printf ("/* Generated automatically by the program `%s'\n", argv[0]);
-  printf ("   from `%s (%lu %lu) and %s (%c)'.  */\n",
-	  argv[1], major, minor, argv[2], phase);
+  printf ("#ifndef VERSION_H\n");
+  printf ("#define VERSION_H\n\n");
+  printf ("/* Generated automatically by genversion.  */\n");
   printf ("\n");
+  printf ("#define GCC_major_version %lu\n\n", major);
+
+  printf ("/* The complete version string, assembled from several pieces.\n"
+	  "BASEVER, DATESTAMP, DEVPHASE, and REVISION are defined by the\n"
+	  "Makefile.  */\n\n");
+
+  printf ("#define version_string \"" BASEVER DATESTAMP DEVPHASE REVISION "\"\n");
+  printf ("#define pkgversion_string \"" PKGVERSION "\"\n\n");
+
+  printf ("/* This is the location of the online document giving instructions for\n"
+     "reporting bugs.  If you distribute a modified version of GCC,\n"
+     "please configure with --with-bugurl pointing to a document giving\n"
+     "instructions for reporting bugs to you, not us.  (You are of course\n"
+     "welcome to forward us bugs reported to you, if you determine that\n"
+     "they are not bugs in your modifications.)  */\n\n");
+  printf ("#define bug_report_url \"" BUGURL "\"\n\n");
+
   printf ("#define GCOV_VERSION ((gcov_unsigned_t)0x%08x)  /* %.4s */\n",
 	  version, v);
+  printf ("\n#endif /* VERSION_H */\n");
 
   return 0;
 }
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 5c7cd84d46f..5f0335eb76c 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "plugin-api.h"
 #include "gcov-io.h"
 #include "diagnostic.h"
+#include "version.h"
 
 /* The encoding for a function consists of the following sections:
 
@@ -120,7 +121,7 @@ along with GCC; see the file COPYING3.  If not see
      String are represented in the table as pairs, a length in ULEB128
      form followed by the data for the string.  */
 
-#define LTO_major_version 9
+#define LTO_major_version GCC_major_version
 #define LTO_minor_version 0
 
 typedef unsigned char	lto_decl_flags_t;
diff --git a/gcc/version.c b/gcc/version.c
deleted file mode 100644
index 9415bb692ec..00000000000
--- a/gcc/version.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 3, or (at your option) any later
-version.
-
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-#include "version.h"
-
-/* This is the location of the online document giving instructions for
-   reporting bugs.  If you distribute a modified version of GCC,
-   please configure with --with-bugurl pointing to a document giving
-   instructions for reporting bugs to you, not us.  (You are of course
-   welcome to forward us bugs reported to you, if you determine that
-   they are not bugs in your modifications.)  */
-
-const char bug_report_url[] = BUGURL;
-
-/* The complete version string, assembled from several pieces.
-   BASEVER, DATESTAMP, DEVPHASE, and REVISION are defined by the
-   Makefile.  */
-
-const char version_string[] = BASEVER DATESTAMP DEVPHASE REVISION;
-const char pkgversion_string[] = PKGVERSION;
diff --git a/gcc/version.h b/gcc/version.h
deleted file mode 100644
index 88919039d96..00000000000
--- a/gcc/version.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef GCC_VERSION_H
-#define GCC_VERSION_H
-extern const char version_string[];
-extern const char pkgversion_string[];
-extern const char bug_report_url[];
-#endif /* ! GCC_VERSION_H */
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index a1338b6e525..2747deff2a8 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -196,7 +196,7 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned_t version,
   if (version != GCOV_VERSION)
     {
       char v[4], e[4];
-      char version_string[128], expected_string[128];
+      char ver_string[128], expected_string[128];
 
       GCOV_UNSIGNED2STRING (v, version);
       GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
@@ -205,7 +205,7 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned_t version,
 		  "got %s (%.4s)\n",
 		  filename? filename : ptr->filename,
 		  gcov_version_string (expected_string, e), e,
-		  gcov_version_string (version_string, v), v);
+		  gcov_version_string (ver_string, v), v);
       return 0;
     }
   return 1;
-- 
2.31.1


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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-20 18:49   ` Martin Liška
@ 2021-04-23  7:28     ` Richard Biener
  2021-04-23  7:59       ` Martin Liška
  2021-05-10  8:51     ` Eric Botcazou
  2021-05-10  9:01     ` Eric Botcazou
  2 siblings, 1 reply; 23+ messages in thread
From: Richard Biener @ 2021-04-23  7:28 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches, Jakub Jelinek, Jan Hubicka

On Tue, Apr 20, 2021 at 8:49 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 4/20/21 2:46 PM, Richard Biener wrote:
> > OK.  Can you somehow arrange for trunk to pick up LTO_major from GCC
> > major automagically then?
>
> I have a pretty nice solution for it where I extended (and simplified)
> the existing gcov-iov.c generator. Doing that we can remove gcc/version.[ch].
>
> Using the patch, the following version.h is generated:
>
> #ifndef VERSION_H
> #define VERSION_H
>
> /* Generated automatically by genversion.  */
>
> #define GCC_major_version 12
>
> /* The complete version string, assembled from several pieces.
> BASEVER, DATESTAMP, DEVPHASE, and REVISION are defined by the
> Makefile.  */
>
> #define version_string "12.0.0 20210420 (experimental)"
> #define pkgversion_string "(GCC) "
>
> /* This is the location of the online document giving instructions for
> reporting bugs.  If you distribute a modified version of GCC,
> please configure with --with-bugurl pointing to a document giving
> instructions for reporting bugs to you, not us.  (You are of course
> welcome to forward us bugs reported to you, if you determine that
> they are not bugs in your modifications.)  */
>
> #define bug_report_url "<https://gcc.gnu.org/bugs/>"
>
> #define GCOV_VERSION ((gcov_unsigned_t)0x42323020)  /* B20  */
>
> #endif /* VERSION_H */
>
> Ready for master?

Nice.  This is OK if others do not have further comments.

I think we'd want to explore whether we can integrate
genchecksum.c as well and make the PCH checksum
based on a set of source files (including the generated
auto-host.h) - that might allow removing the two-stage
link and my "hack" to re-use the version from prev-gcc
as well as our openSUSE "hack" for reproducible builds
which elides genchecksum.c for the use of the build-id
in the actual executables.

Richard.

> Thanks,
> Martin

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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-23  7:28     ` Richard Biener
@ 2021-04-23  7:59       ` Martin Liška
  2021-04-23  9:37         ` Richard Biener
  0 siblings, 1 reply; 23+ messages in thread
From: Martin Liška @ 2021-04-23  7:59 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches, Jakub Jelinek, Jan Hubicka

On 4/23/21 9:28 AM, Richard Biener wrote:
> On Tue, Apr 20, 2021 at 8:49 PM Martin Liška <mliska@suse.cz> wrote:
>>
>> On 4/20/21 2:46 PM, Richard Biener wrote:
>>> OK.  Can you somehow arrange for trunk to pick up LTO_major from GCC
>>> major automagically then?
>>
>> I have a pretty nice solution for it where I extended (and simplified)
>> the existing gcov-iov.c generator. Doing that we can remove gcc/version.[ch].
>>
>> Using the patch, the following version.h is generated:
>>
>> #ifndef VERSION_H
>> #define VERSION_H
>>
>> /* Generated automatically by genversion.  */
>>
>> #define GCC_major_version 12
>>
>> /* The complete version string, assembled from several pieces.
>> BASEVER, DATESTAMP, DEVPHASE, and REVISION are defined by the
>> Makefile.  */
>>
>> #define version_string "12.0.0 20210420 (experimental)"
>> #define pkgversion_string "(GCC) "
>>
>> /* This is the location of the online document giving instructions for
>> reporting bugs.  If you distribute a modified version of GCC,
>> please configure with --with-bugurl pointing to a document giving
>> instructions for reporting bugs to you, not us.  (You are of course
>> welcome to forward us bugs reported to you, if you determine that
>> they are not bugs in your modifications.)  */
>>
>> #define bug_report_url "<https://gcc.gnu.org/bugs/>"
>>
>> #define GCOV_VERSION ((gcov_unsigned_t)0x42323020)  /* B20  */
>>
>> #endif /* VERSION_H */
>>
>> Ready for master?
> 
> Nice.  This is OK if others do not have further comments.

Thanks, I'm going to install it once GCC 11.1 is released.

> 
> I think we'd want to explore whether we can integrate
> genchecksum.c as well and make the PCH checksum
> based on a set of source files (including the generated
> auto-host.h) - that might allow removing the two-stage

Definitely. I see multiple options:

1) using git, it can make provide a hash for content of a folder:

$ git ls-tree HEAD -- gcc

040000 tree db613554ec17462c63bace2015c877d6bed70bbe	gcc

One can do that per-file as well:
git ls-tree HEAD -- gcc/c/*.c

100644 blob bae5757ad137c0af58dbe66229d4201a45094aca	gcc/c/c-aux-info.c

100644 blob d0035a31723447657a04c2ef79c9fd7c0ddc7568	gcc/c/c-convert.c

100644 blob 3ea4708c5075d9274601a0676f86a6900a9345b0	gcc/c/c-decl.c

100644 blob de98958ceabac9d631f937f9f28547d8aed26af2	gcc/c/c-errors.c

100644 blob 68c74cc1eb2ef908545b36e2dbff65606f756e15	gcc/c/c-fold.c

...

That needs to be combined with the generated auto-host.h header file.
From which locations do you want to build the hash? Any other $objdir
files except auto-host.h?

Note 'git archive' can append arbitrary non-git files.

2) Doing checksum of *.[cC] in a given folder + auto-host.h.

3) Using git hash (+ auto-host.h), but it's likely too gross, right?

> link and my "hack" to re-use the version from prev-gcc
> as well as our openSUSE "hack" for reproducible builds
> which elides genchecksum.c for the use of the build-id
> in the actual executables.

What a hack. The binary is reading it's buildid right from the memory,
right?

Thoughts?

Martin

> 
> Richard.
> 
>> Thanks,
>> Martin


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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-23  7:59       ` Martin Liška
@ 2021-04-23  9:37         ` Richard Biener
  2021-04-23  9:51           ` Jan Hubicka
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Biener @ 2021-04-23  9:37 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches, Jakub Jelinek, Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 3840 bytes --]

On Fri, Apr 23, 2021 at 9:59 AM Martin Liška <mliska@suse.cz> wrote:
>
> On 4/23/21 9:28 AM, Richard Biener wrote:
> > On Tue, Apr 20, 2021 at 8:49 PM Martin Liška <mliska@suse.cz> wrote:
> >>
> >> On 4/20/21 2:46 PM, Richard Biener wrote:
> >>> OK.  Can you somehow arrange for trunk to pick up LTO_major from GCC
> >>> major automagically then?
> >>
> >> I have a pretty nice solution for it where I extended (and simplified)
> >> the existing gcov-iov.c generator. Doing that we can remove gcc/version.[ch].
> >>
> >> Using the patch, the following version.h is generated:
> >>
> >> #ifndef VERSION_H
> >> #define VERSION_H
> >>
> >> /* Generated automatically by genversion.  */
> >>
> >> #define GCC_major_version 12
> >>
> >> /* The complete version string, assembled from several pieces.
> >> BASEVER, DATESTAMP, DEVPHASE, and REVISION are defined by the
> >> Makefile.  */
> >>
> >> #define version_string "12.0.0 20210420 (experimental)"
> >> #define pkgversion_string "(GCC) "
> >>
> >> /* This is the location of the online document giving instructions for
> >> reporting bugs.  If you distribute a modified version of GCC,
> >> please configure with --with-bugurl pointing to a document giving
> >> instructions for reporting bugs to you, not us.  (You are of course
> >> welcome to forward us bugs reported to you, if you determine that
> >> they are not bugs in your modifications.)  */
> >>
> >> #define bug_report_url "<https://gcc.gnu.org/bugs/>"
> >>
> >> #define GCOV_VERSION ((gcov_unsigned_t)0x42323020)  /* B20  */
> >>
> >> #endif /* VERSION_H */
> >>
> >> Ready for master?
> >
> > Nice.  This is OK if others do not have further comments.
>
> Thanks, I'm going to install it once GCC 11.1 is released.
>
> >
> > I think we'd want to explore whether we can integrate
> > genchecksum.c as well and make the PCH checksum
> > based on a set of source files (including the generated
> > auto-host.h) - that might allow removing the two-stage
>
> Definitely. I see multiple options:
>
> 1) using git, it can make provide a hash for content of a folder:
>
> $ git ls-tree HEAD -- gcc
>
> 040000 tree db613554ec17462c63bace2015c877d6bed70bbe    gcc
>
> One can do that per-file as well:
> git ls-tree HEAD -- gcc/c/*.c
>
> 100644 blob bae5757ad137c0af58dbe66229d4201a45094aca    gcc/c/c-aux-info.c
>
> 100644 blob d0035a31723447657a04c2ef79c9fd7c0ddc7568    gcc/c/c-convert.c
>
> 100644 blob 3ea4708c5075d9274601a0676f86a6900a9345b0    gcc/c/c-decl.c
>
> 100644 blob de98958ceabac9d631f937f9f28547d8aed26af2    gcc/c/c-errors.c
>
> 100644 blob 68c74cc1eb2ef908545b36e2dbff65606f756e15    gcc/c/c-fold.c
>
> ...

I think using git is out of the question unless we want to check in the
generated file.  We ship tarballs (w/o generated files for snapshots) and those
have to build as well.

> That needs to be combined with the generated auto-host.h header file.
> From which locations do you want to build the hash? Any other $objdir
> files except auto-host.h?

In fact for PCH just summing the gengtype generated files would be
good enough I guess ...

> Note 'git archive' can append arbitrary non-git files.
>
> 2) Doing checksum of *.[cC] in a given folder + auto-host.h.
>
> 3) Using git hash (+ auto-host.h), but it's likely too gross, right?
>
> > link and my "hack" to re-use the version from prev-gcc
> > as well as our openSUSE "hack" for reproducible builds
> > which elides genchecksum.c for the use of the build-id
> > in the actual executables.
>
> What a hack. The binary is reading it's buildid right from the memory,
> right?

Well, yes (I think I've posted the patch as RFC once, attached for reference).

Richard.

> Thoughts?
>
> Martin
>
> >
> > Richard.
> >
> >> Thanks,
> >> Martin
>

[-- Attachment #2: gcc9-reproducible-builds-buildid-for-checksum.patch --]
[-- Type: text/x-patch, Size: 3515 bytes --]

Use the binaries build-id as checksum for PCH purposes.

diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c
index a2292f46a7d..94d633d139a 100644
--- a/gcc/c-family/c-pch.c
+++ b/gcc/c-family/c-pch.c
@@ -65,6 +65,66 @@ static FILE *pch_outfile;
 
 static const char *get_ident (void);
 
+#if _GNU_SOURCE
+#include <link.h>
+
+#define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) - 1))
+
+static int
+get_build_id_1 (struct dl_phdr_info *info, size_t, void *data)
+{
+  for (unsigned i = 0; i < info->dlpi_phnum; ++i)
+    {
+      if (info->dlpi_phdr[i].p_type != PT_NOTE)
+	continue;
+      ElfW(Nhdr) *nhdr
+	= (ElfW(Nhdr) *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
+      ptrdiff_t size = info->dlpi_phdr[i].p_filesz;
+      ptrdiff_t align = info->dlpi_phdr[i].p_align;
+      if (align != 8)
+	align = 4;
+      while (size >= (ptrdiff_t)sizeof (ElfW(Nhdr)))
+	{
+	  if (nhdr->n_type == NT_GNU_BUILD_ID
+	      && nhdr->n_namesz == 4
+	      && strncmp ((char *)nhdr
+			  + sizeof (ElfW(Nhdr)),
+			  "GNU", 4) == 0
+	      && nhdr->n_descsz >= 16)
+	    {
+	      memcpy (data, 
+		      (char *)nhdr
+		      + ALIGN (sizeof (ElfW(Nhdr))
+			       + nhdr->n_namesz, align), 16);
+	      return 1;
+	    }
+	  size_t offset = (ALIGN (sizeof (ElfW(Nhdr))
+				  + nhdr->n_namesz, align)
+			   + ALIGN(nhdr->n_descsz, align));
+	  nhdr = (ElfW(Nhdr) *)((char *)nhdr + offset);
+	  size -= offset;
+	}
+    }
+
+  return 0;
+}
+
+static const unsigned char *
+get_build_id ()
+{
+  static unsigned char build_id[16];
+  if (!dl_iterate_phdr (get_build_id_1, build_id))
+    return NULL;
+  return build_id;
+}
+#else
+static const unsigned char *
+get_build_id ()
+{
+  return NULL;
+}
+#endif
+
 /* Compute an appropriate 8-byte magic number for the PCH file, so that
    utilities like file(1) can identify it, and so that GCC can quickly
    ignore non-PCH files and PCH files that are of a completely different
@@ -120,8 +180,11 @@ pch_init (void)
   v.pch_init = &pch_init;
   target_validity = targetm.get_pch_validity (&v.target_data_length);
 
+  const unsigned char *chksum = get_build_id ();
+  if (!chksum)
+    chksum = executable_checksum;
   if (fwrite (partial_pch, IDENT_LENGTH, 1, f) != 1
-      || fwrite (executable_checksum, 16, 1, f) != 1
+      || fwrite (chksum, 16, 1, f) != 1
       || fwrite (&v, sizeof (v), 1, f) != 1
       || fwrite (target_validity, v.target_data_length, 1, f) != 1)
     fatal_error (input_location, "cannot write to %s: %m", pch_file);
@@ -237,7 +300,10 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd)
 	}
       return 2;
     }
-  if (memcmp (ident + IDENT_LENGTH, executable_checksum, 16) != 0)
+  const unsigned char *chksum = get_build_id ();
+  if (!chksum)
+    chksum = executable_checksum;
+  if (memcmp (ident + IDENT_LENGTH, chksum, 16) != 0)
     {
       if (cpp_get_options (pfile)->warn_invalid_pch)
 	cpp_error (pfile, CPP_DL_WARNING,
diff --git a/gcc/genchecksum.c b/gcc/genchecksum.c
index 09fbb63fa93..ec8b3281d53 100644
--- a/gcc/genchecksum.c
+++ b/gcc/genchecksum.c
@@ -113,8 +113,13 @@ main (int argc, char ** argv)
   puts ("#include \"config.h\"");
   puts ("#include \"system.h\"");
   fputs ("EXPORTED_CONST unsigned char executable_checksum[16] = { ", stdout);
+#if _GNU_SOURCE
+  for (i = 0; i < 16; i++)
+    printf ("0x%02x%s", 0, i == 15 ? " };\n" : ", ");
+#else
   for (i = 0; i < 16; i++)
     printf ("0x%02x%s", result[i], i == 15 ? " };\n" : ", ");
+#endif
 
   return 0;
 }

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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-23  9:37         ` Richard Biener
@ 2021-04-23  9:51           ` Jan Hubicka
  2021-04-23 10:59             ` Richard Biener
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Hubicka @ 2021-04-23  9:51 UTC (permalink / raw)
  To: Richard Biener; +Cc: Martin Liška, Jakub Jelinek, GCC Patches

> > That needs to be combined with the generated auto-host.h header file.
> > From which locations do you want to build the hash? Any other $objdir
> > files except auto-host.h?
> 
> In fact for PCH just summing the gengtype generated files would be
> good enough I guess ...

I think one can, for example, change datastructure layout/meaning of a
bit in tree.h that invalidates PCH but makes the accessors same.

Honza
> 
> > Note 'git archive' can append arbitrary non-git files.
> >
> > 2) Doing checksum of *.[cC] in a given folder + auto-host.h.
> >
> > 3) Using git hash (+ auto-host.h), but it's likely too gross, right?
> >
> > > link and my "hack" to re-use the version from prev-gcc
> > > as well as our openSUSE "hack" for reproducible builds
> > > which elides genchecksum.c for the use of the build-id
> > > in the actual executables.
> >
> > What a hack. The binary is reading it's buildid right from the memory,
> > right?
> 
> Well, yes (I think I've posted the patch as RFC once, attached for reference).
> 
> Richard.
> 
> > Thoughts?
> >
> > Martin
> >
> > >
> > > Richard.
> > >
> > >> Thanks,
> > >> Martin
> >

> Use the binaries build-id as checksum for PCH purposes.
> 
> diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c
> index a2292f46a7d..94d633d139a 100644
> --- a/gcc/c-family/c-pch.c
> +++ b/gcc/c-family/c-pch.c
> @@ -65,6 +65,66 @@ static FILE *pch_outfile;
>  
>  static const char *get_ident (void);
>  
> +#if _GNU_SOURCE
> +#include <link.h>
> +
> +#define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) - 1))
> +
> +static int
> +get_build_id_1 (struct dl_phdr_info *info, size_t, void *data)
> +{
> +  for (unsigned i = 0; i < info->dlpi_phnum; ++i)
> +    {
> +      if (info->dlpi_phdr[i].p_type != PT_NOTE)
> +	continue;
> +      ElfW(Nhdr) *nhdr
> +	= (ElfW(Nhdr) *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
> +      ptrdiff_t size = info->dlpi_phdr[i].p_filesz;
> +      ptrdiff_t align = info->dlpi_phdr[i].p_align;
> +      if (align != 8)
> +	align = 4;
> +      while (size >= (ptrdiff_t)sizeof (ElfW(Nhdr)))
> +	{
> +	  if (nhdr->n_type == NT_GNU_BUILD_ID
> +	      && nhdr->n_namesz == 4
> +	      && strncmp ((char *)nhdr
> +			  + sizeof (ElfW(Nhdr)),
> +			  "GNU", 4) == 0
> +	      && nhdr->n_descsz >= 16)
> +	    {
> +	      memcpy (data, 
> +		      (char *)nhdr
> +		      + ALIGN (sizeof (ElfW(Nhdr))
> +			       + nhdr->n_namesz, align), 16);
> +	      return 1;
> +	    }
> +	  size_t offset = (ALIGN (sizeof (ElfW(Nhdr))
> +				  + nhdr->n_namesz, align)
> +			   + ALIGN(nhdr->n_descsz, align));
> +	  nhdr = (ElfW(Nhdr) *)((char *)nhdr + offset);
> +	  size -= offset;
> +	}
> +    }
> +
> +  return 0;
> +}
> +
> +static const unsigned char *
> +get_build_id ()
> +{
> +  static unsigned char build_id[16];
> +  if (!dl_iterate_phdr (get_build_id_1, build_id))
> +    return NULL;
> +  return build_id;
> +}
> +#else
> +static const unsigned char *
> +get_build_id ()
> +{
> +  return NULL;
> +}
> +#endif
> +
>  /* Compute an appropriate 8-byte magic number for the PCH file, so that
>     utilities like file(1) can identify it, and so that GCC can quickly
>     ignore non-PCH files and PCH files that are of a completely different
> @@ -120,8 +180,11 @@ pch_init (void)
>    v.pch_init = &pch_init;
>    target_validity = targetm.get_pch_validity (&v.target_data_length);
>  
> +  const unsigned char *chksum = get_build_id ();
> +  if (!chksum)
> +    chksum = executable_checksum;
>    if (fwrite (partial_pch, IDENT_LENGTH, 1, f) != 1
> -      || fwrite (executable_checksum, 16, 1, f) != 1
> +      || fwrite (chksum, 16, 1, f) != 1
>        || fwrite (&v, sizeof (v), 1, f) != 1
>        || fwrite (target_validity, v.target_data_length, 1, f) != 1)
>      fatal_error (input_location, "cannot write to %s: %m", pch_file);
> @@ -237,7 +300,10 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd)
>  	}
>        return 2;
>      }
> -  if (memcmp (ident + IDENT_LENGTH, executable_checksum, 16) != 0)
> +  const unsigned char *chksum = get_build_id ();
> +  if (!chksum)
> +    chksum = executable_checksum;
> +  if (memcmp (ident + IDENT_LENGTH, chksum, 16) != 0)
>      {
>        if (cpp_get_options (pfile)->warn_invalid_pch)
>  	cpp_error (pfile, CPP_DL_WARNING,
> diff --git a/gcc/genchecksum.c b/gcc/genchecksum.c
> index 09fbb63fa93..ec8b3281d53 100644
> --- a/gcc/genchecksum.c
> +++ b/gcc/genchecksum.c
> @@ -113,8 +113,13 @@ main (int argc, char ** argv)
>    puts ("#include \"config.h\"");
>    puts ("#include \"system.h\"");
>    fputs ("EXPORTED_CONST unsigned char executable_checksum[16] = { ", stdout);
> +#if _GNU_SOURCE
> +  for (i = 0; i < 16; i++)
> +    printf ("0x%02x%s", 0, i == 15 ? " };\n" : ", ");
> +#else
>    for (i = 0; i < 16; i++)
>      printf ("0x%02x%s", result[i], i == 15 ? " };\n" : ", ");
> +#endif
>  
>    return 0;
>  }


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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-23  9:51           ` Jan Hubicka
@ 2021-04-23 10:59             ` Richard Biener
  2021-04-23 11:37               ` Martin Liška
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Biener @ 2021-04-23 10:59 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: Martin Liška, Jakub Jelinek, GCC Patches

On Fri, Apr 23, 2021 at 11:51 AM Jan Hubicka <hubicka@ucw.cz> wrote:
>
> > > That needs to be combined with the generated auto-host.h header file.
> > > From which locations do you want to build the hash? Any other $objdir
> > > files except auto-host.h?
> >
> > In fact for PCH just summing the gengtype generated files would be
> > good enough I guess ...
>
> I think one can, for example, change datastructure layout/meaning of a
> bit in tree.h that invalidates PCH but makes the accessors same.

True, the question is on how much detail we have to pay attention to.
For us of course the build-id solution works fine.  And hopefully the
days of PCH are counted...

Richard.

> Honza
> >
> > > Note 'git archive' can append arbitrary non-git files.
> > >
> > > 2) Doing checksum of *.[cC] in a given folder + auto-host.h.
> > >
> > > 3) Using git hash (+ auto-host.h), but it's likely too gross, right?
> > >
> > > > link and my "hack" to re-use the version from prev-gcc
> > > > as well as our openSUSE "hack" for reproducible builds
> > > > which elides genchecksum.c for the use of the build-id
> > > > in the actual executables.
> > >
> > > What a hack. The binary is reading it's buildid right from the memory,
> > > right?
> >
> > Well, yes (I think I've posted the patch as RFC once, attached for reference).
> >
> > Richard.
> >
> > > Thoughts?
> > >
> > > Martin
> > >
> > > >
> > > > Richard.
> > > >
> > > >> Thanks,
> > > >> Martin
> > >
>
> > Use the binaries build-id as checksum for PCH purposes.
> >
> > diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c
> > index a2292f46a7d..94d633d139a 100644
> > --- a/gcc/c-family/c-pch.c
> > +++ b/gcc/c-family/c-pch.c
> > @@ -65,6 +65,66 @@ static FILE *pch_outfile;
> >
> >  static const char *get_ident (void);
> >
> > +#if _GNU_SOURCE
> > +#include <link.h>
> > +
> > +#define ALIGN(val, align)      (((val) + (align) - 1) & ~((align) - 1))
> > +
> > +static int
> > +get_build_id_1 (struct dl_phdr_info *info, size_t, void *data)
> > +{
> > +  for (unsigned i = 0; i < info->dlpi_phnum; ++i)
> > +    {
> > +      if (info->dlpi_phdr[i].p_type != PT_NOTE)
> > +     continue;
> > +      ElfW(Nhdr) *nhdr
> > +     = (ElfW(Nhdr) *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
> > +      ptrdiff_t size = info->dlpi_phdr[i].p_filesz;
> > +      ptrdiff_t align = info->dlpi_phdr[i].p_align;
> > +      if (align != 8)
> > +     align = 4;
> > +      while (size >= (ptrdiff_t)sizeof (ElfW(Nhdr)))
> > +     {
> > +       if (nhdr->n_type == NT_GNU_BUILD_ID
> > +           && nhdr->n_namesz == 4
> > +           && strncmp ((char *)nhdr
> > +                       + sizeof (ElfW(Nhdr)),
> > +                       "GNU", 4) == 0
> > +           && nhdr->n_descsz >= 16)
> > +         {
> > +           memcpy (data,
> > +                   (char *)nhdr
> > +                   + ALIGN (sizeof (ElfW(Nhdr))
> > +                            + nhdr->n_namesz, align), 16);
> > +           return 1;
> > +         }
> > +       size_t offset = (ALIGN (sizeof (ElfW(Nhdr))
> > +                               + nhdr->n_namesz, align)
> > +                        + ALIGN(nhdr->n_descsz, align));
> > +       nhdr = (ElfW(Nhdr) *)((char *)nhdr + offset);
> > +       size -= offset;
> > +     }
> > +    }
> > +
> > +  return 0;
> > +}
> > +
> > +static const unsigned char *
> > +get_build_id ()
> > +{
> > +  static unsigned char build_id[16];
> > +  if (!dl_iterate_phdr (get_build_id_1, build_id))
> > +    return NULL;
> > +  return build_id;
> > +}
> > +#else
> > +static const unsigned char *
> > +get_build_id ()
> > +{
> > +  return NULL;
> > +}
> > +#endif
> > +
> >  /* Compute an appropriate 8-byte magic number for the PCH file, so that
> >     utilities like file(1) can identify it, and so that GCC can quickly
> >     ignore non-PCH files and PCH files that are of a completely different
> > @@ -120,8 +180,11 @@ pch_init (void)
> >    v.pch_init = &pch_init;
> >    target_validity = targetm.get_pch_validity (&v.target_data_length);
> >
> > +  const unsigned char *chksum = get_build_id ();
> > +  if (!chksum)
> > +    chksum = executable_checksum;
> >    if (fwrite (partial_pch, IDENT_LENGTH, 1, f) != 1
> > -      || fwrite (executable_checksum, 16, 1, f) != 1
> > +      || fwrite (chksum, 16, 1, f) != 1
> >        || fwrite (&v, sizeof (v), 1, f) != 1
> >        || fwrite (target_validity, v.target_data_length, 1, f) != 1)
> >      fatal_error (input_location, "cannot write to %s: %m", pch_file);
> > @@ -237,7 +300,10 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd)
> >       }
> >        return 2;
> >      }
> > -  if (memcmp (ident + IDENT_LENGTH, executable_checksum, 16) != 0)
> > +  const unsigned char *chksum = get_build_id ();
> > +  if (!chksum)
> > +    chksum = executable_checksum;
> > +  if (memcmp (ident + IDENT_LENGTH, chksum, 16) != 0)
> >      {
> >        if (cpp_get_options (pfile)->warn_invalid_pch)
> >       cpp_error (pfile, CPP_DL_WARNING,
> > diff --git a/gcc/genchecksum.c b/gcc/genchecksum.c
> > index 09fbb63fa93..ec8b3281d53 100644
> > --- a/gcc/genchecksum.c
> > +++ b/gcc/genchecksum.c
> > @@ -113,8 +113,13 @@ main (int argc, char ** argv)
> >    puts ("#include \"config.h\"");
> >    puts ("#include \"system.h\"");
> >    fputs ("EXPORTED_CONST unsigned char executable_checksum[16] = { ", stdout);
> > +#if _GNU_SOURCE
> > +  for (i = 0; i < 16; i++)
> > +    printf ("0x%02x%s", 0, i == 15 ? " };\n" : ", ");
> > +#else
> >    for (i = 0; i < 16; i++)
> >      printf ("0x%02x%s", result[i], i == 15 ? " };\n" : ", ");
> > +#endif
> >
> >    return 0;
> >  }
>

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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-23 10:59             ` Richard Biener
@ 2021-04-23 11:37               ` Martin Liška
  2021-05-11  6:46                 ` Martin Liška
  0 siblings, 1 reply; 23+ messages in thread
From: Martin Liška @ 2021-04-23 11:37 UTC (permalink / raw)
  To: Richard Biener, Jan Hubicka; +Cc: Jakub Jelinek, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 945 bytes --]

On 4/23/21 12:59 PM, Richard Biener wrote:
> True, the question is on how much detail we have to pay attention to.

Agree with that.

> For us of course the build-id solution works fine.  And hopefully the
> days of PCH are counted...

Yes.

I have a tentative patch that emits the attached checksum.h header file.
We also include flags in the checksum:

...
         build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \

                     checksum-options > cc1-checksum.c.tmp &&           \

...

$ cat checksum-options

g++ -no-pie   -g   -DIN_GCC -fPIC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  

Can we ignore them in the checksum calculation?
Martin

[-- Attachment #2: checksum.h --]
[-- Type: text/x-chdr, Size: 2295 bytes --]

/* Checksum based on the following files:

  gt-ada-decl.h
  gt-ada-misc.h
  gt-ada-trans.h
  gt-ada-utils.h
  gt-alias.h
  gt-asan.h
  gt-bitmap.h
  gt-brig-brig-lang.h
  gt-caller-save.h
  gt-calls.h
  gt-c-c-decl.h
  gt-c-c-parser.h
  gt-c-family-c-common.h
  gt-c-family-c-cppbuiltin.h
  gt-c-family-c-format.h
  gt-c-family-c-pragma.h
  gt-cfgrtl.h
  gt-cgraphclones.h
  gt-cgraph.h
  gt-coverage.h
  gt-cp-call.h
  gt-cp-class.h
  gt-cp-constexpr.h
  gt-cp-constraint.h
  gt-cp-coroutines.h
  gt-cp-cp-gimplify.h
  gt-cp-cp-lang.h
  gt-cp-cp-objcp-common.h
  gt-cp-decl2.h
  gt-cp-decl.h
  gt-cp-except.h
  gt-cp-friend.h
  gt-cp-init.h
  gt-cp-lambda.h
  gt-cp-lex.h
  gt-cp-logic.h
  gt-cp-mangle.h
  gt-cp-method.h
  gt-cp-module.h
  gt-cp-name-lookup.h
  gt-cp-parser.h
  gt-cp-pt.h
  gt-cp-rtti.h
  gt-cp-semantics.h
  gt-cp-tree.h
  gt-cp-vtable-class-hierarchy.h
  gt-cselib.h
  gt-dbxout.h
  gt-d-d-builtins.h
  gt-d-d-lang.h
  gt-dojump.h
  gt-d-typeinfo.h
  gt-dwarf2asm.h
  gt-dwarf2cfi.h
  gt-dwarf2out.h
  gt-emit-rtl.h
  gt-except.h
  gt-explow.h
  gt-fortran-f95-lang.h
  gt-fortran-trans-decl.h
  gt-fortran-trans-intrinsic.h
  gt-fortran-trans-io.h
  gt-fortran-trans-stmt.h
  gt-fortran-trans-types.h
  gt-function.h
  gt-gcse.h
  gt-ggc-tests.h
  gt-gimple-expr.h
  gt-godump.h
  gt-go-go-lang.h
  gt-i386-builtins.h
  gt-i386-expand.h
  gt-i386.h
  gt-i386-options.h
  gt-ipa-devirt.h
  gt-ipa-modref.h
  gt-ipa-prop.h
  gt-ipa-sra.h
  gt-jit-dummy-frontend.h
  gt-lists.h
  gt-lto-lto-common.h
  gt-lto-lto-lang.h
  gt-objc-objc-act.h
  gt-objc-objc-gnu-runtime-abi-01.h
  gt-objc-objc-map.h
  gt-objc-objc-next-runtime-abi-01.h
  gt-objc-objc-next-runtime-abi-02.h
  gt-objc-objc-runtime-shared-support.h
  gt-omp-general.h
  gt-omp-low.h
  gt-optabs-libfuncs.h
  gt-stor-layout.h
  gt-stringpool.h
  gt-symtab-thunks.h
  gt-targhooks.h
  gt-trans-mem.h
  gt-tree.h
  gt-tree-iterator.h
  gt-tree-nested.h
  gt-tree-phinodes.h
  gt-tree-profile.h
  gt-tree-scalar-evolution.h
  gt-tree-ssa-address.h
  gt-tree-ssa-loop-ivopts.h
  gt-tree-vect-generic.h
  gt-ubsan.h
  gt-varasm.h
  gt-vtable-verify.h
  auto-host.h
*/

constexpr unsigned char executable_checksum[] = { 0xcf, 0xee, 0xca, 0xc0, 0x17, 0x97, 0x80, 0x55, 0x3a, 0xdd, 0xd4, 0x1e, 0xd4, 0xb9, 0xe7, 0x91 };

[-- Attachment #3: 0001-Emit-checksum.h-from-gt-.h-and-auto-host.h.patch --]
[-- Type: text/x-patch, Size: 10340 bytes --]

From d5025b3148c895f78edaddca0637dc668ae81be9 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Fri, 23 Apr 2021 13:33:55 +0200
Subject: [PATCH] Emit checksum.h from gt-*.h and auto-host.h.

---
 gcc/Makefile.in         | 12 ++++++++----
 gcc/c-family/c-common.h |  3 ---
 gcc/c-family/c-opts.c   |  1 +
 gcc/c-family/c-pch.c    |  1 +
 gcc/c/Make-lang.in      | 20 +++-----------------
 gcc/cp/Make-lang.in     | 20 +++-----------------
 gcc/genchecksum.c       |  9 ++++++---
 gcc/objc/Make-lang.in   | 12 +++---------
 gcc/objcp/Make-lang.in  | 13 +++----------
 9 files changed, 28 insertions(+), 63 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index e5d07fb98b0..d1c2da97f52 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1765,7 +1765,7 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
  gcc-ranlib$(exeext) \
  genversion$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
  gcov-tool$(exeect) \
- gengtype$(exeext) *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a \
+ gengtype$(exeext) genchecksum$(exeext) *.[0-9][0-9].* *.[si] libbackend.a \
  libcommon-target.a libcommon.a libgcc.mk perf.data
 
 # This symlink makes the full installation name of the driver be available
@@ -2814,7 +2814,6 @@ build/genautomata.o : genautomata.c $(RTL_BASE_H) $(OBSTACK_H)		\
 build/gencheck.o : gencheck.c all-tree.def $(BCONFIG_H) $(GTM_H)	\
 	$(SYSTEM_H) $(CORETYPES_H) tree.def c-family/c-common.def	\
 	$(lang_tree_files) gimple.def
-build/genchecksum.o : genchecksum.c $(BCONFIG_H) $(SYSTEM_H) $(MD5_H)
 build/gencodes.o : gencodes.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
   $(CORETYPES_H) $(GTM_H) errors.h $(GENSUPPORT_H)
 build/genconditions.o : genconditions.c $(RTL_BASE_H) $(BCONFIG_H)	\
@@ -3037,6 +3036,13 @@ s-version: build/genversion$(build_exeext)
 	$(SHELL) $(srcdir)/../move-if-change tmp-version.h version.h
 	$(STAMP) s-version
 
+build/genchecksum.o : genchecksum.c $(BCONFIG_H) $(SYSTEM_H) $(MD5_H)
+
+checksum.h: s-checksum; @true
+s-checksum: build/genchecksum$(build_exeext) s-gtype auto-host.h
+	build/genchecksum$(build_exeext) gt-*.h auto-host.h > tmp-checksum.h
+	$(SHELL) $(srcdir)/../move-if-change tmp-checksum.h checksum.h
+
 # gcov.o needs $(ZLIBINC) added to the include flags.
 CFLAGS-gcov.o += $(ZLIBINC)
 
@@ -3505,8 +3511,6 @@ mostlyclean: lang.mostlyclean
 	-rm -f gtype-*
 	-rm -f gt-*
 	-rm -f gtype.state
-# Delete genchecksum outputs
-	-rm -f *-checksum.c
 # Delete lock-and-run bits
 	-rm -rf linkfe.lck lock-stamp.*
 
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index f30b6c6ac33..660c60b49eb 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1162,9 +1162,6 @@ extern void c_common_write_pch (void);
 extern void c_common_no_more_pch (void);
 extern void c_common_pch_pragma (cpp_reader *pfile, const char *);
 
-/* In *-checksum.c */
-extern const unsigned char executable_checksum[16];
-
 /* In c-cppbuiltin.c  */
 extern void builtin_define_std (const char *macro);
 extern void builtin_define_with_value (const char *, const char *, int);
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 89e05a4c551..4b28e107877 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "mkdeps.h"
 #include "dumpfile.h"
 #include "file-prefix-map.h"    /* add_*_prefix_map()  */
+#include "checksum.h"
 
 #ifndef DOLLARS_IN_IDENTIFIERS
 # define DOLLARS_IN_IDENTIFIERS true
diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c
index fd94c3799ac..8e1d2ffbfd5 100644
--- a/gcc/c-family/c-pch.c
+++ b/gcc/c-family/c-pch.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "c-pragma.h"
 #include "langhooks.h"
 #include "hosthooks.h"
+#include "checksum.h"
 
 /* This is a list of flag variables that must match exactly, and their
    names for the error message.  The possible values for *flag_var must
diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in
index a1cdee87264..320ab19cf31 100644
--- a/gcc/c/Make-lang.in
+++ b/gcc/c/Make-lang.in
@@ -57,7 +57,7 @@ C_AND_OBJC_OBJS = attribs.o c/c-errors.o c/c-decl.o c/c-typeck.o \
 
 # Language-specific object files for C.
 C_OBJS = c/c-lang.o c-family/stub-objc.o $(C_AND_OBJC_OBJS)
-c_OBJS = $(C_OBJS) cc1-checksum.o c/gccspec.o
+c_OBJS = $(C_OBJS) c/gccspec.o
 
 # Use strict warnings for this front end.
 c-warn = $(STRICT_WARN)
@@ -68,24 +68,10 @@ $(C_OBJS): ALL_COMPILERFLAGS += -fauto-profile=cc1.fda
 $(C_OBJS): cc1.fda
 endif
 
-# 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)
+cc1$(exeext): $(C_OBJS) checksum.h $(BACKEND) $(LIBDEPS)
 	@$(call LINK_PROGRESS,$(INDEX.c),start)
 	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
-	  cc1-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
+	  $(BACKEND) $(LIBS) $(BACKENDLIBS)
 	@$(call LINK_PROGRESS,$(INDEX.c),end)
 
 cc1.fda: ../stage1-gcc/cc1$(exeext) ../prev-gcc/$(PERF_DATA)
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 155be74efdb..b933477f849 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -112,29 +112,15 @@ endif
 # Language-specific object files for C++.
 CXX_OBJS = cp/cp-lang.o c-family/stub-objc.o $(CXX_AND_OBJCXX_OBJS)
 
-c++_OBJS = $(CXX_OBJS) cc1plus-checksum.o cp/g++spec.o
+c++_OBJS = $(CXX_OBJS) cp/g++spec.o
 
 # Use strict warnings for this front end.
 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) $(CODYLIB) $(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) $(CODYLIB) $(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) $(CODYLIB) $(LIBDEPS) $(c++.prev)
+cc1plus$(exeext): $(CXX_OBJS) checksum.h $(BACKEND) $(CODYLIB) $(LIBDEPS) $(c++.prev)
 	@$(call LINK_PROGRESS,$(INDEX.c++),start)
 	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
-	      $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(CODYLIB) $(NETLIBS) \
+	      $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(NETLIBS) \
 		$(LIBS) $(BACKENDLIBS)
 	@$(call LINK_PROGRESS,$(INDEX.c++),end)
 
diff --git a/gcc/genchecksum.c b/gcc/genchecksum.c
index 47280f5147b..c23228e68d2 100644
--- a/gcc/genchecksum.c
+++ b/gcc/genchecksum.c
@@ -110,9 +110,12 @@ main (int argc, char ** argv)
     dosum (&ctx, argv[i]);
   md5_finish_ctx (&ctx, result);
 
-  puts ("#include \"config.h\"");
-  puts ("#include \"system.h\"");
-  fputs ("EXPORTED_CONST unsigned char executable_checksum[16] = { ", stdout);
+  puts ("/* Checksum based on the following files:\n");
+  for (i = 1; i < argc; i++)
+    printf ("  %s\n", argv[i]);
+  puts ("*/\n");
+
+  fputs ("constexpr unsigned char executable_checksum[] = { ", stdout);
   for (i = 0; i < 16; i++)
     printf ("0x%02x%s", result[i], i == 15 ? " };\n" : ", ");
 
diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in
index c91148a578e..8258d877d1c 100644
--- a/gcc/objc/Make-lang.in
+++ b/gcc/objc/Make-lang.in
@@ -55,19 +55,13 @@ OBJC_OBJS = objc/objc-lang.o objc/objc-act.o hash-table.o \
    objc/objc-encoding.o \
    objc/objc-map.o
 
-objc_OBJS = $(OBJC_OBJS) cc1obj-checksum.o
+objc_OBJS = $(OBJC_OBJS)
 
-cc1obj-checksum.c : build/genchecksum$(build_exeext) checksum-options \
-        $(OBJC_OBJS) $(C_AND_OBJC_OBJS) $(BACKEND) $(LIBDEPS)
-	build/genchecksum$(build_exeext) $(OBJC_OBJS) $(C_AND_OBJC_OBJS) \
-        $(BACKEND) $(LIBDEPS) checksum-options > cc1obj-checksum.c.tmp && \
-	$(srcdir)/../move-if-change cc1obj-checksum.c.tmp cc1obj-checksum.c
-
-cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o $(BACKEND) \
+cc1obj$(exeext): $(OBJC_OBJS) version.h $(C_AND_OBJC_OBJS) $(BACKEND) \
 		 $(LIBDEPS) $(objc.prev)
 	@$(call LINK_PROGRESS,$(INDEX.objc),start)
 	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
-	      $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o \
+	      $(OBJC_OBJS) $(C_AND_OBJC_OBJS) \
 	      $(BACKEND) $(LIBS) $(BACKENDLIBS)
 	@$(call LINK_PROGRESS,$(INDEX.objc),end)
 
diff --git a/gcc/objcp/Make-lang.in b/gcc/objcp/Make-lang.in
index dfa4d230eac..dd40466cb6f 100644
--- a/gcc/objcp/Make-lang.in
+++ b/gcc/objcp/Make-lang.in
@@ -58,20 +58,13 @@ OBJCXX_OBJS = objcp/objcp-act.o objcp/objcp-lang.o objcp/objcp-decl.o \
    objcp/objc-map.o \
    $(CXX_AND_OBJCXX_OBJS)
 
-obj-c++_OBJS = $(OBJCXX_OBJS) cc1objplus-checksum.o
+obj-c++_OBJS = $(OBJCXX_OBJS)
 
-cc1objplus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
-	$(OBJCXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS)
-	build/genchecksum$(build_exeext) $(OBJCXX_OBJS) $(BACKEND) $(CODYLIB) \
-		$(LIBDEPS) checksum-options > cc1objplus-checksum.c.tmp && \
-	$(srcdir)/../move-if-change cc1objplus-checksum.c.tmp \
-	cc1objplus-checksum.c
-
-cc1objplus$(exeext): $(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) \
+cc1objplus$(exeext): $(OBJCXX_OBJS) version.h $(BACKEND) \
 		     $(CODYLIB) $(LIBDEPS) $(obj-c++.prev)
 	@$(call LINK_PROGRESS,$(INDEX.obj-c++),start)
 	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
-		$(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) \
+		$(OBJCXX_OBJS) $(BACKEND) \
 		  $(CODYLIB) $(NETLIBS) $(LIBS) $(BACKENDLIBS)
 	@$(call LINK_PROGRESS,$(INDEX.obj-c++),end)
 
-- 
2.31.1


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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-20 18:49   ` Martin Liška
  2021-04-23  7:28     ` Richard Biener
@ 2021-05-10  8:51     ` Eric Botcazou
  2021-05-10 11:40       ` Bernd Edlinger
  2021-05-10  9:01     ` Eric Botcazou
  2 siblings, 1 reply; 23+ messages in thread
From: Eric Botcazou @ 2021-05-10  8:51 UTC (permalink / raw)
  To: Richard Biener, gcc-patches, Martin Liška
  Cc: Jakub Jelinek, GCC Patches, Jan Hubicka

> Ready for master?

This breaks the build for me:

make[3]: *** No rule to make target '/home/eric/cvs/gcc/gcc/version.c', needed 
by 'ada/stamp-sdefault'.  Stop.
make[3]: *** Waiting for unfinished jobs....

-- 
Eric Botcazou



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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-20 18:49   ` Martin Liška
  2021-04-23  7:28     ` Richard Biener
  2021-05-10  8:51     ` Eric Botcazou
@ 2021-05-10  9:01     ` Eric Botcazou
  2021-05-10  9:08       ` Martin Liška
  2 siblings, 1 reply; 23+ messages in thread
From: Eric Botcazou @ 2021-05-10  9:01 UTC (permalink / raw)
  To: Martin Liška; +Cc: Richard Biener, gcc-patches, Jakub Jelinek, Jan Hubicka

> Ready for master?

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: ada/
gnatvsn.o: in function `gnatvsn__gnat_version_string':
/home/eric/cvs/gcc/gcc/ada/gnatvsn.adb:67: undefined reference to 
`version_string'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /
home/eric/cvs/gcc/gcc/ada/gnatvsn.adb:69: undefined reference to 
`version_string'
collect2: error: ld returned 1 exit status
make[3]: *** [/home/eric/cvs/gcc/gcc/ada/gcc-interface/Make-lang.in:691: 
gnatbind] Error 1
make[3]: *** Waiting for unfinished jobs....
rm gcov.pod fsf-funding.pod lto-dump.pod gfdl.pod gpl.pod cpp.pod gcov-
dump.pod gcc.pod gcov-tool.pod
make[3]: Leaving directory '/home/eric/build/gcc/native/gcc'
make[2]: *** [Makefile:4781: all-stage1-gcc] Error 2

ada/gnatvsn.adb imports version_string from version.c

-- 
Eric Botcazou




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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-10  9:01     ` Eric Botcazou
@ 2021-05-10  9:08       ` Martin Liška
  2021-05-10 15:09         ` Eric Botcazou
  2021-05-10 15:59         ` Eric Botcazou
  0 siblings, 2 replies; 23+ messages in thread
From: Martin Liška @ 2021-05-10  9:08 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: Richard Biener, gcc-patches, Jakub Jelinek, Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 5046 bytes --]

On 5/10/21 11:01 AM, Eric Botcazou wrote:
>> Ready for master?
> 
> /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: ada/
> gnatvsn.o: in function `gnatvsn__gnat_version_string':
> /home/eric/cvs/gcc/gcc/ada/gnatvsn.adb:67: undefined reference to
> `version_string'
> /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /
> home/eric/cvs/gcc/gcc/ada/gnatvsn.adb:69: undefined reference to
> `version_string'
> collect2: error: ld returned 1 exit status
> make[3]: *** [/home/eric/cvs/gcc/gcc/ada/gcc-interface/Make-lang.in:691:
> gnatbind] Error 1
> make[3]: *** Waiting for unfinished jobs....
> rm gcov.pod fsf-funding.pod lto-dump.pod gfdl.pod gpl.pod cpp.pod gcov-
> dump.pod gcc.pod gcov-tool.pod
> make[3]: Leaving directory '/home/eric/build/gcc/native/gcc'
> make[2]: *** [Makefile:4781: all-stage1-gcc] Error 2
> 
> ada/gnatvsn.adb imports version_string from version.c
> 

Sorry for the breakage. Apparently, we'll still need a version.c file in ada
folder (as it's imported in gcc/ada/gnatvsn.adb
). Using the attached patch I get to:

../../gnatbind -I../rts -I. -I/home/marxin/Programming/gcc/gcc/ada -I- -I../rts -I. -I/home/marxin/Programming/gcc/gcc/ada -static -x -x /dev/shm/objdir/gcc/ada/tools/gnatclean.ali

../../gnatlink -v gnatcmd -o ../../gnat \

   --GCC="../../xgcc -B../../ -I- -I../rts -I. -I/home/marxin/Programming/gcc/gcc/ada" --LINK="../../xg++ -B../../ -B../../../x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B../../../x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -L../../../x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L../../../x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -static-libstdc++ -static-libgcc -static-libstdc++ -static-libgcc " ../link.o ../targext.o ../../ggc-none.o ../../libcommon-target.a ../../libcommon.a ../../../libcpp/libcpp.a ../rts/libgnat.a   ../../../libbacktrace/.libs/libbacktrace.a ../../../libiberty/libiberty.a   -no-pie



GNATLINK 12.0.0 20210510 (experimental)

Copyright (C) 1995-2021, Free Software Foundation, Inc.

xgcc -c -gnatA -gnatWb -gnatiw -B../../ -I- -I../rts -I. -I/home/marxin/Programming/gcc/gcc/ada -gnatws /dev/shm/objdir/gcc/ada/tools/b~gnatcmd.adb

/dev/shm/objdir/gcc/xg++ b~gnatcmd.o ../link.o ../targext.o ../../ggc-none.o ../rts/ada.o ../rts/a-charac.o ../rts/a-chlat1.o ../rts/interfac.o ../rts/system.o ../rts/s-addope.o ../rts/s-imgint.o ../rts/s-io.o ../rts/s-parame.o ../rts/s-crtl.o ../rts/i-cstrea.o ../rts/s-stoele.o ../rts/s-stache.o ../rts/s-strhas.o ../rts/s-htable.o ../rts/s-string.o ../rts/s-traent.o ../rts/s-unstyp.o ../rts/s-imguns.o ../rts/s-wchcon.o ../rts/s-wchjis.o ../rts/s-wchcnv.o ../rts/s-carun8.o ../rts/s-conca2.o ../rts/s-traceb.o ../rts/s-excdeb.o ../rts/s-valuti.o ../rts/s-valllu.o ../rts/s-vallli.o ../rts/s-wchstw.o ../rts/a-elchha.o ../rts/a-exctra.o ../rts/s-addima.o ../rts/s-bitops.o ../rts/s-boustr.o ../rts/s-casuti.o ../rts/s-exctab.o ../rts/a-contai.o ../rts/a-ioexce.o ../rts/a-string.o ../rts/a-strmap.o ../rts/a-stmaco.o ../rts/i-c.o ../rts/s-except.o ../rts/s-excmac.o ../rts/a-chahan.o ../rts/s-exctra.o ../rts/s-memory.o ../rts/s-mmap.o ../rts/s-mmauni.o ../rts/s-mmosin.o ../rts/s-objrea.o ../rts/s-dwalin.o ../rts/s-os_lib.o ../rts/s-secsta.o ../rts/s-soliin.o ../rts/s-soflin.o ../rts/s-stalib.o ../rts/s-trasym.o ../rts/a-except.o ../rts/a-assert.o ../rts/a-comlin.o ../rts/a-tags.o ../rts/a-stream.o ../rts/gnat.o ../rts/g-htable.o ../rts/g-os_lib.o ../rts/s-ficobl.o ../rts/s-finroo.o ../rts/a-finali.o ../rts/s-fileio.o ../rts/s-vaenu8.o ../rts/a-textio.o ../rts/s-assert.o ./debug.o ./types.o ./alloc.o ./gnatvsn.o ./hostparm.o ./opt.o ./csets.o ./output.o ./rident.o ./table.o ./widechar.o ./namet.o ./fmap.o ./sdefault.o ./targparm.o ./osint.o ./switch.o ./usage.o ./gnatcmd.o ../../libcommon-target.a ../../libcommon.a ../../../libcpp/libcpp.a ../rts/libgnat.a ../../../libbacktrace/.libs/libbacktrace.a ../../../libiberty/libiberty.a -no-pie -o ../../gnat -L../rts/ -L./ -L/home/marxin/Programming/gcc/gcc/ada/ -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/12.0.0/adalib/ /dev/shm/objdir/gcc/ada/rts/libgnat.a -ldl -B../../ -B../../../x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B../../../x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -L../../../x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L../../../x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -static-libstdc++ -static-libgcc -static-libstdc++ -static-libgcc

/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: ./gnatvsn.o: in function `gnatvsn__gnat_version_string':

/home/marxin/Programming/gcc/gcc/ada/gnatvsn.adb:69: undefined reference to `gnat_version_string'

/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: /home/marxin/Programming/gcc/gcc/ada/gnatvsn.adb:67: undefined reference to `gnat_version_string'

collect2: error: ld returned 1 exit status


Do you know Eric where version.o needs to be added to be included in the problematic command line?
Thanks,
Martin

[-- Attachment #2: 0001-Fix-missing-version_string-in-Ada.patch --]
[-- Type: text/x-patch, Size: 6498 bytes --]

From ba25e961ae05e769c355e8d9ed48da457826a129 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 10 May 2021 10:22:43 +0200
Subject: [PATCH] Fix missing version_string in Ada.

---
 gcc/ada/Make-generated.in          |  2 +-
 gcc/ada/gcc-interface/Make-lang.in |  2 ++
 gcc/ada/gcc-interface/Makefile.in  |  6 +++---
 gcc/ada/gnatvsn.adb                |  2 +-
 gcc/ada/version.c                  | 34 ++++++++++++++++++++++++++++++
 5 files changed, 41 insertions(+), 5 deletions(-)
 create mode 100644 gcc/ada/version.c

diff --git a/gcc/ada/Make-generated.in b/gcc/ada/Make-generated.in
index 237444c7a26..3a65da9b962 100644
--- a/gcc/ada/Make-generated.in
+++ b/gcc/ada/Make-generated.in
@@ -87,7 +87,7 @@ ada/stamp-snames : ada/snames.ads-tmpl ada/snames.adb-tmpl ada/snames.h-tmpl ada
 	touch ada/stamp-snames
 
 ada/sdefault.adb: ada/stamp-sdefault ; @true
-ada/stamp-sdefault : $(srcdir)/version.c Makefile
+ada/stamp-sdefault : $(srcdir)/ada/version.c Makefile
 	$(ECHO) "pragma Style_Checks (Off);" >tmp-sdefault.adb
 	$(ECHO) "with Osint; use Osint;" >>tmp-sdefault.adb
 	$(ECHO) "package body Sdefault is" >>tmp-sdefault.adb
diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in
index 969022e21a7..2fb87c74d6a 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -491,6 +491,7 @@ GNAT_ADA_OBJS =	\
  ada/usage.o	\
  ada/validsw.o	\
  ada/vast.o	\
+ ada/version.o  \
  ada/warnsw.o	\
  ada/widechar.o
 
@@ -648,6 +649,7 @@ GNATBIND_OBJS = \
  ada/uintp.o      \
  ada/uname.o      \
  ada/urealp.o     \
+ ada/version.o    \
  ada/widechar.o
 
 # Language-independent object files.
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 333e2035455..b8e6b214c53 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -302,7 +302,7 @@ ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada
 	$(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
 # how to regenerate this file
-Makefile: ../config.status $(srcdir)/ada/gcc-interface/Makefile.in $(srcdir)/ada/Makefile.in $(srcdir)/version.c
+Makefile: ../config.status $(srcdir)/ada/gcc-interface/Makefile.in $(srcdir)/ada/Makefile.in $(srcdir)/ada/version.c
 	cd ..; \
 	LANGUAGES="$(CONFIG_LANGUAGES)" \
 	CONFIG_HEADERS= \
@@ -319,7 +319,7 @@ GNATLINK_OBJS = gnatlink.o \
  gnatvsn.o hostparm.o indepsw.o interfac.o i-c.o i-cstrin.o namet.o opt.o \
  osint.o output.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
  sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o \
- types.o validsw.o widechar.o
+ types.o validsw.o version.o widechar.o
 
 GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o alloc.o \
  atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o errout.o \
@@ -331,7 +331,7 @@ GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o alloc.o \
  s-purexc.o s-htable.o scil_ll.o sem_aux.o sinfo.o sinput.o sinput-c.o \
  snames.o stand.o stringt.o styleg.o stylesw.o system.o validsw.o \
  switch.o switch-m.o table.o targparm.o tempdir.o types.o uintp.o \
- uname.o urealp.o usage.o widechar.o \
+ uname.o urealp.o usage.o version.o widechar.o \
  seinfo.o einfo-entities.o einfo-utils.o sinfo-nodes.o sinfo-utils.o \
  $(EXTRA_GNATMAKE_OBJS)
 
diff --git a/gcc/ada/gnatvsn.adb b/gcc/ada/gnatvsn.adb
index 578a1aa9743..d6d2a5a3ace 100644
--- a/gcc/ada/gnatvsn.adb
+++ b/gcc/ada/gnatvsn.adb
@@ -53,7 +53,7 @@ package body Gnatvsn is
    --  version.c using the zero-based convention of the C language.
    --  The size is not the real one, which does not matter since we will
    --  check for the nul character in Gnat_Version_String.
-   pragma Import (C, Version_String, "version_string");
+   pragma Import (C, Version_String, "gnat_version_string");
 
    -------------------------
    -- Gnat_Version_String --
diff --git a/gcc/ada/version.c b/gcc/ada/version.c
new file mode 100644
index 00000000000..e6cc6124040
--- /dev/null
+++ b/gcc/ada/version.c
@@ -0,0 +1,34 @@
+/****************************************************************************
+ *                                                                          *
+ *                         GNAT COMPILER COMPONENTS                         *
+ *                                                                          *
+ *				V E R S I O N                               *
+ *                                                                          *
+ *                          C Implementation File                           *
+ *                                                                          *
+ *          Copyright (C) 2021, Free Software Foundation, Inc.         *
+ *                                                                          *
+ * GNAT is free software;  you can  redistribute it  and/or modify it under *
+ * terms of the  GNU General Public License as published  by the Free Soft- *
+ * ware  Foundation;  either version 3,  or (at your option) any later ver- *
+ * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
+ * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
+ * or FITNESS FOR A PARTICULAR PURPOSE.                                     *
+ *                                                                          *
+ * As a special exception under Section 7 of GPL version 3, you are granted *
+ * additional permissions described in the GCC Runtime Library Exception,   *
+ * version 3.1, as published by the Free Software Foundation.               *
+ *                                                                          *
+ * You should have received a copy of the GNU General Public License and    *
+ * a copy of the GCC Runtime Library Exception along with this program;     *
+ * see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    *
+ * <http://www.gnu.org/licenses/>.                                          *
+ *                                                                          *
+ * GNAT was originally developed  by the GNAT team at  New York University. *
+ * Extensive contributions were provided by Ada Core Technologies Inc.      *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "version.h"
+
+char gnat_version_string[] = version_string;
-- 
2.31.1


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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-10  8:51     ` Eric Botcazou
@ 2021-05-10 11:40       ` Bernd Edlinger
  2021-05-10 14:59         ` Eric Botcazou
  0 siblings, 1 reply; 23+ messages in thread
From: Bernd Edlinger @ 2021-05-10 11:40 UTC (permalink / raw)
  To: Eric Botcazou, Richard Biener, gcc-patches, Martin Liška
  Cc: Jakub Jelinek, Jan Hubicka

Hi Eric,

I have a slightly different issue, last week it was still okay,
but now I get (using gcc-4.8 as bootstrap compiler):

gcc -std=gnu99 -c -g  -gnatpg -gnatwns -gnata -W -Wall -nostdinc -I- -I. -Iada/generated -Iada -Iada/gcc-interface -I../../gcc-trunk/gcc/ada -I../../gcc-trunk/gcc/ada/gcc-interface -Iada/libgnat -I../../gcc-trunk/gcc/ada/libgnat ../../gcc-trunk/gcc/ada/atree.adb -o ada/atree.o
atree.adb:569:30: "Shift_Right" is not visible (more references follow)
atree.adb:569:30: non-visible declaration at interfac.ads:147
atree.adb:569:30: non-visible declaration at interfac.ads:127
atree.adb:569:30: non-visible declaration at interfac.ads:107
atree.adb:569:30: non-visible declaration at interfac.ads:87
atree.adb:569:30: non-visible declaration at s-unstyp.ads:220
atree.adb:569:30: non-visible declaration at s-unstyp.ads:200
atree.adb:569:30: non-visible declaration at s-unstyp.ads:180
atree.adb:569:30: non-visible declaration at s-unstyp.ads:160
atree.adb:569:30: non-visible declaration at s-unstyp.ads:140
atree.adb:569:30: non-visible declaration at s-unstyp.ads:120
atree.adb:631:26: "Shift_Left" is not visible (more references follow)
atree.adb:631:26: non-visible declaration at interfac.ads:143
atree.adb:631:26: non-visible declaration at interfac.ads:123
atree.adb:631:26: non-visible declaration at interfac.ads:103
atree.adb:631:26: non-visible declaration at interfac.ads:83
atree.adb:631:26: non-visible declaration at s-unstyp.ads:216
atree.adb:631:26: non-visible declaration at s-unstyp.ads:196
atree.adb:631:26: non-visible declaration at s-unstyp.ads:176
atree.adb:631:26: non-visible declaration at s-unstyp.ads:156
atree.adb:631:26: non-visible declaration at s-unstyp.ads:136
atree.adb:631:26: non-visible declaration at s-unstyp.ads:116
make[3]: *** [ada/atree.o] Error 1
make[3]: *** Waiting for unfinished jobs....


On 5/10/21 10:51 AM, Eric Botcazou wrote:
>> Ready for master?
> 
> This breaks the build for me:
> 
> make[3]: *** No rule to make target '/home/eric/cvs/gcc/gcc/version.c', needed 
> by 'ada/stamp-sdefault'.  Stop.
> make[3]: *** Waiting for unfinished jobs....
> 


Thanks
Bernd.

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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-10 11:40       ` Bernd Edlinger
@ 2021-05-10 14:59         ` Eric Botcazou
  0 siblings, 0 replies; 23+ messages in thread
From: Eric Botcazou @ 2021-05-10 14:59 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches

> I have a slightly different issue, last week it was still okay,
> but now I get (using gcc-4.8 as bootstrap compiler):
> 
> gcc -std=gnu99 -c -g  -gnatpg -gnatwns -gnata -W -Wall -nostdinc -I- -I.
> -Iada/generated -Iada -Iada/gcc-interface -I../../gcc-trunk/gcc/ada
> -I../../gcc-trunk/gcc/ada/gcc-interface -Iada/libgnat
> -I../../gcc-trunk/gcc/ada/libgnat ../../gcc-trunk/gcc/ada/atree.adb -o
> ada/atree.o atree.adb:569:30: "Shift_Right" is not visible (more references
> follow) atree.adb:569:30: non-visible declaration at interfac.ads:147
> atree.adb:569:30: non-visible declaration at interfac.ads:127
> atree.adb:569:30: non-visible declaration at interfac.ads:107
> atree.adb:569:30: non-visible declaration at interfac.ads:87
> atree.adb:569:30: non-visible declaration at s-unstyp.ads:220
> atree.adb:569:30: non-visible declaration at s-unstyp.ads:200
> atree.adb:569:30: non-visible declaration at s-unstyp.ads:180
> atree.adb:569:30: non-visible declaration at s-unstyp.ads:160
> atree.adb:569:30: non-visible declaration at s-unstyp.ads:140
> atree.adb:569:30: non-visible declaration at s-unstyp.ads:120
> atree.adb:631:26: "Shift_Left" is not visible (more references follow)
> atree.adb:631:26: non-visible declaration at interfac.ads:143
> atree.adb:631:26: non-visible declaration at interfac.ads:123
> atree.adb:631:26: non-visible declaration at interfac.ads:103
> atree.adb:631:26: non-visible declaration at interfac.ads:83
> atree.adb:631:26: non-visible declaration at s-unstyp.ads:216
> atree.adb:631:26: non-visible declaration at s-unstyp.ads:196
> atree.adb:631:26: non-visible declaration at s-unstyp.ads:176
> atree.adb:631:26: non-visible declaration at s-unstyp.ads:156
> atree.adb:631:26: non-visible declaration at s-unstyp.ads:136
> atree.adb:631:26: non-visible declaration at s-unstyp.ads:116
> make[3]: *** [ada/atree.o] Error 1
> make[3]: *** Waiting for unfinished jobs....

Yes, the merge is incomplete, temporarily replace

      pragma Provide_Shift_Operators (Slot);

in atree.ads with

      function Shift_Left (S : Slot; V : Natural) return Slot;
      pragma Import (Intrinsic, Shift_Left);

      function Shift_Right (S : Slot; V : Natural) return Slot;
      pragma Import (Intrinsic, Shift_Right);

-- 
Eric Botcazou




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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-10  9:08       ` Martin Liška
@ 2021-05-10 15:09         ` Eric Botcazou
  2021-05-10 15:59         ` Eric Botcazou
  1 sibling, 0 replies; 23+ messages in thread
From: Eric Botcazou @ 2021-05-10 15:09 UTC (permalink / raw)
  To: Martin Liška; +Cc: Richard Biener, gcc-patches, Jakub Jelinek, Jan Hubicka

> Do you know Eric where version.o needs to be added to be included in the
> problematic command line?

Presumably to the beginning of TOOLS_LIBS in ada/gcc-interface/Makefile.in:

TOOLS_LIBS = ../version.o ../link.o ../targext.o ../../ggc-none.o \

-- 
Eric Botcazou



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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-10  9:08       ` Martin Liška
  2021-05-10 15:09         ` Eric Botcazou
@ 2021-05-10 15:59         ` Eric Botcazou
  2021-05-10 19:11           ` Martin Liška
  1 sibling, 1 reply; 23+ messages in thread
From: Eric Botcazou @ 2021-05-10 15:59 UTC (permalink / raw)
  To: Martin Liška; +Cc: Richard Biener, gcc-patches, Jakub Jelinek, Jan Hubicka

> Do you know Eric where version.o needs to be added to be included in the
> problematic command line?

You can presumably remove it from GNATLINK_OBJS & GNATMAKE_OBJS.  And it needs 
to be added to GNAT1_C_OBJS instead of GNAT_ADA_OBJS in Make-lang.in.

-- 
Eric Botcazou




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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-10 15:59         ` Eric Botcazou
@ 2021-05-10 19:11           ` Martin Liška
  2021-05-10 20:06             ` Eric Botcazou
  0 siblings, 1 reply; 23+ messages in thread
From: Martin Liška @ 2021-05-10 19:11 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: Richard Biener, gcc-patches, Jakub Jelinek, Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 389 bytes --]

On 5/10/21 5:59 PM, Eric Botcazou wrote:
>> Do you know Eric where version.o needs to be added to be included in the
>> problematic command line?
> 
> You can presumably remove it from GNATLINK_OBJS & GNATMAKE_OBJS.  And it needs
> to be added to GNAT1_C_OBJS instead of GNAT_ADA_OBJS in Make-lang.in.
> 

Thank you Eric.

The following patch fixes that, ready for master?

Thanks,
Martin

[-- Attachment #2: 0001-Fix-missing-version_string-in-Ada.patch --]
[-- Type: text/x-patch, Size: 6772 bytes --]

From 217785ed3df1d959498e7668b577606a9f5b51e2 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 10 May 2021 10:22:43 +0200
Subject: [PATCH] Fix missing version_string in Ada.

gcc/ada/ChangeLog:

	PR bootstrap/100506
	* Make-generated.in: Replace version.c with ada/version.c.
	* gcc-interface/Make-lang.in: Add version.o to GNAT1_C_OBJS.
	Add version.o to GNAT_ADA_OBJS and GNATBIND_OBJS.
	* gcc-interface/Makefile.in: Add version.o to TOOLS_LIBS.
	* gnatvsn.adb: Start using a new C symbol gnat_version_string.
	* version.c: New file.
---
 gcc/ada/Make-generated.in          |  2 +-
 gcc/ada/gcc-interface/Make-lang.in |  4 +++-
 gcc/ada/gcc-interface/Makefile.in  |  4 ++--
 gcc/ada/gnatvsn.adb                |  2 +-
 gcc/ada/version.c                  | 34 ++++++++++++++++++++++++++++++
 5 files changed, 41 insertions(+), 5 deletions(-)
 create mode 100644 gcc/ada/version.c

diff --git a/gcc/ada/Make-generated.in b/gcc/ada/Make-generated.in
index 237444c7a26..3a65da9b962 100644
--- a/gcc/ada/Make-generated.in
+++ b/gcc/ada/Make-generated.in
@@ -87,7 +87,7 @@ ada/stamp-snames : ada/snames.ads-tmpl ada/snames.adb-tmpl ada/snames.h-tmpl ada
 	touch ada/stamp-snames
 
 ada/sdefault.adb: ada/stamp-sdefault ; @true
-ada/stamp-sdefault : $(srcdir)/version.c Makefile
+ada/stamp-sdefault : $(srcdir)/ada/version.c Makefile
 	$(ECHO) "pragma Style_Checks (Off);" >tmp-sdefault.adb
 	$(ECHO) "with Osint; use Osint;" >>tmp-sdefault.adb
 	$(ECHO) "package body Sdefault is" >>tmp-sdefault.adb
diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in
index 969022e21a7..c8c02d3f795 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -247,7 +247,8 @@ GNAT1_C_OBJS = ada/adadecode.o ada/adaint.o ada/argv.o ada/cio.o \
  ada/cstreams.o ada/env.o ada/init.o ada/initialize.o ada/raise.o \
  ada/raise-gcc.o \
  ada/seh_init.o ada/targext.o ada/cuintp.o ada/decl.o ada/rtfinal.o \
- ada/rtinit.o ada/misc.o ada/utils.o ada/utils2.o ada/trans.o ada/targtyps.o
+ ada/rtinit.o ada/misc.o ada/utils.o ada/utils2.o ada/trans.o ada/targtyps.o \
+ ada/version.o
 
 # Object files from Ada sources that are used by gnat1
 GNAT_ADA_OBJS =	\
@@ -648,6 +649,7 @@ GNATBIND_OBJS = \
  ada/uintp.o      \
  ada/uname.o      \
  ada/urealp.o     \
+ ada/version.o    \
  ada/widechar.o
 
 # Language-independent object files.
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 333e2035455..2598cea2b19 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -250,7 +250,7 @@ LIBS = $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) $(LIBIBERTY) $(SYSLIBS)
 LIBDEPS = $(LIBINTL_DEP) $(LIBICONV_DEP) $(LIBBACKTRACE) $(LIBIBERTY)
 # Default is no TGT_LIB; one might be passed down or something
 TGT_LIB =
-TOOLS_LIBS = ../link.o ../targext.o ../../ggc-none.o ../../libcommon-target.a \
+TOOLS_LIBS = ../version.o ../link.o ../targext.o ../../ggc-none.o ../../libcommon-target.a \
   ../../libcommon.a ../../../libcpp/libcpp.a $(LIBGNAT) $(LIBINTL) $(LIBICONV) \
   ../$(LIBBACKTRACE) ../$(LIBIBERTY) $(SYSLIBS) $(TGT_LIB)
 
@@ -302,7 +302,7 @@ ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada
 	$(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
 # how to regenerate this file
-Makefile: ../config.status $(srcdir)/ada/gcc-interface/Makefile.in $(srcdir)/ada/Makefile.in $(srcdir)/version.c
+Makefile: ../config.status $(srcdir)/ada/gcc-interface/Makefile.in $(srcdir)/ada/Makefile.in $(srcdir)/ada/version.c
 	cd ..; \
 	LANGUAGES="$(CONFIG_LANGUAGES)" \
 	CONFIG_HEADERS= \
diff --git a/gcc/ada/gnatvsn.adb b/gcc/ada/gnatvsn.adb
index 578a1aa9743..d6d2a5a3ace 100644
--- a/gcc/ada/gnatvsn.adb
+++ b/gcc/ada/gnatvsn.adb
@@ -53,7 +53,7 @@ package body Gnatvsn is
    --  version.c using the zero-based convention of the C language.
    --  The size is not the real one, which does not matter since we will
    --  check for the nul character in Gnat_Version_String.
-   pragma Import (C, Version_String, "version_string");
+   pragma Import (C, Version_String, "gnat_version_string");
 
    -------------------------
    -- Gnat_Version_String --
diff --git a/gcc/ada/version.c b/gcc/ada/version.c
new file mode 100644
index 00000000000..e6cc6124040
--- /dev/null
+++ b/gcc/ada/version.c
@@ -0,0 +1,34 @@
+/****************************************************************************
+ *                                                                          *
+ *                         GNAT COMPILER COMPONENTS                         *
+ *                                                                          *
+ *				V E R S I O N                               *
+ *                                                                          *
+ *                          C Implementation File                           *
+ *                                                                          *
+ *          Copyright (C) 2021, Free Software Foundation, Inc.         *
+ *                                                                          *
+ * GNAT is free software;  you can  redistribute it  and/or modify it under *
+ * terms of the  GNU General Public License as published  by the Free Soft- *
+ * ware  Foundation;  either version 3,  or (at your option) any later ver- *
+ * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
+ * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
+ * or FITNESS FOR A PARTICULAR PURPOSE.                                     *
+ *                                                                          *
+ * As a special exception under Section 7 of GPL version 3, you are granted *
+ * additional permissions described in the GCC Runtime Library Exception,   *
+ * version 3.1, as published by the Free Software Foundation.               *
+ *                                                                          *
+ * You should have received a copy of the GNU General Public License and    *
+ * a copy of the GCC Runtime Library Exception along with this program;     *
+ * see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    *
+ * <http://www.gnu.org/licenses/>.                                          *
+ *                                                                          *
+ * GNAT was originally developed  by the GNAT team at  New York University. *
+ * Extensive contributions were provided by Ada Core Technologies Inc.      *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "version.h"
+
+char gnat_version_string[] = version_string;
-- 
2.31.1


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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-10 19:11           ` Martin Liška
@ 2021-05-10 20:06             ` Eric Botcazou
  0 siblings, 0 replies; 23+ messages in thread
From: Eric Botcazou @ 2021-05-10 20:06 UTC (permalink / raw)
  To: Martin Liška; +Cc: Richard Biener, gcc-patches, Jakub Jelinek, Jan Hubicka

> The following patch fixes that, ready for master?

Sure, thanks!

-- 
Eric Botcazou



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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-04-23 11:37               ` Martin Liška
@ 2021-05-11  6:46                 ` Martin Liška
  2021-05-11  7:49                   ` Richard Biener
  0 siblings, 1 reply; 23+ messages in thread
From: Martin Liška @ 2021-05-11  6:46 UTC (permalink / raw)
  To: Richard Biener, Jan Hubicka; +Cc: Jakub Jelinek, GCC Patches

On 4/23/21 1:37 PM, Martin Liška wrote:
> On 4/23/21 12:59 PM, Richard Biener wrote:
>> True, the question is on how much detail we have to pay attention to.
> 
> Agree with that.
> 
>> For us of course the build-id solution works fine.  And hopefully the
>> days of PCH are counted...
> 
> Yes.
> 
> I have a tentative patch that emits the attached checksum.h header file.
> We also include flags in the checksum:
> 
> ...
>           build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
> 
>                       checksum-options > cc1-checksum.c.tmp &&           \
> 
> ...
> 
> $ cat checksum-options
> 
> g++ -no-pie   -g   -DIN_GCC -fPIC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc
> 
> Can we ignore them in the checksum calculation?
> Martin
> 

Richi, what do you think about this part?

Thanks,
Martin

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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-11  6:46                 ` Martin Liška
@ 2021-05-11  7:49                   ` Richard Biener
  2021-05-11 13:33                     ` Martin Liška
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Biener @ 2021-05-11  7:49 UTC (permalink / raw)
  To: Martin Liška; +Cc: Jan Hubicka, Jakub Jelinek, GCC Patches

On Tue, May 11, 2021 at 8:46 AM Martin Liška <mliska@suse.cz> wrote:
>
> On 4/23/21 1:37 PM, Martin Liška wrote:
> > On 4/23/21 12:59 PM, Richard Biener wrote:
> >> True, the question is on how much detail we have to pay attention to.
> >
> > Agree with that.
> >
> >> For us of course the build-id solution works fine.  And hopefully the
> >> days of PCH are counted...
> >
> > Yes.
> >
> > I have a tentative patch that emits the attached checksum.h header file.
> > We also include flags in the checksum:
> >
> > ...
> >           build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
> >
> >                       checksum-options > cc1-checksum.c.tmp &&           \
> >
> > ...
> >
> > $ cat checksum-options
> >
> > g++ -no-pie   -g   -DIN_GCC -fPIC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc
> >
> > Can we ignore them in the checksum calculation?
> > Martin
> >
>
> Richi, what do you think about this part?

We included the linker options in checksumming when changing from checksumming
cc1 to its object files.  I can't find any reasoning other than
mimicing what was there
before.  I wonder how the details of the host binary build influence
PCH validity - can
you make an experiment and (with fixed PCH checksum) try to load a PCH file
generated with the stage1 compiler with the stage3 compiler?  (thus -O0 vs -O2
or even LTO for LTO bootstrap)?  That is, we're concerned about layout and
semantics of the data structures participating in PCH but since the layout is
exposed no option should change it.

Note this also means that we should be able to share the checksum for all
stages (removing the odd comparison failures on frontend binaries).  Some
configury might change the layout so the stage1 PCH could in theory be
not compatible with the stage2+ one.

I wonder if we can instead upstream the build-id use and conditionalize
the checksum stuff on some configury?  Some people do seem worried
about "weakening" the checksum.

Richard.

> Thanks,
> Martin

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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-11  7:49                   ` Richard Biener
@ 2021-05-11 13:33                     ` Martin Liška
  2021-05-11 13:38                       ` Jakub Jelinek
  0 siblings, 1 reply; 23+ messages in thread
From: Martin Liška @ 2021-05-11 13:33 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jan Hubicka, Jakub Jelinek, GCC Patches

On 5/11/21 9:49 AM, Richard Biener wrote:
> I wonder if we can instead upstream the build-id use and conditionalize
> the checksum stuff on some configury?  Some people do seem worried
> about "weakening" the checksum.

I like the build-id approach. Can we please upstream it?

If it's not feasible then we can consider using my approach.

Martin

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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-11 13:33                     ` Martin Liška
@ 2021-05-11 13:38                       ` Jakub Jelinek
  2021-05-11 13:40                         ` Richard Biener
  0 siblings, 1 reply; 23+ messages in thread
From: Jakub Jelinek @ 2021-05-11 13:38 UTC (permalink / raw)
  To: Martin Liška; +Cc: Richard Biener, Jan Hubicka, GCC Patches

On Tue, May 11, 2021 at 03:33:58PM +0200, Martin Liška wrote:
> On 5/11/21 9:49 AM, Richard Biener wrote:
> > I wonder if we can instead upstream the build-id use and conditionalize
> > the checksum stuff on some configury?  Some people do seem worried
> > about "weakening" the checksum.
> 
> I like the build-id approach. Can we please upstream it?

Not all hosts support build ids...
So there needs to be an alternative for those.

	Jakub


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

* Re: [PATCH] Bump LTO_major_version to 11.
  2021-05-11 13:38                       ` Jakub Jelinek
@ 2021-05-11 13:40                         ` Richard Biener
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Biener @ 2021-05-11 13:40 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Martin Liška, Jan Hubicka, GCC Patches

On Tue, May 11, 2021 at 3:39 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Tue, May 11, 2021 at 03:33:58PM +0200, Martin Liška wrote:
> > On 5/11/21 9:49 AM, Richard Biener wrote:
> > > I wonder if we can instead upstream the build-id use and conditionalize
> > > the checksum stuff on some configury?  Some people do seem worried
> > > about "weakening" the checksum.
> >
> > I like the build-id approach. Can we please upstream it?
>
> Not all hosts support build ids...
> So there needs to be an alternative for those.

Well, just keep the old code for those.

Until PCH dies.

Richard.

>         Jakub
>

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

end of thread, other threads:[~2021-05-11 13:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  9:57 [PATCH] Bump LTO_major_version to 11 Martin Liška
2021-04-20 12:46 ` Richard Biener
2021-04-20 18:49   ` Martin Liška
2021-04-23  7:28     ` Richard Biener
2021-04-23  7:59       ` Martin Liška
2021-04-23  9:37         ` Richard Biener
2021-04-23  9:51           ` Jan Hubicka
2021-04-23 10:59             ` Richard Biener
2021-04-23 11:37               ` Martin Liška
2021-05-11  6:46                 ` Martin Liška
2021-05-11  7:49                   ` Richard Biener
2021-05-11 13:33                     ` Martin Liška
2021-05-11 13:38                       ` Jakub Jelinek
2021-05-11 13:40                         ` Richard Biener
2021-05-10  8:51     ` Eric Botcazou
2021-05-10 11:40       ` Bernd Edlinger
2021-05-10 14:59         ` Eric Botcazou
2021-05-10  9:01     ` Eric Botcazou
2021-05-10  9:08       ` Martin Liška
2021-05-10 15:09         ` Eric Botcazou
2021-05-10 15:59         ` Eric Botcazou
2021-05-10 19:11           ` Martin Liška
2021-05-10 20:06             ` Eric Botcazou

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).