ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: xtkoba+ruby@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:103262] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
Date: Wed, 07 Apr 2021 01:11:17 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-91345.20210407011117.772@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17752.20210326170439.772@ruby-lang.org

Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).

File ruby-trivial-undefined-macros.patch added
File ruby-COROUTINE_LIMITED_ADDRESS_SPACE.patch added
File ruby-BIGNUM_EMBED_LEN_MAX.patch added

Using `-Wundef` I saw that the definitions of `BIGNUM_EMBED_LEN_MAX` and `COROUTINE_LIMITED_ADDRESS_SPACE` might be incorrect. Patches are attached to fix them.

Also attached is another patch to calm down `-Wundef` warnings that seem to be trivial.

----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91345

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2021-04-07  1:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
2021-03-27  3:25 ` [ruby-core:103050] " xtkoba+ruby
2021-03-27 11:43 ` [ruby-core:103059] " eregontp
2021-03-27 12:25 ` [ruby-core:103060] " xtkoba+ruby
2021-03-27 12:48 ` [ruby-core:103061] " eregontp
2021-03-29  4:49 ` [ruby-core:103079] " shyouhei
2021-04-07  1:11 ` xtkoba+ruby [this message]
2021-04-07 12:40 ` [ruby-core:103268] " xtkoba+ruby
2021-04-09  1:32 ` [ruby-core:103326] " shyouhei
2021-04-09  9:04 ` [ruby-core:103339] " shyouhei
2021-04-13 12:50 ` [ruby-core:103425] " eregontp
2021-04-14  1:00 ` [ruby-core:103444] " xtkoba+ruby
2021-04-29 13:27 ` [ruby-core:103656] " eregontp
2021-04-29 13:39 ` [ruby-core:103657] " xtkoba+ruby
2021-05-04 22:56 ` [ruby-core:103717] " mame
2021-05-04 22:58 ` [ruby-core:103718] " mame
2021-05-04 23:41 ` [ruby-core:103720] " xtkoba+ruby
2021-05-05  0:57 ` [ruby-core:103721] " eregontp
2021-05-05  1:20 ` [ruby-core:103723] " xtkoba+ruby
2021-05-05  3:57 ` [ruby-core:103728] " xtkoba+ruby
2021-05-05  4:09 ` [ruby-core:103729] " mame
2021-05-05 11:56 ` [ruby-core:103733] " eregontp
2021-05-05 12:38 ` [ruby-core:103737] " mame

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-91345.20210407011117.772@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).