gcc.h 3.12 KB
Newer Older
1
/* Header file for modules that link with gcc.c
2
   Copyright (C) 1999-2018 Free Software Foundation, Inc.
3

4
This file is part of GCC.
5

6 7
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
8
Software Foundation; either version 3, or (at your option) any later
9
version.
10

11 12 13 14
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.
15 16

You should have received a copy of the GNU General Public License
17 18
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
19

20 21
#ifndef GCC_GCC_H
#define GCC_GCC_H
22

23
#include "version.h"
24
#include "diagnostic-core.h"
25

26 27 28 29 30 31 32
/* 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.  */

class driver
{
 public:
33 34
  driver (bool can_finalize, bool debug);
  ~driver ();
35
  int main (int argc, char **argv);
36
  void finalize ();
37 38 39 40 41 42 43 44 45 46 47

 private:
  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;
48 49 50
  void build_option_suggestions (void);
  const char *suggest_option (const char *bad_opt);
  void handle_unrecognized_options ();
51 52 53 54 55 56 57 58 59 60 61
  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;
  int get_exit_code () const;

 private:
  char *explicit_link_files;
  struct cl_decoded_option *decoded_options;
  unsigned int decoded_options_count;
62
  auto_vec <char *> *m_option_suggestions;
63 64
};

65 66 67
/* The mapping of a spec function name to the C function that
   implements it.  */
struct spec_function
68
{
69
  const char *name;
70
  const char *(*func) (int, const char **);
71 72
};

73
/* These are exported by gcc.c.  */
74 75 76 77
extern int do_spec (const char *);
extern void record_temp_file (const char *, int, int);
extern void pfatal_with_name (const char *) ATTRIBUTE_NORETURN;
extern void set_input (const char *);
78

79
/* Spec files linked with gcc.c must provide definitions for these.  */
80

81
/* Called before processing to change/add/remove arguments.  */
82 83
extern void lang_specific_driver (struct cl_decoded_option **,
				  unsigned int *, int *);
84

85
/* Called before linking.  Returns 0 on success and -1 on failure.  */
86
extern int lang_specific_pre_link (void);
87

88 89
extern int n_infiles;

90
/* Number of extra output files that lang_specific_pre_link may generate.  */
91 92
extern int lang_specific_extra_outfiles;

93 94 95 96
/* A vector of corresponding output files is made up later.  */

extern const char **outfiles;

97 98 99 100 101
extern void
driver_get_configure_time_options (void (*cb)(const char *option,
					      void *user_data),
				   void *user_data);

102
#endif /* ! GCC_GCC_H */