/* Initialization of the front end environment, before command line options are parsed. Signal handlers, internationalization etc. ARGV0 is main's argv[0]. */ static void general_init (const char *argv0, bool init_signals) { const char *p; p = argv0 + strlen (argv0); while (p != argv0 && !IS_DIR_SEPARATOR (p[-1])) --p;
progname = p;
xmalloc_set_program_name (progname);
hex_init ();
/* Unlock the stdio streams. */ unlock_std_streams ();
gcc_init_libintl ();
identifier_to_locale_alloc = alloc_for_identifier_to_locale; identifier_to_locale_free = ggc_free;
/* Initialize the diagnostics reporting machinery, so option parsing can give warnings and errors. */ diagnostic_initialize (global_dc, N_OPTS); /* Set a default printer. Language specific initializations will override it later. */ tree_diagnostics_defaults (global_dc);
global_dc->show_caret = global_options_init.x_flag_diagnostics_show_caret; global_dc->show_option_requested = global_options_init.x_flag_diagnostics_show_option; global_dc->show_column = global_options_init.x_flag_show_column; global_dc->internal_error = plugins_internal_error_function; global_dc->option_enabled = option_enabled; global_dc->option_state = &global_options; global_dc->option_name = option_name;
if (init_signals) { /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */ #ifdef SIGSEGV signal (SIGSEGV, crash_signal); #endif #ifdef SIGILL signal (SIGILL, crash_signal); #endif #ifdef SIGBUS signal (SIGBUS, crash_signal); #endif #ifdef SIGABRT signal (SIGABRT, crash_signal); #endif #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT) signal (SIGIOT, crash_signal); #endif #ifdef SIGFPE signal (SIGFPE, crash_signal); #endif
/* Other host-specific signal setup. */ (*host_hooks.extra_signals)(); }
/* Initialize the garbage-collector, string pools and tree type hash table. */ init_ggc (); init_stringpool (); input_location = UNKNOWN_LOCATION; line_table = ggc_alloc<line_maps> (); linemap_init (line_table, BUILTINS_LOCATION); line_table->reallocator = realloc_for_line_map; line_table->round_alloc_size = ggc_round_alloc_size; line_table->default_range_bits = 5; init_ttree ();
/* Initialize register usage now so switches may override. */ init_reg_sets ();
/* Register the language-independent parameters. */ global_init_params ();
/* This must be done after global_init_params but before argument processing. */ init_ggc_heuristics ();
/* Create the singleton holder for global state. Doing so also creates the pass manager and with it the passes. */ g = new gcc::context (); symtab = new (ggc_cleared_alloc <symbol_table> ()) symbol_table ();
statistics_early_init (); finish_params (); }
GCC 初始化前端环境general_init
最新推荐文章于 2021-06-22 01:14:46 发布