gcc.h 2.9 KB

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