Bug 271245 - www/rubygem-hpricot: fix build with clang 16
Summary: www/rubygem-hpricot: 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: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks: 271047
  Show dependency treegraph
 
Reported: 2023-05-04 18:18 UTC by Dimitry Andric
Modified: 2023-05-07 21:38 UTC (History)
0 users

See Also:
sunpoet: maintainer-feedback+


Attachments
www/rubygem-hpricot: fix build with clang 16 (3.96 KB, patch)
2023-05-04 18:19 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-04 18:18:48 UTC
Clang 16 has a new error about incompatible function types, which shows up when building www/rubygem-hpricot:

  fast_xs.c:165:39: error: incompatible function pointer types passing 'VALUE (VALUE)' (aka 'unsigned long (unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
          array = rb_rescue(unpack_utf8, self, unpack_uchar, self);
                                               ^~~~~~~~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/iterator.h:364:62: note: passing argument to parameter 'r_proc' here
  VALUE rb_rescue(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2);
                                                               ^

This is because the r_proc parameter of rb_rescue() should be a pointer to a function taking two VALUE parameters, not one (the second parameter can contain an exception to be handled).

Another similar error occurs later in hpricot_scan.c, which was generated from hpricot_scan.rl:

  hpricot_scan.rl:855:3: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
    rb_define_singleton_method(mHpricot, "css", hpricot_css, 3);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:307:143: note: expanded from macro 'rb_define_singleton_method'
  #define rb_define_singleton_method(obj, mid, func, arity)   RBIMPL_ANYARGS_DISPATCH_rb_define_singleton_method((arity), (func))((obj), (mid), (func), (arity))
                                                                                                                                                ^~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:270:1: note: passing argument to parameter here
  RBIMPL_ANYARGS_DECL(rb_define_singleton_method, VALUE, const char *)
  ^

This is because the func parameter of rb_define_singleton_method() should be a pointer to a function taking four VALUE parameters, not five.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2023-05-04 18:19:29 UTC
Created attachment 241978 [details]
www/rubygem-hpricot: fix build with clang 16
Comment 2 Po-Chuan Hsieh freebsd_committer freebsd_triage 2023-05-07 20:55:58 UTC
LGTM.
Could you please merge the patch files into a single one "patch-clang16"?
Thanks.
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-05-07 21:37:43 UTC
A commit in branch main references this bug:

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

commit 5a61c2c8ba854fc5131d45f84e9d84f484631989
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-05-04 18:17:18 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-05-07 21:35:52 +0000

    www/rubygem-hpricot: fix build with clang 16

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

      fast_xs.c:165:39: error: incompatible function pointer types passing 'VALUE (VALUE)' (aka 'unsigned long (unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
              array = rb_rescue(unpack_utf8, self, unpack_uchar, self);
                                                   ^~~~~~~~~~~~
      /usr/local/include/ruby-3.1/ruby/internal/iterator.h:364:62: note: passing argument to parameter 'r_proc' here
      VALUE rb_rescue(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2);
                                                                   ^

    This is because the r_proc parameter of rb_rescue() should be a pointer
    to a function taking two VALUE parameters, not one (the second parameter
    can contain an exception to be handled).

    Another similar error occurs later in hpricot_scan.c, which was
    generated from hpricot_scan.rl:

      hpricot_scan.rl:855:3: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
        rb_define_singleton_method(mHpricot, "css", hpricot_css, 3);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:307:143: note: expanded from macro 'rb_define_singleton_method'
      #define rb_define_singleton_method(obj, mid, func, arity)   RBIMPL_ANYARGS_DISPATCH_rb_define_singleton_method((arity), (func))((obj), (mid), (func), (arity))
                                                                                                                                                    ^~~~~~
      /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:270:1: note: passing argument to parameter here
      RBIMPL_ANYARGS_DECL(rb_define_singleton_method, VALUE, const char *)
      ^

    This is because the func parameter of rb_define_singleton_method()
    should be a pointer to a function taking four VALUE parameters, not five.

    PR:             271245
    Approved by:    sunpoet (maintainer)
    MFH:            2023Q2

 www/rubygem-hpricot/Makefile                  |  1 +
 www/rubygem-hpricot/files/patch-clang16 (new) | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)