1*38fd1498Szrj /* Header file for modules that link with gcc.c 2*38fd1498Szrj Copyright (C) 1999-2018 Free Software Foundation, Inc. 3*38fd1498Szrj 4*38fd1498Szrj This file is part of GCC. 5*38fd1498Szrj 6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under 7*38fd1498Szrj the terms of the GNU General Public License as published by the Free 8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later 9*38fd1498Szrj version. 10*38fd1498Szrj 11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY 12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or 13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14*38fd1498Szrj for more details. 15*38fd1498Szrj 16*38fd1498Szrj You should have received a copy of the GNU General Public License 17*38fd1498Szrj along with GCC; see the file COPYING3. If not see 18*38fd1498Szrj <http://www.gnu.org/licenses/>. */ 19*38fd1498Szrj 20*38fd1498Szrj #ifndef GCC_GCC_H 21*38fd1498Szrj #define GCC_GCC_H 22*38fd1498Szrj 23*38fd1498Szrj #include "version.h" 24*38fd1498Szrj #include "diagnostic-core.h" 25*38fd1498Szrj 26*38fd1498Szrj /* The top-level "main" within the driver would be ~1000 lines long. 27*38fd1498Szrj This class breaks it up into smaller functions and contains some 28*38fd1498Szrj state shared by them. */ 29*38fd1498Szrj 30*38fd1498Szrj class driver 31*38fd1498Szrj { 32*38fd1498Szrj public: 33*38fd1498Szrj driver (bool can_finalize, bool debug); 34*38fd1498Szrj ~driver (); 35*38fd1498Szrj int main (int argc, char **argv); 36*38fd1498Szrj void finalize (); 37*38fd1498Szrj 38*38fd1498Szrj private: 39*38fd1498Szrj void set_progname (const char *argv0) const; 40*38fd1498Szrj void expand_at_files (int *argc, char ***argv) const; 41*38fd1498Szrj void decode_argv (int argc, const char **argv); 42*38fd1498Szrj void global_initializations (); 43*38fd1498Szrj void build_multilib_strings () const; 44*38fd1498Szrj void set_up_specs () const; 45*38fd1498Szrj void putenv_COLLECT_GCC (const char *argv0) const; 46*38fd1498Szrj void maybe_putenv_COLLECT_LTO_WRAPPER () const; 47*38fd1498Szrj void maybe_putenv_OFFLOAD_TARGETS () const; 48*38fd1498Szrj void build_option_suggestions (void); 49*38fd1498Szrj const char *suggest_option (const char *bad_opt); 50*38fd1498Szrj void handle_unrecognized_options (); 51*38fd1498Szrj int maybe_print_and_exit () const; 52*38fd1498Szrj bool prepare_infiles (); 53*38fd1498Szrj void do_spec_on_infiles () const; 54*38fd1498Szrj void maybe_run_linker (const char *argv0) const; 55*38fd1498Szrj void final_actions () const; 56*38fd1498Szrj int get_exit_code () const; 57*38fd1498Szrj 58*38fd1498Szrj private: 59*38fd1498Szrj char *explicit_link_files; 60*38fd1498Szrj struct cl_decoded_option *decoded_options; 61*38fd1498Szrj unsigned int decoded_options_count; 62*38fd1498Szrj auto_vec <char *> *m_option_suggestions; 63*38fd1498Szrj }; 64*38fd1498Szrj 65*38fd1498Szrj /* The mapping of a spec function name to the C function that 66*38fd1498Szrj implements it. */ 67*38fd1498Szrj struct spec_function 68*38fd1498Szrj { 69*38fd1498Szrj const char *name; 70*38fd1498Szrj const char *(*func) (int, const char **); 71*38fd1498Szrj }; 72*38fd1498Szrj 73*38fd1498Szrj /* These are exported by gcc.c. */ 74*38fd1498Szrj extern int do_spec (const char *); 75*38fd1498Szrj extern void record_temp_file (const char *, int, int); 76*38fd1498Szrj extern void pfatal_with_name (const char *) ATTRIBUTE_NORETURN; 77*38fd1498Szrj extern void set_input (const char *); 78*38fd1498Szrj 79*38fd1498Szrj /* Spec files linked with gcc.c must provide definitions for these. */ 80*38fd1498Szrj 81*38fd1498Szrj /* Called before processing to change/add/remove arguments. */ 82*38fd1498Szrj extern void lang_specific_driver (struct cl_decoded_option **, 83*38fd1498Szrj unsigned int *, int *); 84*38fd1498Szrj 85*38fd1498Szrj /* Called before linking. Returns 0 on success and -1 on failure. */ 86*38fd1498Szrj extern int lang_specific_pre_link (void); 87*38fd1498Szrj 88*38fd1498Szrj extern int n_infiles; 89*38fd1498Szrj 90*38fd1498Szrj /* Number of extra output files that lang_specific_pre_link may generate. */ 91*38fd1498Szrj extern int lang_specific_extra_outfiles; 92*38fd1498Szrj 93*38fd1498Szrj /* A vector of corresponding output files is made up later. */ 94*38fd1498Szrj 95*38fd1498Szrj extern const char **outfiles; 96*38fd1498Szrj 97*38fd1498Szrj extern void 98*38fd1498Szrj driver_get_configure_time_options (void (*cb)(const char *option, 99*38fd1498Szrj void *user_data), 100*38fd1498Szrj void *user_data); 101*38fd1498Szrj 102*38fd1498Szrj #endif /* ! GCC_GCC_H */ 103