ruby-debug / debase

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

Error while installing debase-0.2.5.beta2 #111

Open nguyener2024 opened 1 month ago

nguyener2024 commented 1 month ago

I saw the problem was reported on this issue https://github.com/ruby-debug/debase/issues/76. Even though it has been closed, but I saw different issue when installing that package with ruby 3.3.4

this is the error I got

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]

ZimbiX commented 1 month ago

I'm seeing a similar issue on 0.2.4.1 (and it's still there on 0.2.5.beta2):

➜ gem install debase -v 0.2.5.beta2
Fetching debase-0.2.5.beta2.gem
Fetching debase-ruby_core_source-3.3.1.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: /home/brendan/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/debase-0.2.5.beta2/ext
/home/brendan/.rbenv/versions/3.3.4/bin/ruby extconf.rb
checking for vm_core.h... no
checking for vm_core.h... no
**************************************************************************
No source for ruby-3.3.4-p94 (revision be1089c8ec5ba40e09b1553e36b3174bf4014d9d) provided with
debase-ruby_core_source gem. Falling back to ruby-3.3.0-p0.
**************************************************************************
checking for vm_core.h... yes
checking for iseq.h... yes
checking for version.h... yes
creating Makefile

current directory: /home/brendan/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/debase-0.2.5.beta2/ext
make DESTDIR\= sitearchdir\=./.gem.20240821-67628-tpsvjr sitelibdir\=./.gem.20240821-67628-tpsvjr clean

current directory: /home/brendan/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/debase-0.2.5.beta2/ext
make DESTDIR\= sitearchdir\=./.gem.20240821-67628-tpsvjr sitelibdir\=./.gem.20240821-67628-tpsvjr
compiling breakpoint.c
breakpoint.c: In function ‘breakpoint_init_variables’:
breakpoint.c:297:1: warning: old-style function definition [-Wold-style-definition]
  297 | breakpoint_init_variables()
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
At top level:
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
compiling context.c
context.c: In function ‘context_init_variables’:
context.c:366:1: warning: old-style function definition [-Wold-style-definition]
  366 | context_init_variables()
      | ^~~~~~~~~~~~~~~~~~~~~~
At top level:
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
compiling debase_internals.c
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:105:1: warning: old-style function definition [-Wold-style-definition]
  105 | try_disable_trace_points()
      | ^~~~~~~~~~~~~~~~~~~~~~~~
debase_internals.c: In function ‘enable_trace_points’:
debase_internals.c:128:1: warning: old-style function definition [-Wold-style-definition]
  128 | enable_trace_points()
      | ^~~~~~~~~~~~~~~~~~~
debase_internals.c: In function ‘count_stack_size’:
debase_internals.c:316:5: warning: old-style function definition [-Wold-style-definition]
  316 | int 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));
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
debase_internals.c: In function ‘Debase_init_variables’:
debase_internals.c:728:1: warning: old-style function definition [-Wold-style-definition]
  728 | Debase_init_variables()
      | ^~~~~~~~~~~~~~~~~~~~~
debase_internals.c: In function ‘Init_debase_internals’:
debase_internals.c:753:1: warning: old-style function definition [-Wold-style-definition]
  753 | Init_debase_internals()
      | ^~~~~~~~~~~~~~~~~~~~~
In file included from /home/brendan/.rbenv/versions/3.3.4/include/ruby-3.3.0/ruby/ruby.h:27,
                 from /home/brendan/.rbenv/versions/3.3.4/include/ruby-3.3.0/ruby.h:38,
                 from ./debase_internals.h:4,
                 from debase_internals.c:1:
/home/brendan/.rbenv/versions/3.3.4/include/ruby-3.3.0/ruby/internal/anyargs.h:338:142: error: passing argument 3 of ‘rb_define_module_function_01’ from incompatible pointer type [-Wincompatible-pointer-types]
  338 | #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:770:3: note: in expansion of macro ‘rb_define_module_function’
  770 |   rb_define_module_function(mDebase, "set_trace_flag_to_iseq", Debase_set_trace_flag_to_iseq, 1);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/brendan/.rbenv/versions/3.3.4/include/ruby-3.3.0/ruby/internal/anyargs.h:274: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)’}
  274 | RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/brendan/.rbenv/versions/3.3.4/include/ruby-3.3.0/ruby/internal/anyargs.h:256:41: note: in definition of macro ‘RBIMPL_ANYARGS_DECL’
  256 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__, VALUE(*)(VALUE, VALUE), int); \
      |                                         ^~~
/home/brendan/.rbenv/versions/3.3.4/include/ruby-3.3.0/ruby/internal/anyargs.h:338:142: error: passing argument 3 of ‘rb_define_module_function_01’ from incompatible pointer type [-Wincompatible-pointer-types]
  338 | #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:773:3: note: in expansion of macro ‘rb_define_module_function’
  773 |   rb_define_module_function(mDebase, "unset_iseq_flags", Debase_unset_trace_flags, 1);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/brendan/.rbenv/versions/3.3.4/include/ruby-3.3.0/ruby/internal/anyargs.h:274: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)’}
  274 | RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/brendan/.rbenv/versions/3.3.4/include/ruby-3.3.0/ruby/internal/anyargs.h:256:41: note: in definition of macro ‘RBIMPL_ANYARGS_DECL’
  256 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__, VALUE(*)(VALUE, VALUE), int); \
      |                                         ^~~
At top level:
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
make: *** [Makefile:248: debase_internals.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/brendan/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/debase-0.2.5.beta2 for inspection.
Results logged to /home/brendan/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/extensions/x86_64-linux/3.3.0/debase-0.2.5.beta2/gem_make.out

It sounds like the C compiler has changed the default for incompatible-pointer-types from warning to error. It installs successfully if I do:

bundle config --local build.debase --with-cflags=-Wno-error=incompatible-pointer-types
# or:
gem install debase -v 0.2.5.beta2 -- --with-cflags=-Wno-error=incompatible-pointer-types

So in your case, try:

bundle config --local build.debase --with-cflags=-Wno-error=incompatible-function-pointer-types
# or:
gem install debase -v 0.2.5.beta2 -- --with-cflags=-Wno-error=incompatible-function-pointer-types

Related: https://github.com/ruby-debug/debase/issues/108, https://github.com/grpc/grpc/issues/35148, https://github.com/ruby-debug/ruby-debug-ide/issues/242