[Bug 255910] lang/ruby26 lang/ruby27: Fix clang 12 -Wcompound-token-split-by-macro warning in ruby.h
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sat May 15 19:20:32 UTC 2021
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255910
Bug ID: 255910
Summary: lang/ruby26 lang/ruby27: Fix clang 12
-Wcompound-token-split-by-macro warning in ruby.h
Product: Ports & Packages
Version: Latest
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: Individual Port(s)
Assignee: ruby at FreeBSD.org
Reporter: dim at FreeBSD.org
Flags: maintainer-feedback?(ruby at FreeBSD.org)
Assignee: ruby at FreeBSD.org
Created attachment 224976
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=224976&action=edit
Fix -Wcompound-token-split-by-macro warning in ruby26's ruby.h
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
[1]:
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 [2]:
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
(see [3]). 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
I am attaching a patch that adds these changes to the lang/ruby26 and
lang/ruby27 ports.
Also noted in the pull request is that ruby 3.0 does not need these changes, as
they have refactored ruby.h, so that it avoids emitting this warning.
[1]
http://package22.nyi.freebsd.org/data/mainamd64PR255570-default/2021-05-08_16h02m24s/logs/errors/rubygem-thrift-0.14.0,1.log
[2]
http://package22.nyi.freebsd.org/data/mainamd64PR255570-default/2021-05-08_16h02m24s/logs/errors/unit-ruby2.7-1.23.0.log
[3]
https://github.com/llvm/llvm-project/commit/0e00a95b4fad5e72851de012d3a0b2c2d01f8685
[4] https://github.com/ruby/ruby/pull/4504
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-ports-bugs
mailing list