GCC Middle and Back End API Reference
|
#include <gcc.h>
Public Member Functions | |
driver (bool can_finalize, bool debug) | |
~driver () | |
int | main (int argc, char **argv) |
void | finalize () |
Private Member Functions | |
void | set_progname (const char *argv0) const |
void | expand_at_files (int *argc, char ***argv) const |
void | decode_argv (int argc, const char **argv) |
void | global_initializations () |
void | build_multilib_strings () const |
void | set_up_specs () const |
void | putenv_COLLECT_GCC (const char *argv0) const |
void | maybe_putenv_COLLECT_LTO_WRAPPER () const |
void | maybe_putenv_OFFLOAD_TARGETS () const |
void | handle_unrecognized_options () |
int | maybe_print_and_exit () const |
bool | prepare_infiles () |
void | do_spec_on_infiles () const |
void | maybe_run_linker (const char *argv0) const |
void | final_actions () const |
void | detect_jobserver () const |
int | get_exit_code () const |
Private Attributes | |
char * | explicit_link_files |
struct cl_decoded_option * | decoded_options |
unsigned int | decoded_options_count |
option_proposer | m_option_proposer |
Header file for modules that link with gcc.cc Copyright (C) 1999-2024 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 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/>.
The top-level "main" within the driver would be ~1000 lines long. This class breaks it up into smaller functions and contains some state shared by them.
References debug, env, and env_manager::init().
driver::~driver | ( | ) |
References decoded_options, and explicit_link_files.
|
private |
Build multilib_select, et. al from the separate lines that make up each multilib selection.
References i, multilib_defaults, multilib_defaults_raw, multilib_exclusions, multilib_matches, multilib_obstack, multilib_reuse, and multilib_select.
Referenced by main().
|
private |
Decode the command-line arguments from argc/argv into the decoded_options array.
References CL_DRIVER, decode_cmdline_options_to_array(), decoded_options, decoded_options_count, global_options, global_options_set, init_options_struct(), and init_opts_obstack().
Referenced by main().
|
private |
Detect whether jobserver is active and working. If not drop --jobserver-auth from MAKEFLAGS.
References jobserver_info::is_active, jobserver_info::skipped_makeflags, and xputenv().
Referenced by maybe_run_linker().
|
private |
Run the spec machinery on each input file.
References clear_failure_queue(), compare_debug, compare_files(), infile::compiled, debug_check_temp_file, delete_failure_queue(), do_spec(), error(), errorcount, explicit_link_files, free(), gcc_assert, gcc_input_filename, i, infiles, inform(), input_file_compiler, input_file_number, input_filename_length, lang_specific_pre_link(), lookup_compiler(), n_infiles, n_switches, n_switches_alloc, n_switches_alloc_debug_check, n_switches_debug_check, NULL, outfiles, seen_error(), set_input(), compiler::spec, switches, switches_debug_check, and UNKNOWN_LOCATION.
Referenced by main().
|
private |
Expand any @ files within the command-line args, setting at_file_supplied if any were expanded.
References at_file_supplied.
Referenced by main().
|
private |
The end of "main".
References delete_failure_queue(), delete_temp_files(), NULL, print_help_list, seen_error(), and totruncate_file.
Referenced by main().
void driver::finalize | ( | ) |
Restore all state within gcc.cc to the initial state, so that the driver code can be safely re-run in-process. Many const char * variables are referenced by static specs (see INIT_STATIC_SPEC above). These variables are restored to their default values by a simple loop over the static specs. For other variables, we directly restore them all to their initial values (often implicitly 0). Free the various obstacks in this file, along with "opts_obstack" from opts.cc. This function also restores any environment variables that were changed.
References added_libraries, always_delete_queue, arg_going, assembler_options, at_file_supplied, basename_length, clear_args(), collect_obstack, combine_inputs, compare_debug, compare_debug_opt, compare_debug_second, compilers, debug_check_temp_file, spec_list::default_ptr, DEFAULT_TARGET_SYSTEM_ROOT, delete_this_arg, diagnostic_finish(), dumpbase, dumpbase_ext, dumpdir, dumpdir_length, dumpdir_trailing_dash_added, env, exec_prefixes, execution_count, failure_delete_queue, used_arg_t::finalize(), free(), gcc_exec_prefix, gcc_input_filename, gcc_libexec_prefix, global_dc, greatest_status, have_c, have_o, i, include_prefixes, infiles, input_basename, input_file_compiler, input_file_number, input_filename_length, input_from_pipe, input_stat_set, input_suffix, is_cpp_driver, just_machine_suffix, last_language_n_infiles, LINK_COMMAND_SPEC, link_command_spec, linker_options, machine_suffix, MD_EXEC_PREFIX, md_exec_prefix, MD_STARTFILE_PREFIX, md_startfile_prefix, MD_STARTFILE_PREFIX_1, md_startfile_prefix_1, mdswitches, multiarch_dir, multilib_dir, multilib_obstack, multilib_os_dir, n_compilers, n_default_compilers, n_infiles, n_infiles_alloc, n_mdswitches, n_switches, n_switches_alloc, n_switches_alloc_debug_check, n_switches_debug_check, spec_list::name, spec_list::next, NULL, obstack, opts_obstack, outbase, outbase_length, outfiles, path_prefix_reset(), preprocessor_options, print_help_list, print_subprocess_help, print_version, processing_spec_function, report_times_to_file, env_manager::restore(), save_temps_flag, SAVE_TEMPS_NONE, save_temps_overrides_dumpdir, set_static_spec_shared(), signal_count, sl, spec_lang, spec_machine, specs, startfile_prefixes, static_specs, suffix_subst, suffixed_basename_length, switches, switches_debug_check, target_sysroot_hdrs_suffix, target_sysroot_suffix, target_system_root, target_system_root_changed, temp_filename, temp_filename_length, temp_names, this_is_library_file, this_is_linker_script, this_is_output_file, use_ld, used_arg, user_specs_head, user_specs_tail, and verbose_only_flag.
|
private |
Determine what the exit code of the driver should be.
References greatest_status, seen_error(), and signal_count.
Referenced by main().
|
private |
Perform various initializations and setup.
References alloc_args(), delete_temp_files(), diagnostic_color_init(), diagnostic_initialize(), diagnostic_urls_init(), fatal_error(), fatal_signal(), gcc_init_libintl, global_dc, input_location, make_gcc_urlifier(), obstack, and diagnostic_context::set_urlifier().
Referenced by main().
|
private |
Reject switches that no pass was interested in.
References error(), i, m_option_proposer, n_switches, option_proposer::suggest_option(), and switches.
Referenced by main().
int driver::main | ( | int | argc, |
char ** | argv ) |
driver::main is implemented as a series of driver:: method calls.
References assembler_options, build_multilib_strings(), completion, decode_argv(), do_spec_on_infiles(), expand_at_files(), final_actions(), get_exit_code(), global_initializations(), handle_unrecognized_options(), m_option_proposer, maybe_print_and_exit(), maybe_putenv_COLLECT_LTO_WRAPPER(), maybe_putenv_OFFLOAD_TARGETS(), maybe_run_linker(), prepare_infiles(), putenv_COLLECT_AS_OPTIONS(), putenv_COLLECT_GCC(), set_progname(), set_up_specs(), and option_proposer::suggest_completion().
Referenced by main().
|
private |
Handle the various -print-* options, returning 0 if the driver should exit, or nonzero if the driver should continue.
References _, build_search_list(), display_help(), exec_prefixes, fatal_error(), find_a_program(), find_file(), fputc(), gcc_exec_prefix, HOST_EXECUTABLE_SUFFIX, input_location, machine_suffix, multiarch_dir, multilib_dir, multilib_os_dir, n_infiles, NULL, print_configuration(), print_help_list, print_multilib_info(), print_version, progname, standard_exec_prefix, startfile_prefixes, sysroot_hdrs_suffix_spec, target_sysroot_hdrs_suffix, target_sysroot_suffix, target_system_root, use_ld, and X_OK.
Referenced by main().
|
private |
Set up to remember the pathname of the lto wrapper.
References collect_obstack, convert_white_space(), find_a_program(), have_c, lto_wrapper_spec, NULL, set_static_spec_owned(), and xputenv().
Referenced by main().
|
private |
Set up to remember the names of offload targets.
References collect_obstack, free(), NULL, offload_targets, and xputenv().
Referenced by main().
|
private |
If we have to run the linker, do it now.
References _, basename_length, convert_white_space(), detect_jobserver(), do_spec(), dumpdir, dumpdir_length, dumpdir_trailing_dash_added, error(), errorcount, exec_prefixes, execution_count, explicit_link_files, F_OK, fatal_error(), find_a_file(), find_a_program(), free(), gcc_assert, gcc_checking_assert, have_c, i, infiles, input_basename, input_location, LIBRARY_PATH_ENV, link_command_spec, linker_name_spec, linker_plugin_file_spec, lto_gcc_spec, n_infiles, NULL, outbase, outbase_length, outfiles, print_subprocess_help, putenv_from_prefixes(), R_OK, seen_error(), set_static_spec_shared(), startfile_prefixes, suffixed_basename_length, switch_matches(), and warning().
Referenced by main().
|
private |
Figure out what to do with each input file. Return true if we need to exit early from "main", false otherwise.
References added_libraries, compiler::combinable, combine_inputs, infile::compiled, explicit_link_files, fatal_error(), have_c, have_o, i, infile::incompiler, infiles, input_file_compiler, input_location, lang_specific_extra_outfiles, lookup_compiler(), n_infiles, infile::name, NULL, outfiles, infile::preprocessed, and seen_error().
Referenced by main().
|
private |
Set up to remember the pathname of gcc and any options needed for collect. We use argv[0] instead of progname because we need the complete pathname.
References collect_obstack, and xputenv().
Referenced by main().
|
private |
|
private |
Set up the spec-handling machinery.
References accel_dir_suffix, add_prefix(), add_sysrooted_prefix(), alloca, argbuf, compare_debug, compare_debug_second, compilers, cross_compile, decoded_options, decoded_options_count, default_compilers, dir_separator_str, do_option_spec(), do_self_spec(), do_spec_1(), do_spec_2(), driver_self_specs, error(), exec_prefixes, find_a_file(), gcc_exec_prefix, i, init_spec(), just_machine_suffix, link_spec, machine_suffix, md_exec_prefix, md_startfile_prefix, md_startfile_prefix_1, n_compilers, n_default_compilers, n_switches, n_switches_alloc, n_switches_alloc_debug_check, n_switches_debug_check, spec_list::next, user_specs::next, NULL, obstack, option_default_specs, PREFIX_PRIORITY_LAST, process_command(), R_OK, read_specs(), save_temps_flag, SAVE_TEMPS_NONE, set_multilib_dir(), set_spec(), sl, spec_host_machine, spec_machine, spec_version, specs, standard_exec_prefix, standard_startfile_prefix, standard_startfile_prefix_1, standard_startfile_prefix_2, startfile_prefix_spec, startfile_prefixes, switches, switches_debug_check, sysroot_hdrs_suffix_spec, sysroot_suffix_spec, target_sysroot_hdrs_suffix, target_sysroot_suffix, target_system_root, user_specs_head, validate_all_switches(), and xputenv().
Referenced by main().
|
private |
Referenced by decode_argv(), set_up_specs(), and ~driver().
|
private |
Referenced by decode_argv(), and set_up_specs().
|
private |
Referenced by do_spec_on_infiles(), maybe_run_linker(), prepare_infiles(), and ~driver().
|
private |
Referenced by handle_unrecognized_options(), and main().