Skip to content

seems to require re-writing in places #65

@simon-dedeo

Description

@simon-dedeo

I've tried to get this gem working for ruby 3.0; unfortunately, it seems that some major changes to ruby under the hood make this a rather complex problem.

A few things are simple to fix (e.g., moving "EXTERN" to "RUBY_EXTERN" in some declarations). But other issues seem to involve changes to the macros sitting inside the ruby code itself, e.g., "RB_OBJ_WRITE", which has a new definition in ruby 3.0.

linalg.c:154:5: error: cannot take the address of an rvalue of type 'VALUE' (aka 'unsigned long')
    RBGSL_SET_CLASS(omatrix, cgsl_matrix_LU);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/rb_gsl_common.h:302:5: note: expanded from macro 'RBGSL_SET_CLASS'
    RBGSL_SET_CLASS0(_obj_, cls); \
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/rb_gsl_common.h:296:56: note: expanded from macro 'RBGSL_SET_CLASS0'
#define RBGSL_SET_CLASS0(obj0, cls) RB_OBJ_WRITE(obj0, &(RBASIC_CLASS(obj0)), cls)
                                    ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/ruby-3.0.0/ruby/internal/rgengc.h:108:52: note: expanded from macro 'RB_OBJ_WRITE'
    RBIMPL_CAST(rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/ruby-3.0.0/ruby/internal/cast.h:33:29: note: expanded from macro 'RBIMPL_CAST'
# define RBIMPL_CAST(expr) (expr)

After a lot of fiddling, I think there's a solution.

  1. First, replace all "EXTERN" and "extern" with "RUBY_EXTERN" and "RUBY_EXTERN". You can do this using rpl.
  2. The remaining problem is the RBGSL_SET_CLASS macro. In the updated ruby 3.0, there's a new macro that sets the class directly. You'll want to edit the older definition of RBGSL_SET_CLASS as follows (I think):
#ifndef RBGSL_SET_CLASS
#define RBGSL_SET_CLASS(obj, cls) do { \
    VALUE _obj_ = (obj); \
    RBASIC_SET_CLASS(_obj_, cls); \
} while (0)
#endif
  1. then things actually do compile. You have to wrestle with gems for awhile, but it seems to install and run from irb3.0

If anyone's reading this and is interested in updating the gem to work with 3.0, let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions