[PATCH] Bump LTO_major_version

2014-04-15 Thread Richard Biener

This bumps LTO_major_version on trunk to avoid ICEing when
accidentially mixing objects with 4.9 ones.  We'll soon start
to diverge (if we didn't already).

Committed.

Richard.

2014-04-15  Richard Biener  

* lto-streamer.h (LTO_major_version): Bump to 4.

Index: gcc/lto-streamer.h
===
--- gcc/lto-streamer.h  (revision 209415)
+++ gcc/lto-streamer.h  (working copy)
@@ -140,7 +140,7 @@ along with GCC; see the file COPYING3.
sections a '.' and the section type are appended.  */
 #define LTO_SECTION_NAME_PREFIX ".gnu.lto_"
 
-#define LTO_major_version 3
+#define LTO_major_version 4
 #define LTO_minor_version 0
 
 typedef unsigned char  lto_decl_flags_t;


[PATCH] Bump LTO_major_version on trunk

2015-06-29 Thread Richard Biener

Was still the same as on the GCC 5 branch.

Committed as obvious.

Richard.

2015-06-29  Richard Biener  

* lto-streamer.h (LTO_major_version): Bump to 5.

Index: gcc/lto-streamer.h
===
--- gcc/lto-streamer.h  (revision 225112)
+++ gcc/lto-streamer.h  (working copy)
@@ -130,7 +130,7 @@ along with GCC; see the file COPYING3.
  String are represented in the table as pairs, a length in ULEB128
  form followed by the data for the string.  */
 
-#define LTO_major_version 4
+#define LTO_major_version 5
 #define LTO_minor_version 0
 
 typedef unsigned char  lto_decl_flags_t;


[PATCH] Bump LTO_major_version on trunk

2018-04-25 Thread Richard Biener

This bumps the bytecode version.

Committed to trunk.

Richard.

2018-04-25  Richard Biener  

* lto-streamer.h (LTO_major_version): Bump to 8.

Index: gcc/lto-streamer.h
===
--- gcc/lto-streamer.h  (revision 259637)
+++ gcc/lto-streamer.h  (working copy)
@@ -120,7 +120,7 @@ along with GCC; see the file COPYING3.
  String are represented in the table as pairs, a length in ULEB128
  form followed by the data for the string.  */
 
-#define LTO_major_version 7
+#define LTO_major_version 8
 #define LTO_minor_version 0
 
 typedef unsigned char  lto_decl_flags_t;


[PATCH] Bump LTO_major_version to 11.

2021-04-20 Thread Martin Liška
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



Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Eric Botcazou
> 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





Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Eric Botcazou
> 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




Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Eric Botcazou
> 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





Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Martin Liška

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
>From 217785ed3df1d959498e7668b577606a9f5b51e2 Mon Sep 17 00:00:00 2001
From: Martin Liska 
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 000..e6cc6124040
--- /dev/null
+++ b/gcc/ada/version.c
@@ -0,0 +1,34 @@
+/
+ *  *
+ * GNAT COMPILER COMPONENTS *
+ *   

Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Eric Botcazou
> The following patch fixes that, ready for master?

Sure, thanks!

-- 
Eric Botcazou




Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Martin Liška

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


Re: [PATCH] Bump LTO_major_version to 11.

2021-05-11 Thread Richard Biener via Gcc-patches
On Tue, May 11, 2021 at 8:46 AM Martin Liška  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


Re: [PATCH] Bump LTO_major_version to 11.

2021-05-11 Thread Martin Liška

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


Re: [PATCH] Bump LTO_major_version to 11.

2021-05-11 Thread Jakub Jelinek via 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



Re: [PATCH] Bump LTO_major_version to 11.

2021-05-11 Thread Richard Biener via Gcc-patches
On Tue, May 11, 2021 at 3:39 PM Jakub Jelinek  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
>


Re: [PATCH] Bump LTO_major_version to 11.

2021-04-20 Thread Richard Biener via Gcc-patches
On Tue, Apr 20, 2021 at 11:57 AM Martin Liška  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
>


Re: [PATCH] Bump LTO_major_version to 11.

2021-04-20 Thread Martin Liška
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 ""

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

#endif /* VERSION_H */

Ready for master?
Thanks,
Martin
>From 86d1946449de8aec5e71030f6c7c48010e83cd67 Mon Sep 17 00:00:00 2001
From: Martin Liska 
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
+	$(MACHMOD

Re: [PATCH] Bump LTO_major_version to 11.

2021-04-23 Thread Richard Biener via Gcc-patches
On Tue, Apr 20, 2021 at 8:49 PM Martin Liška  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 ""
>
> #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


Re: [PATCH] Bump LTO_major_version to 11.

2021-04-23 Thread Martin Liška
On 4/23/21 9:28 AM, Richard Biener wrote:
> On Tue, Apr 20, 2021 at 8:49 PM Martin Liška  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 ""
>>
>> #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

04 tree db613554ec17462c63bace2015c877d6bed70bbegcc

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

100644 blob bae5757ad137c0af58dbe66229d4201a45094acagcc/c/c-aux-info.c

100644 blob d0035a31723447657a04c2ef79c9fd7c0ddc7568gcc/c/c-convert.c

100644 blob 3ea4708c5075d9274601a0676f86a6900a9345b0gcc/c/c-decl.c

100644 blob de98958ceabac9d631f937f9f28547d8aed26af2gcc/c/c-errors.c

100644 blob 68c74cc1eb2ef908545b36e2dbff65606f756e15gcc/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



Re: [PATCH] Bump LTO_major_version to 11.

2021-04-23 Thread Richard Biener via Gcc-patches
On Fri, Apr 23, 2021 at 9:59 AM Martin Liška  wrote:
>
> On 4/23/21 9:28 AM, Richard Biener wrote:
> > On Tue, Apr 20, 2021 at 8:49 PM Martin Liška  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 ""
> >>
> >> #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
>
> 04 tree db613554ec17462c63bace2015c877d6bed70bbegcc
>
> One can do that per-file as well:
> git ls-tree HEAD -- gcc/c/*.c
>
> 100644 blob bae5757ad137c0af58dbe66229d4201a45094acagcc/c/c-aux-info.c
>
> 100644 blob d0035a31723447657a04c2ef79c9fd7c0ddc7568gcc/c/c-convert.c
>
> 100644 blob 3ea4708c5075d9274601a0676f86a6900a9345b0gcc/c/c-decl.c
>
> 100644 blob de98958ceabac9d631f937f9f28547d8aed26af2gcc/c/c-errors.c
>
> 100644 blob 68c74cc1eb2ef908545b36e2dbff65606f756e15gcc/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
>
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 
+
+#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_names

Re: [PATCH] Bump LTO_major_version to 11.

2021-04-23 Thread Jan Hubicka
> > 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 
> +
> +#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", re

Re: [PATCH] Bump LTO_major_version to 11.

2021-04-23 Thread Richard Biener via Gcc-patches
On Fri, Apr 23, 2021 at 11:51 AM Jan Hubicka  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 
> > +
> > +#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/genchecks

Re: [PATCH] Bump LTO_major_version to 11.

2021-04-23 Thread Martin Liška
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
/* 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 };
>From d5025b3148c895f78edaddca0637dc668ae81be9 Mon Sep 17 00:00:00 2001
From: Martin Liska 
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,1

Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Eric Botcazou
> 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




Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Eric Botcazou
> 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





Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Martin Liška

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,
Mart

Re: [PATCH] Bump LTO_major_version to 11.

2021-05-10 Thread Bernd Edlinger
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.