From 0f2da02b2373078e96bb44fe83f5b7fd303414a6 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 8 Dec 2020 04:59:09 -0800 Subject: [PATCH] c++: Add module includes gcc/cp/ * Make-lang.in (MODULE_VERSION): Define. * module.cc: Add includes. --- gcc/cp/Make-lang.in | 9 +++++++++ gcc/cp/module.cc | 47 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index ebfdc902192..d7dc0dec2b8 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -57,6 +57,15 @@ CFLAGS-cp/g++spec.o += $(DRIVER_DEFINES) CFLAGS-cp/module.o += -DHOST_MACHINE=\"$(host)\" \ -DTARGET_MACHINE=\"$(target)\" +ifeq ($(DEVPHASE_c),experimental) +# Some date's don't grok 'r', if so, simply use today's +# date (don't bootstrap at midnight). +MODULE_VERSION := $(shell date -r $(srcdir)/cp/module.cc '+%y%m%d-%H%M' \ + 2>/dev/null || date '+%y%m%d-0000' 2>/dev/null || echo 0) + +CFLAGS-cp/module.o += -DMODULE_VERSION='($(subst -,,$(MODULE_VERSION))U)' +endif + # Create the compiler driver for g++. GXX_OBJS = $(GCC_OBJS) cp/g++spec.o xg++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 596061b3c49..f250d6c1819 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -18,4 +18,49 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ -/* This file intentionally left empty. */ +/* This file intentionally left empty of all but barest minium. */ + +/* In expermental (trunk) sources, MODULE_VERSION is a #define passed + in from the Makefile. It records the modification date of the + source directory -- that's the only way to stay sane. In release + sources, we (plan to) use the compiler's major.minor versioning. + While the format might not change between at minor versions, it + seems simplest to tie the two together. There's no concept of + inter-version compatibility. */ +#define IS_EXPERIMENTAL(V) ((V) >= (1U << 20)) +#define MODULE_MAJOR(V) ((V) / 10000) +#define MODULE_MINOR(V) ((V) % 10000) +#define EXPERIMENT(A,B) (IS_EXPERIMENTAL (MODULE_VERSION) ? (A) : (B)) +#ifndef MODULE_VERSION +#error "Shtopp! What are you doing? This is not ready yet." +#include "bversion.h" +#define MODULE_VERSION (BUILDING_GCC_MAJOR * 10000U + BUILDING_GCC_MINOR) +#elif !IS_EXPERIMENTAL (MODULE_VERSION) +#error "This is not the version I was looking for." +#endif + +#define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available. */ +#include "config.h" + +#include "system.h" +#include "coretypes.h" +#include "cp-tree.h" +#include "timevar.h" +#include "stringpool.h" +#include "dumpfile.h" +#include "bitmap.h" +#include "cgraph.h" +#include "tree-iterator.h" +#include "cpplib.h" +#include "mkdeps.h" +#include "incpath.h" +#include "libiberty.h" +#include "stor-layout.h" +#include "version.h" +#include "tree-diagnostic.h" +#include "toplev.h" +#include "opts.h" +#include "attribs.h" +#include "intl.h" +#include "langhooks.h" + -- 2.30.2