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.
This commit is contained in:
Martin Liska 2021-04-20 16:56:07 +02:00
parent 79a27f32df
commit e3a682f419
9 changed files with 55 additions and 104 deletions

View File

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

View File

@ -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)
@ -1712,7 +1712,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
@ -1764,7 +1764,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
@ -2145,7 +2145,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
@ -2334,12 +2334,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)
@ -2756,7 +2750,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 \
@ -2770,16 +2764,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
@ -2958,10 +2942,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)
@ -3040,20 +3024,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)

View File

@ -231,11 +231,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) \

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -201,7 +201,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);
@ -210,7 +210,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;