1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-22 04:17:44 +00:00
freebsd-ports/lang/ruby26
Dimitry Andric 6f95cc5245 lang/ruby{26,27}: work around clang 12 -Wcompound-token-split-by-macro warning
During an exp-run for llvm 12 (see bug 255570), it turned out that
several ruby gem extensions do not build with clang 12.0.0, for example
devel/rubygem-thrift:

compiling binary_protocol_accelerated.c
binary_protocol_accelerated.c:404:68: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
  VALUE thrift_binary_protocol_class = rb_const_get(thrift_module, rb_intern("BinaryProtocol"));
                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/ruby-2.7/ruby/ruby.h:1847:23: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                      ^
binary_protocol_accelerated.c:404:68: note: '{' token is here
  VALUE thrift_binary_protocol_class = rb_const_get(thrift_module, rb_intern("BinaryProtocol"));
                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/ruby-2.7/ruby/ruby.h:1847:24: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/ruby-2.7/ruby/ruby.h:1832:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
    {                                                   \
    ^

and similarly www/unit-ruby:

src/ruby/nxt_ruby.c:242:21: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
    nxt_ruby_call = rb_intern("call");
                    ^~~~~~~~~~~~~~~~~
/usr/local/include/ruby-2.7/ruby/ruby.h:1847:23: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                      ^
src/ruby/nxt_ruby.c:242:21: note: '{' token is here
    nxt_ruby_call = rb_intern("call");
                    ^~~~~~~~~~~~~~~~~
/usr/local/include/ruby-2.7/ruby/ruby.h:1847:24: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/ruby-2.7/ruby/ruby.h:1832:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
    {                                                   \
    ^

The gem extensions appear to purposefully compile using -Werror, and
this new -Wcompound-token-split-by-macro is enabled by default in clang
12 and later. Of course we could go over all these extensions, and
either remove -Werror or add -Wno-compound-token-split-by-macro, but
that seems quite a lot of effort.

Instead, I have submitted a pull request to ruby's GitHub, which fixes
this by modifying the main ruby.h header:
* Add RUBY_CONST_ID_CACHE_NB() (i.e. no-brace) which contains the code
  itself, without any braces
* RUBY_CONST_ID_CACHE() which uses RUBY_CONST_ID_CACHE_NB(), but puts
  braces around it (so no existing code using this macro breaks)
* Finally, change rb_intern() so the __extension__ directly creates a
  gcc statement expression, using the RUBY_CONST_ID_CACHE_NB() macro

Patch this locally in our lang/ruby26 and lang/ruby27 ports for now,
until upstream manages to get this in.

Approved by:	maintainer timeout (2 weeks)
PR:		255910
MFH:		2021Q2
2021-05-29 16:08:19 +02:00
..
files lang/ruby{26,27}: work around clang 12 -Wcompound-token-split-by-macro warning 2021-05-29 16:08:19 +02:00
distinfo
Makefile *: Remove unnecessary 'port' argument from USES=readline 2021-05-15 09:14:04 +02:00
pkg-descr
pkg-message
pkg-plist lang/ruby26: Fix improper substitution in PLIST 2021-04-26 04:36:30 +08:00