diff mbox series

c++: Add module includes

Message ID 7934072c-5508-e9dd-54e9-ae36fde22640@acm.org
State New
Headers show
Series c++: Add module includes | expand

Commit Message

Nathan Sidwell Dec. 8, 2020, 1:01 p.m. UTC
This adds MODULE_VERSION to the makefile, so it's generated from the 
date of the module.cc file in development.  Also adds the include files 
to module.cc

         gcc/cp/
         * Make-lang.in (MODULE_VERSION): Define.
         * module.cc: Add includes.

pushing to trunk

Comments

Nathan Sidwell Dec. 8, 2020, 2:35 p.m. UTC | #1
On 12/8/20 8:01 AM, Nathan Sidwell wrote:
> This adds MODULE_VERSION to the makefile, so it's generated from the 
> date of the module.cc file in development.  Also adds the include files 
> to module.cc

It broke :(


c++: Fix MODULE_VERSION	breakage

Adding includes	to module.cc triggered the kind	of build failure I
wanted to check for.  In this case it was MODULE_VERSION not being
defined, and module.cc's internal #error triggering.  I've relaxed the
check in Make-lang, so we proviude MODULE_VERSION when DEVPHASE is not
empty (rather than when it is 'experimental').  AFAICT devphase is
empty for release builds, and the #error will force us to decide
whether modules is sufficiently baked at that point.

	gcc/cp
         * Make-lang.in (MODULE_VERSION): Override when DEVPHASE	not empty.
         * module.cc: Comment.
diff mbox series

Patch

diff --git i/gcc/cp/Make-lang.in w/gcc/cp/Make-lang.in
index ebfdc902192..d7dc0dec2b8 100644
--- i/gcc/cp/Make-lang.in
+++ w/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 i/gcc/cp/module.cc w/gcc/cp/module.cc
index 596061b3c49..f250d6c1819 100644
--- i/gcc/cp/module.cc
+++ w/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
 <http://www.gnu.org/licenses/>.  */
 
-/* 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"
+