From owner-freebsd-ruby@freebsd.org Sat May 15 19:20:32 2021 Return-Path: Delivered-To: freebsd-ruby@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0544064D4C6 for ; Sat, 15 May 2021 19:20:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4FjFbg6YjZz3PPC for ; Sat, 15 May 2021 19:20:31 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id DF6BE64D5AE; Sat, 15 May 2021 19:20:31 +0000 (UTC) Delivered-To: ruby@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DF2D264D56D for ; Sat, 15 May 2021 19:20:31 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjFbg5sBWz3PTl for ; Sat, 15 May 2021 19:20:31 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B18282C61 for ; Sat, 15 May 2021 19:20:31 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 14FJKVdk038445 for ; Sat, 15 May 2021 19:20:31 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 14FJKVeV038444 for ruby@FreeBSD.org; Sat, 15 May 2021 19:20:31 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" From: bugzilla-noreply@freebsd.org To: ruby@FreeBSD.org Subject: maintainer-feedback requested: [Bug 255910] lang/ruby26 lang/ruby27: Fix clang 12 -Wcompound-token-split-by-macro warning in ruby.h Date: Sat, 15 May 2021 19:20:31 +0000 X-Bugzilla-Type: request X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: ruby@FreeBSD.org X-Bugzilla-Flags: maintainer-feedback? Message-ID: In-Reply-To: References: X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-ruby@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: FreeBSD-specific Ruby discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 19:20:32 -0000 Bugzilla Automation has asked freebsd-ruby (Nobody) for maintainer-feedback: Bug 255910: lang/ruby26 lang/ruby27: Fix clang 12 -Wcompound-token-split-by-macro warning in ruby.h https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D255910 --- Description --- 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")); =09=09=09=09=09=09=09=09=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")); =09=09=09=09=09=09=09=09=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_= 16h0 2m24s/logs/errors/rubygem-thrift-0.14.0,1.log [2] http://package22.nyi.freebsd.org/data/mainamd64PR255570-default/2021-05-08_= 16h0 2m24s/logs/errors/unit-ruby2.7-1.23.0.log [3] https://github.com/llvm/llvm-project/commit/0e00a95b4fad5e72851de012d3a0b2c= 2d01 f8685 [4] https://github.com/ruby/ruby/pull/4504