From: mame@... Date: 2021-05-04T22:56:20+00:00 Subject: [ruby-core:103717] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository Issue #17752 has been updated by mame (Yusuke Endoh). Status changed from Closed to Assigned I think this change broke the following servers on RubyCI. * [Ubuntu armv7l eabihf](http://rubyci.s3.amazonaws.com/scw-9d6766/ruby-master/log/20210504T221708Z.fail.html.gz) * [CentOS 7.6(1810) x86_64](http://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20210504T213003Z.fail.html.gz) * [RHEL 7.1 s390x](http://rubyci.s3.amazonaws.com/rhel_zlinux/ruby-master/log/20210504T213302Z.fail.html.gz) * [FreeBSD 12.2 x64](http://rubyci.s3.amazonaws.com/freebsd12/ruby-master/log/20210504T223001Z.fail.html.gz) * [macOS Big Sur (ARM)](http://rubyci.s3.amazonaws.com/osx1100arm/ruby-master/log/20210504T214504Z.fail.html.gz) @eregon Could you please fix them? ---------------------------------------- Feature #17752: Enable -Wundef for C extensions in repository https://bugs.ruby-lang.org/issues/17752#change-91811 * Author: Eregon (Benoit Daloze) * Status: Assigned * Priority: Normal * Assignee: Eregon (Benoit Daloze) * Target version: 3.1 ---------------------------------------- I would like to enable `-Wundef` for C extensions built/bundled with CRuby. From https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html > -Wundef > Warn if an undefined identifier is evaluated in an #if directive. Such identifiers are replaced with zero. I found this warning to be quite useful, notably when investigating why a given C extension did not include some code I expected, and then building those extensions on TruffleRuby. There are a couple places not respecting this currently but they seem trivial to fix, I can do that. For instance a confusing case is: https://github.com/ruby/ruby/blob/9143d21b1bf2f16b1e847d569a588510726d8860/ext/nkf/nkf-utf8/nkf.h#L19 ``` #if DEFAULT_NEWLINE == 0x0D0A ``` which without -Wundef would just exclude the code without any warning if DEFAULT_NEWLINE is not defined. I'm not sure if we should/can enable it for C extensions in general (installed as gems), as if a C extensions uses -Werror and would have such a warning it would no longer build. I can make a PR for this. I'm not sure where to add -Wundef though, should it be in https://github.com/ruby/ruby/blob/9143d21b1bf2f16b1e847d569a588510726d8860/configure.ac#L620, or maybe in mkmf.rb? ---Files-------------------------------- ruby-USE_BACKTRACE.patch (1.21 KB) ruby-BIGNUM_EMBED_LEN_MAX.patch (950 Bytes) ruby-COROUTINE_LIMITED_ADDRESS_SPACE.patch (711 Bytes) ruby-trivial-undefined-macros.patch (4.35 KB) ruby-trivial-undefind-macros-0002.patch (1.44 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: