From 21033c63cba6c2a0b402c3334668e998125b94a5 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 28 Nov 2023 12:02:58 +0100 Subject: [PATCH] Compile iseq_collector.c logic only on CRuby MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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; | ^~~~~~ --- ext/debug/debug.c | 4 ++++ ext/debug/extconf.rb | 1 + ext/debug/iseq_collector.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/ext/debug/debug.c b/ext/debug/debug.c index 9eaac2bbd..f1161440f 100644 --- a/ext/debug/debug.c +++ b/ext/debug/debug.c @@ -180,7 +180,9 @@ iseq_last_line(VALUE iseqw) } #endif +#ifdef CRUBY void Init_iseq_collector(void); +#endif void Init_debug(void) @@ -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 } diff --git a/ext/debug/extconf.rb b/ext/debug/extconf.rb index b4e78fbe3..dc2964d2c 100644 --- a/ext/debug/extconf.rb +++ b/ext/debug/extconf.rb @@ -4,6 +4,7 @@ $distcleanfiles << "debug_version.h" if defined? RubyVM + $defs << '-DCRUBY' $defs << '-DHAVE_RB_ISEQ_PARAMETERS' $defs << '-DHAVE_RB_ISEQ_CODE_LOCATION' diff --git a/ext/debug/iseq_collector.c b/ext/debug/iseq_collector.c index f87c4f978..3504dee6d 100644 --- a/ext/debug/iseq_collector.c +++ b/ext/debug/iseq_collector.c @@ -1,3 +1,4 @@ +#ifdef CRUBY #include VALUE rb_iseqw_new(VALUE v); @@ -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