Date: Sat, 15 May 2021 19:20:31 +0000 From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 255910] lang/ruby26 lang/ruby27: Fix clang 12 -Wcompound-token-split-by-macro warning in ruby.h Message-ID: <bug-255910-7788@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D255910 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@FreeBSD.org Reporter: dim@FreeBSD.org Flags: maintainer-feedback?(ruby@FreeBSD.org) Assignee: ruby@FreeBSD.org Created attachment 224976 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D224976&action= =3Dedit 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-th= rift [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 =3D rb_const_get(thrift_module, rb_intern("BinaryProtocol")); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /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 =3D rb_const_get(thrift_module, rb_intern("BinaryProtocol")); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /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 =3D 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 =3D 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 n= ew -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 remo= ve -Werror or add -Wno-compound-token-split-by-macro, but that seems quite a l= ot 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 itse= lf, 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/0e00a95b4fad5e72851de012d3a0b2c= 2d01f8685 [4] https://github.com/ruby/ruby/pull/4504 --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-255910-7788>