GCC创建新通道

GCC创建新通道,gcc,Gcc,我试图在GCC-4.1.2中编写一个新的GCC通道。这是我的第一次尝试,我正在尝试打印gcc正在编译的函数的代码行。所以我添加了下面的代码。注意:如果我删除execute\u gimple\u操纵方法中的代码,则不会出现问题: gcc/gcc-4.1.2 1223> cat gcc/gimple-manipulation.c #include "config.h" #include "system.h" #include "coretypes.h" #include "tm.h" #inc

我试图在GCC-4.1.2中编写一个新的GCC通道。这是我的第一次尝试,我正在尝试打印gcc正在编译的函数的代码行。所以我添加了下面的代码。注意:如果我删除execute\u gimple\u操纵方法中的代码,则不会出现问题:

gcc/gcc-4.1.2 1223> cat gcc/gimple-manipulation.c
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "ggc.h"
#include "flags.h"
#include "tree.h"
#include "basic-block.h"
#include "tree-flow.h"
#include "tree-pass.h"
#include "tree-dump.h"
#include "timevar.h"
#include "diagnostic.h"
#include "cfgloop.h"
#include "tree-scalar-evolution.h"
#include "tree-ssa-propagate.h"
#include "tree-chrec.h"


static void execute_gimple_manipulation (void);
static bool gate_gimple_manipulation (void);

/*-------------------------
  The main driver function.
 -------------------------*/
static void execute_gimple_manipulation (void)
{
  basic_block bb = ENTRY_BLOCK_PTR;
  int bbcounter=0, stmtcounter;
  tree stmt;
  block_stmt_iterator si;

  /* traverse each basic block and print all statements  */

  FOR_EACH_BB (bb){ /* in any order */

    bbcounter++;
    printf("\n-> entering bb # %d (internal #: %d)\n", bbcounter, bb->index);

    stmtcounter=0;

    for(si = bsi_start(bb); !bsi_end_p(si); bsi_next(&si)){
      stmtcounter++;
      printf("   encountering statement #%2d: ", stmtcounter);
      stmt = bsi_stmt(si);
      print_generic_stmt (stderr, stmt, 0);
    }
  }
}

/* ------------------------------------------
   Return true if we should execute our pass.
   ------------------------------------------*/
static bool
gate_gimple_manipulation (void)
{
/*    return (flag_unit_at_a_time != 0  && flag_ipa_gimple_manipulation
           Don't bother doing anything if the program has errors.
          && !(errorcount || sorrycount));*/
  return (/*optimize >= 1*/
          /* Don't bother doing anything if the program has errors.  */
          /*&&*/ !(errorcount || sorrycount));
}
struct tree_opt_pass pass_gimple_manipulation =
{
   "gm_pass_simple",             /* name */
   gate_gimple_manipulation,     /* gate */
   execute_gimple_manipulation,  /* execute */
   NULL,                         /* sub */
   NULL,                         /* next */
   0,                            /* static pass number */
   0,                            /* tv_id */
   PROP_cfg | PROP_ssa | PROP_alias,                            /* properties required */
   0,                            /* properties provided */
   0,                            /* properties destroyed */
   0,                            /* todo_flags start */
   TODO_dump_func,                            /* todo_flags finish */
   0                             /* letter */
};
我的新代码编译按照make进行:

gcc -c   -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -Wmissing-format-attribute    -DHAVE_CONFIG_H -I. -I. -I../.././gcc -I../.././gcc/. -I../.././gcc/../include -I../.././gcc/../libcpp/include     ../.././gcc/gimple-manipulation.c -o gimple-manipulation.o
但汇编过程在以下方面进一步失败:

gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/xgcc -Bgcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/ -B/usr/local/x86_64-unknown-linux-gnu/bin/ -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-include -O2  -O2 -g -O2  -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -msse -c \
                ../.././gcc/config/i386/crtfastmath.c \
                -o crtfastmath.o
../.././gcc/config/i386/crtfastmath.c:110: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[2]: *** [crtfastmath.o] Error 1
make[2]: Leaving directory `gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `gcc/gcc-4.1.2'
make: *** [all] Error 2
gcc/gcc-4.1.2 1223>
gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/xgcc-Bgcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/-B/usr/local/x86_64-unknown-linux-gnu/bin/-B/usr/local/x86_64-unknown-linux-gnu/lib/-isystem/usr/local/x86_64-unknown-linux-gnu/gnu/include-linux-gnu/include-O2-O2-gcc-Wwrite strings-Wstrict prototype-Wmissing prototype-Wold style definition-isystem./include-fPIC-g-DHAVE_GTHR_DEFAULT-DIN_LIBGCC2-D_GCC_FLOAT_NOT_NEEDED-msse-c\
../.././gcc/config/i386/crtfastmath.c\
-o crtfastmath.o
../../../gcc/config/i386/crtfastmath.c:110:内部编译器错误:分段错误
请提交完整的bug报告,
如果合适,使用预处理源。
有关说明,请参阅。
生成[2]:***[crtfastmath.o]错误1
make[2]:离开目录“gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc”
make[1]:***[all gcc]错误2
make[1]:离开目录“gcc/gcc-4.1.2”
make:**[全部]错误2
gcc/gcc-4.1.2 1223>
任何帮助–问题发生的原因以及如何实现目标?

重复