gccのソースはどこ(その3)

gccつづきです。
前回main関数から、toplevを呼び出ししているところまで見ました。
ということで、toplev.cを探します。

takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$ find -name toplev.c
./gcc/toplev.c
takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$

短いソースでしょうか。

takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$ wc -l gcc/toplev.c
2150 gcc/toplev.c
takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$

なかなか長編です。となると見るのはヘッダが先でしょうか。

ヘッダの行数を確認。

takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$ find -name toplev.h
./gcc/toplev.h
takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$ wc -l gcc/toplev.h
101 gcc/toplev.h
takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$

短いので全文見てみます。
ソースを読むのは、アニメを見たり、ゲームをしたりするのと同じぐらい楽しいです。

takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$ cat -n gcc/toplev.h
     1  /* toplev.h - Various declarations for functions found in toplev.c
     2     Copyright (C) 1998-2016 Free Software Foundation, Inc.
     3
     4  This file is part of GCC.
     5
     6  GCC is free software; you can redistribute it and/or modify it under
     7  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  GCC is distributed in the hope that it will be useful, but WITHOUT ANY
    12  WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  for more details.
    15
    16  You should have received a copy of the GNU General Public License
    17  along with GCC; see the file COPYING3.  If not see
    18  <http://www.gnu.org/licenses/>.  */
    19
    20  #ifndef GCC_TOPLEV_H
    21  #define GCC_TOPLEV_H
    22
    23  /* Decoded options, and number of such options.  */
    24  extern struct cl_decoded_option *save_decoded_options;
    25  extern unsigned int save_decoded_options_count;
    26
    27  class timer;
    28
    29  /* Invoking the compiler.  */
    30  class toplev
    31  {
    32  public:
    33    toplev (timer *external_timer,
    34            bool init_signals);
    35    ~toplev ();
    36
    37    int main (int argc, char **argv);
    38
    39    void finalize ();
    40
    41  private:
    42
    43    void start_timevars ();
    44
    45    bool m_use_TV_TOTAL;
    46    bool m_init_signals;
    47  };
    48
    49  extern void rest_of_decl_compilation (tree, int, int);
    50  extern void rest_of_type_compilation (tree, int);
    51  extern void init_optimization_passes (void);
    52  extern bool enable_rtl_dump_file (void);
    53
    54  /* In except.c.  Initialize exception handling.  This is used by the Ada
    55     and LTO front ends to initialize EH "on demand".  See lto-streamer-in.c
    56     and ada/gcc-interface/misc.c.  */
    57  extern void init_eh (void);
    58
    59  extern void announce_function (tree);
    60
    61  extern void wrapup_global_declaration_1 (tree);
    62  extern bool wrapup_global_declaration_2 (tree);
    63  extern bool wrapup_global_declarations (tree *, int);
    64
    65  extern void global_decl_processing (void);
    66
    67  extern void dump_memory_report (bool);
    68  extern void dump_profile_report (void);
    69
    70  extern void target_reinit (void);
    71
    72  /* A unique local time stamp, might be zero if none is available.  */
    73  extern unsigned local_tick;
    74
    75  /* True if the user has tagged the function with the 'section'
    76     attribute.  */
    77
    78  extern bool user_defined_section_attribute;
    79
    80  /* See toplev.c.  */
    81  extern int flag_rerun_cse_after_global_opts;
    82
    83  extern void print_version (FILE *, const char *, bool);
    84
    85  /* The hashtable, so that the C front ends can pass it to cpplib.  */
    86  extern struct ht *ident_hash;
    87
    88  /* Functions used to get and set GCC's notion of in what directory
    89     compilation was started.  */
    90
    91  extern const char *get_src_pwd         (void);
    92  extern bool set_src_pwd                (const char *);
    93
    94  /* Functions used to manipulate the random seed.  */
    95
    96  extern HOST_WIDE_INT get_random_seed (bool);
    97  extern const char *set_random_seed (const char *);
    98
    99  extern void initialize_rtl (void);
   100
   101  #endif /* ! GCC_TOPLEV_H */
takk@deb9:~/gcc/gcc-6-6.3.0/gcc-6.3.0$

ビルドする時に時間がかかったらエラーになるのでしょうか、タイマーを使ってるのが不思議に感じます。

つづく

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA