Skip to content

Fails to bulid with Ruby 3.4 #410

Description

@MingcongBai

When attempting to build elinks 0.19.0 with Ruby bindings enabled (against Ruby 3.4.7), we saw the following error:

../src/scripting/ruby/core.c: In function ‘init_erb_module’:
../src/scripting/ruby/core.c:222:58: error: passing argument 3 of ‘rb_define_module_function_01’ from incompatible pointer type [-Wincompatible-pointer-types]
  222 |         rb_define_module_function(erb_module, "message", (VALUE (*)(ANYARGS))erb_module_message, 1);
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:341:143: note: in definition of macro ‘rb_define_module_function’
  341 | #define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
      |                                                                                                                                               ^~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:277:21: note: expected ‘VALUE (*)(VALUE,  VALUE)’ {aka ‘long unsigned int (*)(long unsigned int,  long unsigned int)’} but argument is of type ‘VALUE (*)(void)’ {aka ‘long unsigned int (*)(void)’}
  277 | RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:259:41: note: in definition of macro ‘RBIMPL_ANYARGS_DECL’
  259 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__, VALUE(*)(VALUE, VALUE), int); \
      |                                         ^~~
../src/scripting/ruby/core.c:223:65: error: passing argument 3 of ‘rb_define_module_function_m1’ from incompatible pointer type [-Wincompatible-pointer-types]
  223 |         rb_define_module_function(erb_module, "method_missing", (VALUE (*)(ANYARGS))erb_module_method_missing, -1);
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:341:143: note: in definition of macro ‘rb_define_module_function’
  341 | #define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
      |                                                                                                                                               ^~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:277:21: note: expected ‘VALUE (*)(int,  union <anonymous>,  VALUE)’ {aka ‘long unsigned int (*)(int,  union <anonymous>,  long unsigned int)’} but argument is of type ‘VALUE (*)(void)’ {aka ‘long unsigned int (*)(void)’}
  277 | RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:257:41: note: in definition of macro ‘RBIMPL_ANYARGS_DECL’
  257 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _m1(__VA_ARGS__, VALUE(*)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE), int); \
      |                                         ^~~
../src/scripting/ruby/core.c:224:52: error: passing argument 3 of ‘rb_define_module_function_m1’ from incompatible pointer type [-Wincompatible-pointer-types]
  224 |         rb_define_module_function(erb_module, "p", (VALUE (*)(ANYARGS))erb_stdout_p, -1);
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:341:143: note: in definition of macro ‘rb_define_module_function’
  341 | #define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
      |                                                                                                                                               ^~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:277:21: note: expected ‘VALUE (*)(int,  union <anonymous>,  VALUE)’ {aka ‘long unsigned int (*)(int,  union <anonymous>,  long unsigned int)’} but argument is of type ‘VALUE (*)(void)’ {aka ‘long unsigned int (*)(void)’}
  277 | RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:257:41: note: in definition of macro ‘RBIMPL_ANYARGS_DECL’
  257 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _m1(__VA_ARGS__, VALUE(*)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE), int); \
      |                                         ^~~
../src/scripting/ruby/core.c: In function ‘init_ruby’:
../src/scripting/ruby/core.c:241:56: error: passing argument 3 of ‘rb_define_singleton_method_01’ from incompatible pointer type [-Wincompatible-pointer-types]
  241 |         rb_define_singleton_method(rb_stdout, "write", (VALUE (*)(ANYARGS))erb_module_message, 1);
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:311:144: note: in definition of macro ‘rb_define_singleton_method’
  311 | #define rb_define_singleton_method(obj, mid, func, arity)   RBIMPL_ANYARGS_DISPATCH_rb_define_singleton_method((arity), (func))((obj), (mid), (func), (arity))
      |                                                                                                                                                ^~~~
/usr/include/ruby-3.4.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 ‘VALUE (*)(void)’ {aka ‘long unsigned int (*)(void)’}
  274 | RBIMPL_ANYARGS_DECL(rb_define_singleton_method, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:259:41: note: in definition of macro ‘RBIMPL_ANYARGS_DECL’
  259 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__, VALUE(*)(VALUE, VALUE), int); \
      |                                         ^~~
../src/scripting/ruby/core.c:242:40: error: passing argument 2 of ‘rb_define_global_function_m1’ from incompatible pointer type [-Wincompatible-pointer-types]
  242 |         rb_define_global_function("p", (VALUE (*)(ANYARGS))erb_stdout_p, -1);
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:350:136: note: in definition of macro ‘rb_define_global_function’
  350 | #define rb_define_global_function(mid, func, arity)         RBIMPL_ANYARGS_DISPATCH_rb_define_global_function((arity), (func))((mid), (func), (arity))
      |                                                                                                                                        ^~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:278:21: note: expected ‘VALUE (*)(int,  union <anonymous>,  VALUE)’ {aka ‘long unsigned int (*)(int,  union <anonymous>,  long unsigned int)’} but argument is of type ‘VALUE (*)(void)’ {aka ‘long unsigned int (*)(void)’}
  278 | RBIMPL_ANYARGS_DECL(rb_define_global_function, const char *)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/ruby-3.4.0/ruby/internal/anyargs.h:257:41: note: in definition of macro ‘RBIMPL_ANYARGS_DECL’
  257 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _m1(__VA_ARGS__, VALUE(*)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE), int); \
      |                                         ^~~

An additional patch was needed to for Meson to detect Ruby correctly:

commit 42b917d1cb017f804e101e027da388fa2df8a04f
Author: Kaiyang Wu <self@origincode.me>
Date:   Mon Mar 31 05:54:38 2025 -0700

    Fix Ruby not found on AOSC OS
    
    Signed-off-by: Kaiyang Wu <self@origincode.me>

diff --git a/meson.build b/meson.build
index 9f9d2acb8..e6b494e44 100644
--- a/meson.build
+++ b/meson.build
@@ -655,7 +655,7 @@ conf_data.set('CONFIG_PERL_POPPX_WITHOUT_N_A', 1)
 
 rubydeps = []
 if conf_data.get('CONFIG_SCRIPTING_RUBY')
-    rubydeps = dependency('ruby', static: st)
+    rubydeps = dependency('Ruby', static: st)
     deps += rubydeps
 endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions