Skip to content

Commit 5d98691

Browse files
eregonko1
authored andcommitted
Compile iseq_collector.c logic only on CRuby
* 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; | ^~~~~~
1 parent 233c4a0 commit 5d98691

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

ext/debug/debug.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,17 @@ iseq_last_line(VALUE iseqw)
180180
}
181181
#endif
182182

183+
#ifdef HAVE_RB_ISEQ
183184
void Init_iseq_collector(void);
185+
#endif
184186

185187
void
186188
Init_debug(void)
187189
{
190+
#ifdef HAVE_RB_ISEQ
188191
VALUE rb_mRubyVM = rb_const_get(rb_cObject, rb_intern("RubyVM"));
189192
VALUE rb_cISeq = rb_const_get(rb_mRubyVM, rb_intern("InstructionSequence"));
193+
#endif
190194
rb_mDebugger = rb_const_get(rb_cObject, rb_intern("DEBUGGER__"));
191195
rb_cFrameInfo = rb_const_get(rb_mDebugger, rb_intern("FrameInfo"));
192196

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

217+
#ifdef HAVE_RB_ISEQ
213218
Init_iseq_collector();
219+
#endif
214220
}

ext/debug/extconf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
$distcleanfiles << "debug_version.h"
55

66
if defined? RubyVM
7+
$defs << '-DHAVE_RB_ISEQ'
78
$defs << '-DHAVE_RB_ISEQ_PARAMETERS'
89
$defs << '-DHAVE_RB_ISEQ_CODE_LOCATION'
910

ext/debug/iseq_collector.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <ruby/ruby.h>
22

3+
#ifdef HAVE_RB_ISEQ
34
VALUE rb_iseqw_new(VALUE v);
45
void rb_objspace_each_objects(
56
int (*callback)(void *start, void *end, size_t stride, void *data),
@@ -89,3 +90,4 @@ Init_iseq_collector(void)
8990
rb_define_singleton_method(rb_mObjSpace, "each_iseq", each_iseq, 0);
9091
rb_define_singleton_method(rb_mObjSpace, "count_iseq", count_iseq, 0);
9192
}
93+
#endif

0 commit comments

Comments
 (0)