From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1499) id CBFD03857C70; Tue, 25 Jan 2022 18:13:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBFD03857C70 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Gaius Mulley To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/modula-2] gcc.cc externs used by front ends prefixed by fe. X-Act-Checkin: gcc X-Git-Author: Gaius Mulley X-Git-Refname: refs/heads/devel/modula-2 X-Git-Oldrev: d08981bfd00da0b2fc738359986e7775b6bb0d1d X-Git-Newrev: 183c1231175227cd41f3ec108abc67e390db3c65 Message-Id: <20220125181347.CBFD03857C70@sourceware.org> Date: Tue, 25 Jan 2022 18:13:47 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2022 18:13:47 -0000 https://gcc.gnu.org/g:183c1231175227cd41f3ec108abc67e390db3c65 commit 183c1231175227cd41f3ec108abc67e390db3c65 Author: Gaius Mulley Date: Tue Jan 25 18:13:06 2022 +0000 gcc.cc externs used by front ends prefixed by fe. This patch converts external symbols provided by gcc.cc to front end drivers to be prefixed by fe_. It is largely cosmetic but provides clarify over which symbols are required by front end drivers. gcc/ChangeLog: * gcc/gcc.cc: (xputenv) Reinstated static declaration. Capitalized comment start. (xgetenv) Reinstated static declaration. (fe_putenv) New function. (fe_getenv) New function. (save_switch) Reinstated static declaration. (fe_save_switch) New function. (fe_add_linker_option) Added header comment. (handle_OPT_B) Renamed to handle_opt_b. (fe_handle_opt_b) New function. * gcc/gcc.h: (save_switch) Replaced by fe_save_switch. (handle_OPT_B) Replaced by fe_handle_opt_b. (xputenv) Replaced by fe_putenv. (xgetenv) Replaced by fe_getenv. gcc/m2/ChangeLog: * gm2spec.cc: Replaced save_switch by fe_save_switch. Replaced xputenv by fe_putenv. Replaced xgetenv by fe_getenv. Signed-off-by: Gaius Mulley Diff: --- gcc/gcc.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++---------- gcc/gcc.h | 8 ++++---- gcc/m2/gm2spec.cc | 28 +++++++++++++-------------- 3 files changed, 65 insertions(+), 28 deletions(-) diff --git a/gcc/gcc.cc b/gcc/gcc.cc index a96891e3900..d7cece303d5 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -366,6 +366,7 @@ static void set_spec (const char *, const char *, bool); static struct compiler *lookup_compiler (const char *, size_t, const char *); static char *build_search_list (const struct path_prefix *, const char *, bool, bool); +static void xputenv (const char *); static void putenv_from_prefixes (const struct path_prefix *, const char *, bool); static int access_check (const char *, int); @@ -1152,7 +1153,6 @@ proper position among the other output files. */ /* We pass any -flto flags on to the linker, which is expected to understand them. In practice, this means it had better be collect2. */ /* %{e*} includes -export-dynamic; see comment in common.opt. */ - #ifndef LINK_COMMAND_SPEC #define LINK_COMMAND_SPEC "\ %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ @@ -1786,7 +1786,7 @@ static const struct spec_function static_spec_functions[] = { 0, 0 } }; -/* front end registered spec functions */ +/* Front end registered spec functions */ static struct spec_function *lang_spec_functions = NULL; static unsigned int lang_spec_functions_length = 0; @@ -2952,7 +2952,7 @@ add_to_obstack (char *path, void *data) /* Add or change the value of an environment variable, outputting the change to standard error if in verbose mode. */ -void +static void xputenv (const char *string) { env.xput (string); @@ -2960,12 +2960,28 @@ xputenv (const char *string) /* Get the environment variable through the managed env. */ -const char * +static const char * xgetenv (const char *key) { return env.get (key); } +/* Allow front end access to xputenv. */ + +void +fe_putenv (const char *string) +{ + xputenv (string); +} + +/* Allow front end access to xgetenv. */ + +const char * +fe_getenv (const char *key) +{ + return xgetenv (key); +} + /* Build a list of search directories from PATHS. PREFIX is a string to prepend to the list. If CHECK_DIR_P is true we ensure the directory exists. @@ -3909,7 +3925,7 @@ alloc_switch (void) /* Save an option OPT with N_ARGS arguments in array ARGS, marking it as validated if VALIDATED and KNOWN if it is an internal switch. */ -void +static void save_switch (const char *opt, size_t n_args, const char *const *args, bool validated, bool known) { @@ -3931,6 +3947,15 @@ save_switch (const char *opt, size_t n_args, const char *const *args, n_switches++; } +/* Allow front ends to save switches. */ + +void +fe_save_switch (const char *opt, size_t n_args, const char *const *args, + bool validated, bool known) +{ + save_switch (opt, n_args, args, validated, known); +} + /* Set the SOURCE_DATE_EPOCH environment variable to the current time if it is not set already. */ @@ -3954,6 +3979,8 @@ set_source_date_epoch_envvar () setenv ("SOURCE_DATE_EPOCH", source_date_epoch, 0); } +/* Wrapper providing front end access to link options. */ + void fe_add_linker_option (const char *option) { @@ -3963,8 +3990,8 @@ fe_add_linker_option (const char *option) /* Handle the -B option by adding the prefix to exec, startfile and include search paths. */ -void -handle_OPT_B (const char *arg) +static void +handle_opt_b (const char *arg) { size_t len = strlen (arg); @@ -3993,6 +4020,14 @@ handle_OPT_B (const char *arg) PREFIX_PRIORITY_B_OPT, 0, 0); } +/* Wrapper allowing the front end to create a -B option. */ + +void +fe_handle_opt_b (const char *arg) +{ + handle_opt_b (arg); +} + /* Save the infile. */ void @@ -4593,7 +4628,7 @@ driver_handle_option (struct gcc_options *opts, break; case OPT_B: - handle_OPT_B (arg); + handle_opt_b (arg); validated = true; break; @@ -6956,7 +6991,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) /* Allow the front end to register a spec function. */ -void fe_add_spec_function (const char *name, const char *(*func) (int, const char **)) +void fe_add_spec_function (const char *name, + const char *(*func) (int, const char **)) { const struct spec_function *f = lookup_spec_function (name); struct spec_function *fl; @@ -6969,7 +7005,8 @@ void fe_add_spec_function (const char *name, const char *(*func) (int, const cha lang_spec_functions_length = 1; lang_spec_functions_length++; - fl = (struct spec_function *) xmalloc (sizeof (const struct spec_function)*lang_spec_functions_length); + fl = (struct spec_function *) xmalloc (sizeof (const struct spec_function) + *lang_spec_functions_length); for (i=0; iopt_text); if (arg == NULL || joined) - save_switch (opt, 0, NULL, true, false); + fe_save_switch (opt, 0, NULL, true, false); else { const char **x = (const char **)XCNEWVEC (const char **, 2); @@ -203,7 +203,7 @@ fe_generate_option (size_t opt_index, const char *arg, bool joined) x[1] = NULL; gcc_assert (opt_index != OPT_l); - save_switch (opt, 1, x, true, false); + fe_save_switch (opt, 1, x, true, false); } } @@ -255,7 +255,7 @@ add_B_prefix (unsigned int *in_decoded_options_count ATTRIBUTE_UNUSED, for (i = 0; i < *in_decoded_options_count; i++) print_option ("before add -B", i, *in_decoded_options); #endif - handle_OPT_B (xstrdup (path)); + fe_handle_opt_b (xstrdup (path)); fe_generate_option (OPT_B, xstrdup (path), 1); #if defined(DEBUGGING) @@ -784,7 +784,7 @@ build_path (const char *prefix) strcat (s, ":"); strcat (s, path); } - xputenv (s); + fe_putenv (s); } /* gen_gm2_prefix, return the prefix string. */ @@ -849,7 +849,7 @@ build_library_path (const char *prefix) strcpy (s, "LIBRARY_PATH="); strcat (s, path); - xputenv (s); + fe_putenv (s); } /* build_compiler_path, implements export @@ -865,7 +865,7 @@ build_compiler_path (const char *path) strcpy (s, "COMPILER_PATH="); strcat (s, libexec); - xputenv (s); + fe_putenv (s); } /* check_gm2_root, checks to see whether GM2_PREFIX or GM2_LIBEXEC @@ -881,10 +881,10 @@ check_gm2_root (void) const char *gm2_prefix; const char *gm2_libexec; - library_path = xgetenv (LIBRARY_PATH_ENV); - compiler_path = xgetenv ("COMPILER_PATH"); - gm2_prefix = xgetenv (GM2_PREFIX_ENV); - gm2_libexec = xgetenv (GM2_LIBEXEC_ENV); + library_path = fe_getenv (LIBRARY_PATH_ENV); + compiler_path = fe_getenv ("COMPILER_PATH"); + gm2_prefix = fe_getenv (GM2_PREFIX_ENV); + gm2_libexec = fe_getenv (GM2_LIBEXEC_ENV); if ((library_path == NULL || (strcmp (library_path, "") == 0)) && (compiler_path == NULL || (strcmp (compiler_path, "") == 0))) @@ -1191,12 +1191,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, fe_generate_option (OPT_fonlylink, NULL, false); check_gm2_root (); - libpath = xgetenv (LIBRARY_PATH_ENV); + libpath = fe_getenv (LIBRARY_PATH_ENV); if (libpath == NULL || (strcmp (libpath, "") == 0)) libpath = LIBSUBDIR; - gm2ipath = xgetenv (GM2IPATH_ENV); - gm2opath = xgetenv (GM2OPATH_ENV); + gm2ipath = fe_getenv (GM2IPATH_ENV); + gm2opath = fe_getenv (GM2OPATH_ENV); #if defined(DEBUGGING) print_options ("at beginning", *in_decoded_options_count, *in_decoded_options);