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 5c33af4 commit 21033c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/debug/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ iseq_last_line(VALUE iseqw)
}
#endif

#ifdef CRUBY
void Init_iseq_collector(void);
#endif

void
Init_debug(void)
Expand Down Expand Up @@ -210,5 +212,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 21033c6

Please sign in to comment.