c.opt: Add -fmodule-header.

gcc/c-family/
	* c.opt: Add -fmodule-header.
	gcc/cp/
	* lang-specs.h: Add legacy import options.
	* module.c (module_header_name): New.
	(init_module_processing): Default it.
	(handle_module_option): Set it.

From-SVN: r261862
This commit is contained in:
Nathan Sidwell
2018-06-21 20:04:36 +00:00
committed by Nathan Sidwell
parent a12bfc32cc
commit 4a2623caab
5 changed files with 80 additions and 27 deletions

View File

@@ -1,5 +1,13 @@
2018-06-21 Nathan Sidwell <nathan@acm.org>
gcc/c-family/
* c.opt: Add -fmodule-header.
gcc/cp/
* lang-specs.h: Add legacy import options.
* module.c (module_header_name): New.
(init_module_processing): Default it.
(handle_module_option): Set it.
Use getaddrinfo, not gethostbyname2
gcc/
* configure.ac (HAVE_AF_INET6): Test for getaddrinfo.

View File

@@ -1532,6 +1532,14 @@ fno-modules
C++ ObjC++ Driver Undocumented RejectNegative Var(flag_modules,0) Integer
;; undocumented
fmodule-header
C++ ObjC Driver Undocumented RejectNegative
;; undocumented
fmodule-header=
C++ ObjC++ Driver Joined RejectNegative MissingArgError(missing header name)
ATOM legacy import name
fmodule-mapper=
C++ ObjC++ Driver Joined RejectNegative MissingArgError(missing mapper)
Mapper for module to BMI files

View File

@@ -40,29 +40,32 @@ along with GCC; see the file COPYING3. If not see
{".tcc", "@c++-header", 0, 0, 0},
{".hh", "@c++-header", 0, 0, 0},
{"@c++-header",
"%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
%{save-temps*|no-integrated-cpp:cc1plus -E\
%(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}\
cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\
%{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
%(cc1_options) %2\
%{!fsyntax-only:%{!S:-o %g.s} \
%{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
%W{o*:--output-pch=%*}}%V}}}}",
"%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)}"
"%{!E:%{!M:%{!MM:"
" %{save-temps*|no-integrated-cpp:cc1plus -E"
" %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}"
" cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed"
" %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
" %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
" %(cc1_options) %2"
" %{fmodules-atom:%{fmodule-header*:-fmodule-header}}"
" %{!fsyntax-only:%{!S:-o %g.s}"
" %{!fdump-ada-spec*:%{!fmodules-atom:"
" %{!o*:--output-pch=%i.gch}%W{o*:--output-pch=%*}}%V}}}}}",
CPLUSPLUS_CPP_SPEC, 0, 0},
{"@c++",
"%{E|M|MM:cc1plus -E %{fmodule-prefix*} %(cpp_options) %2 %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
%{save-temps*|no-integrated-cpp:cc1plus -E\
%(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}\
cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\
%{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
%(cc1_options) %2\
%{!fsyntax-only:%(invoke_as)}}}}",
CPLUSPLUS_CPP_SPEC, 0, 0},
"%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)}"
"%{!E:%{!M:%{!MM:"
" %{save-temps*|no-integrated-cpp:cc1plus -E"
" %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}"
" cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed"
" %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
" %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
" %(cc1_options) %2"
" %{!fsyntax-only:%(invoke_as)}}}}",
CPLUSPLUS_CPP_SPEC, 0, 0},
{".ii", "@c++-cpp-output", 0, 0, 0},
{"@c++-cpp-output",
"%{!M:%{!MM:%{!E:\
cc1plus -fpreprocessed %i %(cc1_options) %2\
%{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
"%{!E:%{!M:%{!MM:"
" cc1plus -fpreprocessed %i %(cc1_options) %2"
" %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},

View File

@@ -2827,6 +2827,9 @@ bool module_state_hash::equal (const value_type existing,
/* Mapper name. */
static const char *module_mapper_name;
/* Legacy header mode. */
static const char *module_header_name;
/* BMI repository path and workspace. */
static char *bmi_repo;
static size_t bmi_repo_length;
@@ -10736,8 +10739,28 @@ atom_module_preamble (location_t loc, line_maps *lmaps)
void
init_module_processing ()
{
if (pch_file)
error ("modules and PCH are incompatible");
gcc_assert (pch_file);
if (module_header_name && !module_header_name[0])
{
/* Set the module header name from the main_input_filename. */
const char *main = main_input_filename;
size_t len = strlen (main);
for (; len >= 2; len--)
if (IS_DIR_SEPARATOR (main[len-1]))
{
/* Is this '//' or '/./'? */
size_t peek = len - 2;
if (peek && main[peek] == '.')
peek--;
if (IS_DIR_SEPARATOR (main[peek]))
break;
}
if (len < 2)
len = 0;
module_header_name = main + len;
else
}
module_state::init ();
}
@@ -10844,7 +10867,9 @@ maybe_repeat_preamble (location_t loc, int count ATTRIBUTE_UNUSED, cpp_reader *)
}
/* If CODE is a module option, handle it & return true. Otherwise
return false. */
return false. For unknown reasons I cannot get the option
generation machinery to set fmodule-mapper pr -fmodule-header to
make a string type option variable. */
bool
handle_module_option (unsigned code, const char *str, int num)
@@ -10861,6 +10886,15 @@ handle_module_option (unsigned code, const char *str, int num)
flag_module_preamble = num;
return true;
case OPT_fmodule_header:
str="";
/* FALLTHROUGH. */
case OPT_fmodule_header_:
module_header_name = str;
/* Force atom. */
flag_modules = -1;
return true;
default:
return false;
}

View File

@@ -488,7 +488,7 @@ Objective-C and Objective-C++ Dialects}.
-dD -dI -dM -dN -dU @gol
-fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
-fexec-charset=@var{charset} -fextended-identifiers @gol
-finput-charset=@var{charset} -fmodule-prefix @gol
-finput-charset=@var{charset} -fmodule-preamble @gol
-fmacro-prefix-map=@var{old}=@var{new} @gol
-fno-canonical-system-headers @gol -fpch-deps -fpch-preprocess @gol
-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
@@ -29471,7 +29471,7 @@ Usually importing a module will load minimal information, defering the
bulk of the loading to the point at which name-lookup inspects a
particular namespace-scope name.
The @option{-fmodule-prefix} option may be added when preprocessing with
The @option{-fmodule-preamble} option may be added when preprocessing with
@option{-E}. This causes preprocessing to terminate once the Atom
preamble is processed. Build systems may need to determine the set of
imports a compilation needed, and this allows that without the expense