From: Nobuyoshi Nakada Date: 2007-07-02T12:22:58+09:00 Subject: [ruby-dev:31106] Re: make error at bcc32 なかだです。 At Fri, 29 Jun 2007 18:07:23 +0900, pegacorn wrote in [ruby-dev:31092]: > http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-dev/27460?27417-28049 > によると、複数ターゲットと単独ターゲットの順序の問題のようですね。 よくそんなのを見付けましたね。書いた当人もすっかり忘れていたと いう。 > 上記パッチで、「Redefinition of target」エラーは出なくなりますが、 > 今度は下記のエラーが出ます。 > ヘッダーファイルの格納先が変わってるので、VPATH とか色々変更しないと > いけないようですね。 > > Fatal: '.\ruby.h' does not exist - don't know how to make it とりあえずコンパイルまで通るようにはしてみましたが、見事にSEGV しました。gdbだとほとんど情報が出ないのですが、バックトレースか らすると、鬼車のバグを踏んでいるか、逆に鬼車がbccのバグをついて いるような感じでした。 > > bcc32 を使っているのは少数派だと思いますが、愛の手を。 > > # 普段は使わないのですけど、インストールしてあったので > # ちょっとだけ試してみました。 bcc 5.82でもC89未対応(実行時の値で構造体の要素を初期化できない) というところで、ほぼやる気が失せてしまいました。 Index: bcc32/Makefile.sub =================================================================== --- bcc32/Makefile.sub (revision 12670) +++ bcc32/Makefile.sub (working copy) @@ -8,4 +8,6 @@ OS = bccwin32 RT = $(OS) +arch = $(ARCH)-$(OS) + ## variables may be overridden by $(compile_dir)/Makefile !ifndef srcdir @@ -37,5 +39,4 @@ iconinc=-I$(icondirs: = -I) ############### -VPATH = $(srcdir):$(srcdir)/missing .SUFFIXES: .y @@ -143,5 +144,5 @@ STACK = 0x2000000 !endif -XCFLAGS = -DRUBY_EXPORT -I. -I$(srcdir) -I$(srcdir)missing +XCFLAGS = -DRUBY_EXPORT -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)missing ARFLAGS = /a @@ -177,5 +178,5 @@ PREP = miniruby$(EXEEXT) OBJEXT = obj -OBJEXT = asm +ASMEXT = asm INSTALLED_LIST= .installed.list @@ -184,6 +185,13 @@ WINMAINOBJ = winmain.$(OBJEXT) MINIOBJS = dmydln.$(OBJEXT) +arch_hdrdir = $(EXTOUT)/include/$(arch) +hdrdir = $(srcdir)include +VPATH = $(arch_hdrdir)/ruby;$(hdrdir)/ruby;$(srcdir);$(srcdir)missing;$(srcdir)win32 + .path.c = .;$(srcdir);$(srcdir)win32;$(srcdir)missing -.path.h = .;$(srcdir);$(srcdir)win32;$(srcdir)missing +.path.ci = $(srcdir) +.path.inc = .;$(srcdir) +.path.def = .;$(srcdir) +.path.h = .;$(arch_hdrdir)/ruby;$(hdrdir)/ruby;$(srcdir);$(srcdir)win32;$(srcdir)missing .path.y = $(srcdir) .path. = $(srcdir) @@ -212,4 +220,5 @@ rubyw: $(WPROGRAM) PHONY: Makefile +RUBY_CONFIG_H = $(arch_hdrdir)/ruby/config.h CONFIG_H = ./.config.h.time @@ -219,5 +228,5 @@ config.status: $(CONFIG_H) $(CONFIG_H): $(MKFILES) $(srcdir)bcc32/Makefile.sub - @$(srcdir:/=\)win32\ifchange.bat config.h &&| + @$(srcdir:/=\)win32\ifchange.bat $(RUBY_CONFIG_H:/=\) &&| \#define HAVE_SYS_TYPES_H 1 \#define HAVE_SYS_STAT_H 1 @@ -455,4 +464,7 @@ $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_ . $(icondirs) $(srcdir)win32 +lex.c: {$(srcdir)}lex.c.blt + copy "$(?:/=\)" $@ + post-install-bin:: @$(NULLCMD) Index: common.mk =================================================================== --- common.mk (revision 12670) +++ common.mk (working copy) @@ -514,5 +514,5 @@ sprintf.$(OBJEXT): {$(VPATH)}sprintf.c { {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \ {$(VPATH)}re.h {$(VPATH)}regex.h {$(VPATH)}oniguruma.h \ - {$(VPATH)}missing/vsnprintf.c + {$(VPATH)}vsnprintf.c st.$(OBJEXT): {$(VPATH)}st.c {$(VPATH)}config.h {$(VPATH)}st.h {$(VPATH)}defines.h string.$(OBJEXT): {$(VPATH)}string.c {$(VPATH)}ruby.h {$(VPATH)}config.h \ @@ -596,4 +596,8 @@ INSNS = opt_sc.inc optinsn.inc optunifs. INSNS2VMOPT = --srcdir="$(srcdir)" +$(INSNS): $(srcdir)/insns.def {$(VPATH)}vm_opts.h + $(RM) $(PROGRAM) + $(BASERUBY) -C $(srcdir) tool/insns2vm.rb $(INSNS2VMOPT) + minsns.inc: $(srcdir)/template/minsns.inc.tmpl @@ -612,9 +616,5 @@ vmtc.inc: $(srcdir)/template/vmtc.inc.tm vm.inc: $(srcdir)/template/vm.inc.tmpl -$(INSNS): $(srcdir)/insns.def {$(VPATH)}vm_opts.h - $(RM) $(PROGRAM) - $(BASERUBY) $(srcdir)/tool/insns2vm.rb $(INSNS2VMOPT) - -incs: $(INSNS) +incs: $(INSNS) $(REVISION_UP) docs: Index: compile.c =================================================================== --- compile.c (revision 12670) +++ compile.c (working copy) @@ -37,4 +37,10 @@ VALUE iseq_load(VALUE self, VALUE data, #define ISEQ_ELEMENT_SEQ INT2FIX(0x03) +#define DECL_ANCHOR(name) \ + LINK_ANCHOR name##_body__ = {{0,},}; \ + LINK_ANCHOR *name = & name##_body__ +#define INIT_ANCHOR(name) \ + name##_body__.last = &name##_body__.anchor + typedef struct iseq_link_element { int type; @@ -139,4 +145,5 @@ rb_iseq_compile(VALUE self, NODE *node) DECL_ANCHOR(ret); rb_iseq_t *iseq; + INIT_ANCHOR(ret); GetISeqPtr(self, iseq); @@ -1831,4 +1838,5 @@ compile_array(rb_iseq_t *iseq, DECL_ANCHOR(anchor); + INIT_ANCHOR(anchor); while (node) { if (nd_type(node) != NODE_ARRAY) { @@ -1939,4 +1947,5 @@ make_masgn_lhs(rb_iseq_t *iseq, LINK_ANC default: { DECL_ANCHOR(anchor); + INIT_ANCHOR(anchor); COMPILE_POPED(anchor, "masgn lhs", node); /* dump_disasm_list(FIRST_ELEMENT(anchor)); */ @@ -2048,4 +2057,5 @@ compile_massign(rb_iseq_t *iseq, LINK_AN DECL_ANCHOR(lhs); + INIT_ANCHOR(lhs); COMPILE_POPED(lhs, "post", n->nd_head); REMOVE_ELEM(FIRST_ELEMENT(lhs)); @@ -2403,4 +2413,5 @@ add_ensure_iseq(LINK_ANCHOR *ret, rb_ise DECL_ANCHOR(ensure); + INIT_ANCHOR(ensure); while (enlp) { DECL_ANCHOR(ensure_part); @@ -2450,4 +2461,5 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR DECL_ANCHOR(tmp); + INIT_ANCHOR(tmp); COMPILE(tmp, "args (cat: splat)", argn->nd_body); if (next_is_array && nsplat == 0) { @@ -2585,4 +2597,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ VALUE special_literals = rb_ary_new(); + INIT_ANCHOR(head); + INIT_ANCHOR(body_seq); + INIT_ANCHOR(cond_seq); if (node->nd_head == 0) { COMPILE_(ret, "when", node->nd_body, poped); @@ -2680,4 +2695,5 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ DECL_ANCHOR(body_seq); + INIT_ANCHOR(body_seq); endlabel = NEW_LABEL(nd_line(node)); @@ -3060,12 +3076,14 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ LABEL *lend = NEW_LABEL(nd_line(node)); LABEL *lcont = NEW_LABEL(nd_line(node)); - struct ensure_range er = { lstart, lend, 0 }; - struct iseq_compile_data_ensure_node_stack enl = { - node->nd_ensr, - iseq->compile_data->ensure_node_stack, /* prev */ - &er, - }; + struct ensure_range er = { 0 }; + struct iseq_compile_data_ensure_node_stack enl; struct ensure_range *erange; + INIT_ANCHOR(ensr); + er.begin = lstart; + er.end = lend; + enl.ensure_node = node->nd_ensr; + enl.prev = iseq->compile_data->ensure_node_stack; /* prev */ + enl.erange = &er; COMPILE_POPED(ensr, "ensure ensr", node->nd_ensr); @@ -3241,4 +3259,5 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ */ + INIT_ANCHOR(args); COMPILE(ret, "NODE_OP_ASGN1 recv", node->nd_recv); argc = compile_array(iseq, args, node->nd_args->nd_body, Qfalse); @@ -3433,4 +3452,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ iseq->compile_data->current_block = Qfalse; + INIT_ANCHOR(recv); + INIT_ANCHOR(args); #if SUPPORT_JOKE if (nd_type(node) == NODE_VCALL) { @@ -3528,6 +3549,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ unsigned long flag = 0; VALUE parent_block = iseq->compile_data->current_block; - iseq->compile_data->current_block = Qfalse; + INIT_ANCHOR(args); + iseq->compile_data->current_block = Qfalse; if (nd_type(node) == NODE_SUPER) { argc = setup_args(iseq, args, node->nd_args, &flag); @@ -3635,4 +3657,5 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ int type = node->nd_head ? nd_type(node->nd_head) : NODE_ZARRAY; + INIT_ANCHOR(list); switch (type) { case NODE_ARRAY:{ @@ -3692,4 +3715,5 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ unsigned long flag = 0; + INIT_ANCHOR(args); if (iseq->type == ISEQ_TYPE_TOP || iseq->type == ISEQ_TYPE_CLASS) { COMPILE_ERROR(("Illegal yield")); @@ -3801,4 +3825,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ DECL_ANCHOR(val); + INIT_ANCHOR(recv); + INIT_ANCHOR(val); switch(nd_type(node)) { case NODE_MATCH: @@ -4065,4 +4091,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ DECL_ANCHOR(body); + INIT_ANCHOR(pref); + INIT_ANCHOR(body); compile_colon2(iseq, node, pref, body); if (LIST_SIZE_ZERO(pref)) { @@ -4259,4 +4287,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ VALUE argc; + INIT_ANCHOR(recv); + INIT_ANCHOR(args); argc = setup_args(iseq, args, node->nd_args, &flag); @@ -4689,4 +4719,5 @@ iseq_build_from_ary(rb_iseq_t *iseq, VAL DECL_ANCHOR(anchor); + INIT_ANCHOR(anchor); if (iseq->type == ISEQ_TYPE_METHOD || iseq->type == ISEQ_TYPE_TOP || Index: compile.h =================================================================== --- compile.h (revision 12670) +++ compile.h (working copy) @@ -210,7 +210,3 @@ r_value(VALUE value) #define COMPILE_NG 0 -#define DECL_ANCHOR(name) \ - LINK_ANCHOR name##_body__ = {{0,}, &name##_body__.anchor}; \ - LINK_ANCHOR *name = & name##_body__ - #endif /* RUBY_COMPILE_H */ Index: eval.c =================================================================== --- eval.c (revision 12670) +++ eval.c (working copy) @@ -1158,7 +1158,7 @@ rb_protect(VALUE (*proc) (VALUE), VALUE rb_thread_t *th = GET_THREAD(); rb_control_frame_t *cfp = th->cfp; - struct rb_vm_trap_tag trap_tag = { - th->trap_tag, - }; + struct rb_vm_trap_tag trap_tag; + + trap_tag.prev = th->trap_tag; PUSH_TAG(); Index: thread.c =================================================================== --- thread.c (revision 12670) +++ thread.c (working copy) @@ -1961,7 +1961,8 @@ thgroup_list(VALUE group) { VALUE ary = rb_ary_new(); - struct thgroup_list_params param = { - ary, group, - }; + struct thgroup_list_params param; + + param.ary = ary; + param.group = group; st_foreach(GET_THREAD()->vm->living_threads, thgroup_list_i, (st_data_t) & param); return ary; @@ -2805,5 +2806,11 @@ static void call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass) { - struct call_trace_func_args args = {event, proc, self, id, klass}; + struct call_trace_func_args args; + + args.event = event; + args.proc = proc; + args.self = self; + args.id = id; + args.klass = klass; ruby_suppress_tracing(call_trace_proc, (VALUE)&args); } svn: 'thread.c~' is not under version control Index: thread_win32.ci =================================================================== --- thread_win32.ci (revision 12670) +++ thread_win32.ci (working copy) @@ -141,8 +141,18 @@ w32_resume_thread(HANDLE handle) } +#ifdef __BORLANDC__ +#undef HAVE__BEGINTHREADEX +#define start_thread CreateThread +typedef LPTHREAD_START_ROUTINE w32_thread_start_func; +#else +#define HAVE__BEGINTHREADEX 1 +#define start_thread (HANDLE)_beginthreadex +typedef unsigned long (_stdcall *w32_thread_start_func)(void*); +#endif + static HANDLE -w32_create_thread(DWORD stack_size, void *func, void *val) +w32_create_thread(DWORD stack_size, w32_thread_start_func func, void *val) { - return (HANDLE)_beginthreadex(0, stack_size, func, val, CREATE_SUSPENDED, 0); + return start_thread(0, stack_size, func, val, CREATE_SUSPENDED, 0); } @@ -293,5 +303,5 @@ native_thread_destroy(rb_thread_t *th) } -static unsigned int _stdcall +static unsigned long _stdcall thread_start_func_1(void *th_ptr) { @@ -368,5 +378,5 @@ static void timer_thread_function(void); static HANDLE timer_thread_id = 0; -static unsigned int _stdcall +static unsigned long _stdcall timer_thread_func(void *dummy) { Index: vm.c =================================================================== --- vm.c (revision 12670) +++ vm.c (working copy) @@ -995,34 +995,28 @@ void yarv_init_redefined_flag(void) { - const VALUE register_info[] = { - idPLUS, BOP_PLUS, rb_cFixnum, rb_cFloat, rb_cString, rb_cArray, 0, - idMINUS, BOP_MINUS, rb_cFixnum, 0, - idMULT, BOP_MULT, rb_cFixnum, rb_cFloat, 0, - idDIV, BOP_DIV, rb_cFixnum, rb_cFloat, 0, - idMOD, BOP_MOD, rb_cFixnum, rb_cFloat, 0, - idEq, BOP_EQ, rb_cFixnum, rb_cFloat, rb_cString, 0, - idLT, BOP_LT, rb_cFixnum, 0, - idLE, BOP_LE, rb_cFixnum, 0, - idLTLT, BOP_LTLT, rb_cString, rb_cArray, 0, - idAREF, BOP_AREF, rb_cArray, rb_cHash, 0, - idASET, BOP_ASET, rb_cArray, rb_cHash, 0, - idLength, BOP_LENGTH, rb_cArray, rb_cString, rb_cHash, 0, - idSucc, BOP_SUCC, rb_cFixnum, rb_cString, rb_cTime, 0, - idGT, BOP_GT, rb_cFixnum, 0, - idGE, BOP_GE, rb_cFixnum, 0, - 0, - }; - const VALUE *ptr = register_info; + ID mid; + VALUE bop; + vm_opt_method_table = st_init_numtable(); - while (*ptr) { - ID mid = *ptr++; - VALUE bop = *ptr++; - while(*ptr) { - VALUE klass = *ptr++; - add_opt_method(klass, mid, bop); - } - ptr++; - } +#define OP(mid_, bop_) (mid = id##mid_, bop = BOP_##bop_) +#define C(k) add_opt_method(rb_c##k, mid, bop) + OP(PLUS, PLUS), (C(Fixnum), C(Float), C(String), C(Array)); + OP(MINUS, MINUS), (C(Fixnum)); + OP(MULT, MULT), (C(Fixnum), C(Float)); + OP(DIV, DIV), (C(Fixnum), C(Float)); + OP(MOD, MOD), (C(Fixnum), C(Float)); + OP(Eq, EQ), (C(Fixnum), C(Float), C(String)); + OP(LT, LT), (C(Fixnum)); + OP(LE, LE), (C(Fixnum)); + OP(LTLT, LTLT), (C(String), C(Array)); + OP(AREF, AREF), (C(Array), C(Hash)); + OP(ASET, ASET), (C(Array), C(Hash)); + OP(Length, LENGTH), (C(Array), C(String), C(Hash)); + OP(Succ, SUCC), (C(Fixnum), C(String), C(Time)); + OP(GT, GT), (C(Fixnum)); + OP(GE, GE), (C(Fixnum)); +#undef C +#undef OP } -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦