ruby-debug / debase

BSD 2-Clause "Simplified" License
209 stars 32 forks source link

Ruby 3.0.0 compatibilty #92

Closed Govinda-Fichtner closed 3 years ago

Govinda-Fichtner commented 3 years ago

I am currently getting the following error when I try to install debase:

# gem install debase
Building native extensions. This could take a while...
ERROR:  Error installing debase:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/debase-0.2.4.1/ext
/root/.rbenv/versions/3.0.0/bin/ruby -I /root/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -r ./siteconf20201226-13989-9lckur.rb extconf.rb
checking for vm_core.h... no
checking for vm_core.h... no
**************************************************************************
No source for ruby-3.0.0-p0 (revision 95aff214687a5e12c3eb57d056665741e734c188) provided with
debase-ruby_core_source gem. Falling back to ruby-3.0.0-preview1.
**************************************************************************
checking for vm_core.h... yes
checking for iseq.h... yes
checking for version.h... yes
checking for vm_core.h... yes
checking for vm_insnhelper.h... yes
checking for vm_core.h... yes
checking for method.h... yes
creating Makefile

current directory: /usr/local/bundle/gems/debase-0.2.4.1/ext
make "DESTDIR=" clean

current directory: /usr/local/bundle/gems/debase-0.2.4.1/ext
make "DESTDIR="
compiling breakpoint.c
compiling context.c
compiling debase_internals.c
In file included from ./hacks.h:1,
                 from debase_internals.c:2:
/usr/local/bundle/gems/debase-ruby_core_source-0.10.11/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_core.h:1617:21: error: expected declaration specifiers or '...' before '*' token
 1617 | typedef RETSIGTYPE (*ruby_sighandler_t)(int);
      |                     ^
In file included from /root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/defines.h:73,
                 from /root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/ruby.h:23,
                 from /root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby.h:38,
                 from ./debase_internals.h:4,
                 from debase_internals.c:1:
/usr/local/bundle/gems/debase-ruby_core_source-0.10.11/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_core.h:1618:39: error: unknown type name 'ruby_sighandler_t'; did you mean 'sighandler_t'?
 1618 | NORETURN(void rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const void *, const char *fmt, ...));
      |                                       ^~~~~~~~~~~~~~~~~
/root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/backward/2/attributes.h:152:44: note: in definition of macro 'NORETURN'
  152 | #define NORETURN(x) RBIMPL_ATTR_NORETURN() x
      |                                            ^
debase_internals.c: In function 'print_debug':
debase_internals.c:36:3: warning: function 'print_debug' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
   36 |   vfprintf(stderr, message, ap);
      |   ^~~~~~~~
debase_internals.c: In function 'try_disable_trace_points':
debase_internals.c:111:8: warning: implicit declaration of function 'RHASH_EMPTY_P' [-Wimplicit-function-declaration]
  111 |   if (!RHASH_EMPTY_P(catchpoints)) return;
      |        ^~~~~~~~~~~~~
debase_internals.c: In function 'count_stack_size':
debase_internals.c:319:37: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  319 |     rb_control_frame_t *start_cfp = RUBY_VM_END_CONTROL_FRAME(TH_INFO(thread));
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/ruby.h:24,
                 from /root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby.h:38,
                 from ./debase_internals.h:4,
                 from debase_internals.c:1:
debase_internals.c: In function 'Init_debase_internals':
/root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/internal/anyargs.h:337:142: warning: passing argument 3 of 'rb_define_module_function_01' from incompatible pointer type [-Wincompatible-pointer-types]
  337 | #define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
      |                                                                                                                                              ^~~~~~
      |                                                                                                                                              |
      |                                                                                                                                              void (*)(VALUE,  VALUE) {aka void (*)(long unsigned int,  long unsigned int)}
debase_internals.c:768:3: note: in expansion of macro 'rb_define_module_function'
  768 |   rb_define_module_function(mDebase, "set_trace_flag_to_iseq", Debase_set_trace_flag_to_iseq, 1);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
/root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/internal/anyargs.h:273:21: note: expected 'VALUE (*)(VALUE,  VALUE)' {aka 'long unsigned int (*)(long unsigned int,  long unsigned int)'} but argument is of type 'void (*)(VALUE,  VALUE)' {aka 'void (*)(long unsigned int,  long unsigned int)'}
  273 | RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/internal/anyargs.h:255:41: note: in definition of macro 'RBIMPL_ANYARGS_DECL'
  255 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__, VALUE(*)(VALUE, VALUE), int); \
      |                                         ^~~
/root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/internal/anyargs.h:337:142: warning: passing argument 3 of 'rb_define_module_function_01' from incompatible pointer type [-Wincompatible-pointer-types]
  337 | #define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
      |                                                                                                                                              ^~~~~~
      |                                                                                                                                              |
      |                                                                                                                                              void (*)(VALUE,  VALUE) {aka void (*)(long unsigned int,  long unsigned int)}
debase_internals.c:771:3: note: in expansion of macro 'rb_define_module_function'
  771 |   rb_define_module_function(mDebase, "unset_iseq_flags", Debase_unset_trace_flags, 1);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
/root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/internal/anyargs.h:273:21: note: expected 'VALUE (*)(VALUE,  VALUE)' {aka 'long unsigned int (*)(long unsigned int,  long unsigned int)'} but argument is of type 'void (*)(VALUE,  VALUE)' {aka 'void (*)(long unsigned int,  long unsigned int)'}
  273 | RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/root/.rbenv/versions/3.0.0/include/ruby-3.0.0/ruby/internal/anyargs.h:255:41: note: in definition of macro 'RBIMPL_ANYARGS_DECL'
  255 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__, VALUE(*)(VALUE, VALUE), int); \
      |                                         ^~~
debase_internals.c: At top level:
cc1: warning: unrecognized command line option '-Wno-self-assign'
cc1: warning: unrecognized command line option '-Wno-parentheses-equality'
cc1: warning: unrecognized command line option '-Wno-constant-logical-operand'
make: *** [Makefile:245: debase_internals.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/bundle/gems/debase-0.2.4.1 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux-musl/3.0.0/debase-0.2.4.1/gem_make.out

I am getting this error with a standard alpine ruby image (ruby:3.0-rc-alpine) or by using a rbenv installed ruby version.

Any ideas how to fix it?

hurricup commented 3 years ago

ruby3-compatible gem wasn't released yet.

Govinda-Fichtner commented 3 years ago

@hurricup Is there already a beta version that one can test drive? Any expectations for when a ruby3 compatible gem could arrive?

hurricup commented 3 years ago

Not yet

hurricup commented 3 years ago

Please, check https://github.com/ruby-debug/debase/releases/tag/v0.2.5.beta2

casperisfine commented 3 years ago

@hurricup no huge deal, but could we have a non-beta release?

EverardB commented 2 years ago

Is there anything on the roadmap for the 0.2.5 (non-beta) release?

hurricup commented 2 years ago

@EverardB for now main goal is to migrate from debase to the new debugging gem bundled with new ruby versions.

BenSandeen commented 1 year ago

@EverardB for now main goal is to migrate from debase to the new debugging gem bundled with new ruby versions.

@hurricup Are you referring to the gem named debugging? This one, right? https://rubygems.org/gems/debugging

Update: After looking at that gem more, I'm less confident that's the correct one :/

hurricup commented 1 year ago

@BenSandeen no, https://github.com/ruby/debug

AndyObtiva commented 8 months ago

I am having a similar issue on my M2 Chip Mac ARM64 (Sonoma 14.4 & ruby 3.0.6p216 & xcode-select version 2406):

% gem install debase -v0.2.5.beta2                                                            
Fetching debase-ruby_core_source-3.3.1.gem
Fetching debase-0.2.5.beta2.gem
Successfully installed debase-ruby_core_source-3.3.1
Building native extensions. This could take a while...
ERROR:  Error installing debase:
  ERROR: Failed to build gem native extension.

    current directory: ~/.rvm/gems/ruby-3.0.6@debase-temp/gems/debase-0.2.5.beta2/ext
~/.rvm/rubies/ruby-3.0.6/bin/ruby -I ~/.rvm/rubies/ruby-3.0.6/lib/ruby/3.0.0 -r ./siteconf20240321-87109-znf1i2.rb extconf.rb
checking for vm_core.h... yes
checking for iseq.h... yes
checking for version.h... yes
creating Makefile

current directory: ~/.rvm/gems/ruby-3.0.6@debase-temp/gems/debase-0.2.5.beta2/ext
make DESTDIR\= clean

current directory: ~/.rvm/gems/ruby-3.0.6@debase-temp/gems/debase-0.2.5.beta2/ext
make DESTDIR\=
compiling breakpoint.c
compiling context.c
compiling debase_internals.c
debase_internals.c:319:25: warning: initializing 'rb_control_frame_t *' (aka 'struct rb_control_frame_struct *') with an expression of type 'const rb_control_frame_t *' (aka 'const struct rb_control_frame_struct *') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    rb_control_frame_t *start_cfp = RUBY_VM_END_CONTROL_FRAME(TH_INFO(thread));
                        ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
debase_internals.c:770:3: error: incompatible function pointer types passing 'void (VALUE, VALUE)' (aka 'void (unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_module_function(mDebase, "set_trace_flag_to_iseq", Debase_set_trace_flag_to_iseq, 1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~/.rvm/rubies/ruby-3.0.6/include/ruby-3.0.0/ruby/internal/anyargs.h:337:142: note: expanded from macro 'rb_define_module_function'
#define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
                                                                                                                                             ^~~~~~
~/.rvm/rubies/ruby-3.0.6/include/ruby-3.0.0/ruby/internal/anyargs.h:273:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
^
~/.rvm/rubies/ruby-3.0.6/include/ruby-3.0.0/ruby/internal/anyargs.h:255:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__, VALUE(*)(VALUE, VALUE), int); \
                                                                       ^
debase_internals.c:773:3: error: incompatible function pointer types passing 'void (VALUE, VALUE)' (aka 'void (unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_module_function(mDebase, "unset_iseq_flags", Debase_unset_trace_flags, 1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~/.rvm/rubies/ruby-3.0.6/include/ruby-3.0.0/ruby/internal/anyargs.h:337:142: note: expanded from macro 'rb_define_module_function'
#define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
                                                                                                                                             ^~~~~~
~/.rvm/rubies/ruby-3.0.6/include/ruby-3.0.0/ruby/internal/anyargs.h:273:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
^
~/.rvm/rubies/ruby-3.0.6/include/ruby-3.0.0/ruby/internal/anyargs.h:255:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__, VALUE(*)(VALUE, VALUE), int); \
                                                                       ^
1 warning and 2 errors generated.
make: *** [debase_internals.o] Error 1

make failed, exit code 2

Gem files will remain installed in ~/.rvm/gems/ruby-3.0.6@debase-temp/gems/debase-0.2.5.beta2 for inspection.
Results logged to ~/.rvm/gems/ruby-3.0.6@debase-temp/extensions/arm64-darwin-23/3.0.0/debase-0.2.5.beta2/gem_make.out

I was able to resolve the issue by installing the gem with cflags:

gem install debase -v0.2.5.beta2 -- --with-cflags="-Wno-incompatible-function-pointer-types"

Still, it would be better in the future if I didn't have to set those cflags and could install the gem normally instead.

By the way, one weird thing I discovered from a coworker who uses RubyMine (I don't, but share the same project that has the debase and ruby-debug-ide gems in the development gem group) is he has version 3.0.0.beta10 & 3.0.0.beta15 of debase and ruby-debug-ide respectively, which are NOT on rubygems.org as of today (2024-03-21).