From ff41abdca0ab9993b6170b9b1f46b3a40921f1b0 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 16 May 2024 16:09:12 -0400 Subject: c++: add module extensions There is a trend in the broader C++ community to use a different extension for module interface units, even though (in GCC) they are compiled in the same way as other source files. Let's recognize these extensions as C++. .ixx is the MSVC standard, while the .c*m are supported by Clang. libc++ standard headers use .cppm, as their other source files use .cpp. Perhaps libstdc++ might use .ccm for parallel consistency? One issue with .c++m is that libcpp/mkdeps.cc has been using it for the phony dependencies to express module dependencies, so I'm changing mkdeps to something less likely to be an actual file, ".c++-module". gcc/cp/ChangeLog: * lang-specs.h: Add module interface extensions. gcc/ChangeLog: * doc/invoke.texi: Update module extension docs. libcpp/ChangeLog: * mkdeps.cc (make_write): Change .c++m to .c++-module. gcc/testsuite/ChangeLog: * g++.dg/modules/dep-1_a.C * g++.dg/modules/dep-1_b.C * g++.dg/modules/dep-2.C: Change .c++m to .c++-module. --- libcpp/mkdeps.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'libcpp') diff --git a/libcpp/mkdeps.cc b/libcpp/mkdeps.cc index 4cf0cf0..622d0dc 100644 --- a/libcpp/mkdeps.cc +++ b/libcpp/mkdeps.cc @@ -411,8 +411,7 @@ make_write_vec (const mkdeps::vec &vec, FILE *fp, return col; } -/* Write the dependencies to a Makefile. If PHONY is true, add - .PHONY targets for all the dependencies too. */ +/* Write the dependencies to a Makefile. */ static void make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) @@ -453,7 +452,7 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) column = make_write_name (d->cmi_name, fp, column, colmax); fputs (":", fp); column++; - column = make_write_vec (d->modules, fp, column, colmax, 0, ".c++m"); + column = make_write_vec (d->modules, fp, column, colmax, 0, ".c++-module"); fputs ("\n", fp); } @@ -463,7 +462,7 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) { /* module-name : cmi-name */ column = make_write_name (d->module_name, fp, 0, colmax, - true, ".c++m"); + true, ".c++-module"); fputs (":", fp); column++; column = make_write_name (d->cmi_name, fp, column, colmax); @@ -471,7 +470,7 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) column = fprintf (fp, ".PHONY:"); column = make_write_name (d->module_name, fp, column, colmax, - true, ".c++m"); + true, ".c++-module"); fputs ("\n", fp); } @@ -488,11 +487,11 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax) fputs ("\n", fp); } } - + if (d->modules.size ()) { column = fprintf (fp, "CXX_IMPORTS +="); - make_write_vec (d->modules, fp, column, colmax, 0, ".c++m"); + make_write_vec (d->modules, fp, column, colmax, 0, ".c++-module"); fputs ("\n", fp); } } -- cgit v1.1