Bug 271706 - graphics/rubygem-cairo: fix build with clang 16
Summary: graphics/rubygem-cairo: fix build with clang 16
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ruby (Nobody)
URL:
Keywords:
Depends on:
Blocks: 271047
  Show dependency treegraph
 
Reported: 2023-05-29 13:35 UTC by Dimitry Andric
Modified: 2023-06-04 16:24 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (ruby)


Attachments
graphics/rubygem-cairo: fix build with clang 16 (4.30 KB, patch)
2023-05-29 13:36 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2023-05-29 13:35:50 UTC
Clang 16 has a new error about incompatible function types, which shows
up when building graphics/rubygem-cairo:

  rb_cairo_surface.c:2354:3: error: incompatible function pointer types passing 'VALUE (int, VALUE *, VALUE)' (aka 'unsigned long (int, unsigned long *, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_method (rb_cCairo_GLSurface, "initialize",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:287:135: note: expanded from macro 'rb_define_method'
  #define rb_define_method(klass, mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
                                                                                                                                        ^~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:276:1: note: passing argument to parameter here
  RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
  ^
  /usr/local/include/ruby-3.1/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); \
                                                                         ^
  rb_cairo_surface.c:2368:3: error: incompatible function pointer types passing 'VALUE (int, VALUE *, VALUE)' (aka 'unsigned long (int, unsigned long *, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_method (rb_cCairo_GLTextureSurface, "initialize",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:287:135: note: expanded from macro 'rb_define_method'
  #define rb_define_method(klass, mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
                                                                                                                                        ^~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:276:1: note: passing argument to parameter here
  RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
  ^
  /usr/local/include/ruby-3.1/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); \
                                                                         ^

This is because rb_define_method's last argument is the 'arity' of the
method, and in case of cr_gl_surface_initialize() and
cr_gl_texture_surface_initialize() it should be -1 to indicate a
variable number of arguments.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2023-05-29 13:36:24 UTC
Created attachment 242478 [details]
graphics/rubygem-cairo: fix build with clang 16
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2023-05-29 13:44:46 UTC
Also submitted upstream: https://github.com/rcairo/rcairo/pull/79
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-06-04 16:22:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=eff4307ac72a9630c67d030e0565fde34ff82d7d

commit eff4307ac72a9630c67d030e0565fde34ff82d7d
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-05-29 13:20:55 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-04 16:21:24 +0000

    graphics/rubygem-cairo: fix build with clang 16

    Clang 16 has a new error about incompatible function types, which shows
    up when building graphics/rubygem-cairo:

      rb_cairo_surface.c:2354:3: error: incompatible function pointer types passing 'VALUE (int, VALUE *, VALUE)' (aka 'unsigned long (int, unsigned long *, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_define_method (rb_cCairo_GLSurface, "initialize",
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:287:135: note: expanded from macro 'rb_define_method'
      #define rb_define_method(klass, mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
                                                                                                                                            ^~~~~~
      /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:276:1: note: passing argument to parameter here
      RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
      ^
      /usr/local/include/ruby-3.1/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); \
                                                                             ^
      rb_cairo_surface.c:2368:3: error: incompatible function pointer types passing 'VALUE (int, VALUE *, VALUE)' (aka 'unsigned long (int, unsigned long *, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_define_method (rb_cCairo_GLTextureSurface, "initialize",
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:287:135: note: expanded from macro 'rb_define_method'
      #define rb_define_method(klass, mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
                                                                                                                                            ^~~~~~
      /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:276:1: note: passing argument to parameter here
      RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
      ^
      /usr/local/include/ruby-3.1/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); \
                                                                             ^

    This is because rb_define_method's last argument is the 'arity' of the
    method, and in case of cr_gl_surface_initialize() and
    cr_gl_texture_surface_initialize() it should be -1 to indicate a
    variable number of arguments.

    PR:             271706
    Approved by:    portmgr (buildfix blanket)
    MFH:            2023Q2

 graphics/rubygem-cairo/Makefile                      |  1 +
 .../files/patch-ext_cairo_rb__cairo__surface.c (new) | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2023-06-04 16:24:50 UTC
Note: upstream has accepted the pull request.