Skip to content

Commit

Permalink
Compile iseq_collector.c logic only on CRuby
Browse files Browse the repository at this point in the history
* iseq_collector.c relies on many CRuby internals, there is no point to compile it on other Rubies.
* It now fails to compile on TruffleRuby:
  ../../../../ext/debug/iseq_collector.c: In function ‘imemo_type’:
  ../../../../ext/debug/iseq_collector.c:18:13: error: implicit declaration of function ‘RBASIC’ [-Werror=implicit-function-declaration]
    18 |     return (RBASIC(imemo)->flags >> FL_USHIFT) & imemo_mask;
        |            ^~~~~~
  • Loading branch information
eregon committed Nov 28, 2023
1 parent 7261bc6 commit 613c7b7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ext/debug/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,17 @@ iseq_last_line(VALUE iseqw)
}
#endif

#ifdef CRUBY
void Init_iseq_collector(void);
#endif

void
Init_debug(void)
{
#ifdef CRUBY
VALUE rb_mRubyVM = rb_const_get(rb_cObject, rb_intern("RubyVM"));
VALUE rb_cISeq = rb_const_get(rb_mRubyVM, rb_intern("InstructionSequence"));
#endif
rb_mDebugger = rb_const_get(rb_cObject, rb_intern("DEBUGGER__"));
rb_cFrameInfo = rb_const_get(rb_mDebugger, rb_intern("FrameInfo"));

Expand All @@ -210,5 +214,7 @@ Init_debug(void)
rb_define_method(rb_cISeq, "last_line", iseq_last_line, 0);
#endif

#ifdef CRUBY
Init_iseq_collector();
#endif
}
1 change: 1 addition & 0 deletions ext/debug/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$distcleanfiles << "debug_version.h"

if defined? RubyVM
$defs << '-DCRUBY'
$defs << '-DHAVE_RB_ISEQ_PARAMETERS'
$defs << '-DHAVE_RB_ISEQ_CODE_LOCATION'

Expand Down
2 changes: 2 additions & 0 deletions ext/debug/iseq_collector.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef CRUBY
#include <ruby/ruby.h>

VALUE rb_iseqw_new(VALUE v);
Expand Down Expand Up @@ -89,3 +90,4 @@ Init_iseq_collector(void)
rb_define_singleton_method(rb_mObjSpace, "each_iseq", each_iseq, 0);
rb_define_singleton_method(rb_mObjSpace, "count_iseq", count_iseq, 0);
}
#endif

0 comments on commit 613c7b7

Please sign in to comment.