* [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
@ 2021-03-26 17:04 eregontp
2021-03-27 3:25 ` [ruby-core:103050] " xtkoba+ruby
` (21 more replies)
0 siblings, 22 replies; 23+ messages in thread
From: eregontp @ 2021-03-26 17:04 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been reported by Eregon (Benoit Daloze).
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752
* 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?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103050] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
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 ` xtkoba+ruby
2021-03-27 11:43 ` [ruby-core:103059] " eregontp
` (20 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-03-27 3:25 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).
I think it's just a matter of coding style to allow evaluating undefined identifiers, whether it is good or bad.
The example of `ext/nkf/nkf-utf8/nkf.h` seems intentional, just not bothering to write:
```c
#ifndef DEFAULT_NEWLINE
#define DEFAULT_NEWLINE 0
#endif
```
If this practice should be error-prone, we might have to change the style. I am neutral for now.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91111
* 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?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103059] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
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 ` eregontp
2021-03-27 12:25 ` [ruby-core:103060] " xtkoba+ruby
` (19 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: eregontp @ 2021-03-27 11:43 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by Eregon (Benoit Daloze).
The `#if UNDEFINED_IDENTIFIER` seems fairly rare (56 vs 637), so it also seems more consistent to always use `#ifdef` if the identifier might not always be defined.
One example is:
```c
#if HAVE_RB_EXT_RACTOR_SAFE
```
vs
```c
#ifdef HAVE_RB_EXT_RACTOR_SAFE
```
The second seems better to me, and is more explicit about the fact this might not be defined.
The value of the macro ultimately does not matter for all `HAVE_` macros.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91120
* 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?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103060] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
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 ` xtkoba+ruby
2021-03-27 12:48 ` [ruby-core:103061] " eregontp
` (18 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-03-27 12:25 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).
File ruby-USE_BACKTRACE.patch added
> The value of the macro ultimately does not matter for all `HAVE_` macros.
There is a counterexample: `HAVE_BACKTRACE` in `vm_dump.c`, which is redefined as 0 when `BROKEN_BACKTRACE` is defined. I feel this to be an abuse of `HAVE_` macros, and I would like to define a new macro `USE_BACKTRACE` indicating whether `backtrace` should be used or not, as in the attached patch.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91121
* 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)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103061] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (2 preceding siblings ...)
2021-03-27 12:25 ` [ruby-core:103060] " xtkoba+ruby
@ 2021-03-27 12:48 ` eregontp
2021-03-29 4:49 ` [ruby-core:103079] " shyouhei
` (17 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: eregontp @ 2021-03-27 12:48 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by Eregon (Benoit Daloze).
Indeed, and that patch looks good to me.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91122
* 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)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103079] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (3 preceding siblings ...)
2021-03-27 12:48 ` [ruby-core:103061] " eregontp
@ 2021-03-29 4:49 ` shyouhei
2021-04-07 1:11 ` [ruby-core:103262] " xtkoba+ruby
` (16 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: shyouhei @ 2021-03-29 4:49 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by shyouhei (Shyouhei Urabe).
As far as the effect of `-Wundef` do not leak to 3rd party extension libraries, yes I'm in favor of it. It sounds a bit too harsh for 3rd parties.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91140
* 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)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103262] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (4 preceding siblings ...)
2021-03-29 4:49 ` [ruby-core:103079] " shyouhei
@ 2021-04-07 1:11 ` xtkoba+ruby
2021-04-07 12:40 ` [ruby-core:103268] " xtkoba+ruby
` (15 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-04-07 1:11 UTC (permalink / raw)
To: ruby-core
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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103268] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (5 preceding siblings ...)
2021-04-07 1:11 ` [ruby-core:103262] " xtkoba+ruby
@ 2021-04-07 12:40 ` xtkoba+ruby
2021-04-09 1:32 ` [ruby-core:103326] " shyouhei
` (14 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-04-07 12:40 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).
I noticed that `-Wundef` is explicitly disabled for GCC at [include/ruby/internal/token_paste.h:40](https://github.com/ruby/ruby/blob/587e6800086764a1b7c959976acef33e230dccc2/include/ruby/internal/token_paste.h#L40):
```c
#if RBIMPL_COMPILER_SINCE(GCC, 4, 2, 0)
# /* GCC is one of such compiler who cannot write `_Pragma` inside of a `#if`.
# * Cannot but globally kill everything. This is of course a very bad thing.
# * If you know how to reroute this please tell us. */
# /* https://gcc.godbolt.org/z/K2xr7X */
# define RBIMPL_TOKEN_PASTE(x, y) TOKEN_PASTE(x, y)
# pragma GCC diagnostic ignored "-Wundef"
# /* > warning: "symbol" is not defined, evaluates to 0 [-Wundef] */
```
The problem is that GCC is a major compiler that is widely used in CI, and so we will still be missing a lot of potential problems even if `-Wundef` is enabled by default.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91353
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103326] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (6 preceding siblings ...)
2021-04-07 12:40 ` [ruby-core:103268] " xtkoba+ruby
@ 2021-04-09 1:32 ` shyouhei
2021-04-09 9:04 ` [ruby-core:103339] " shyouhei
` (13 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: shyouhei @ 2021-04-09 1:32 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by shyouhei (Shyouhei Urabe).
xtkoba (Tee KOBAYASHI) wrote in #note-7:
> I noticed that `-Wundef` is explicitly disabled for GCC at [include/ruby/internal/token_paste.h:40](https://github.com/ruby/ruby/blob/587e6800086764a1b7c959976acef33e230dccc2/include/ruby/internal/token_paste.h#L40):
Ah yes I remember. This is because for instance `TOKEN_PASTE(re, strict)` issues undefined macro warning for "re", in spite of the rendered token `restrict` being valid.
PS. `TOKEN_PASTE` is a macro defined by configure.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91417
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103339] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (7 preceding siblings ...)
2021-04-09 1:32 ` [ruby-core:103326] " shyouhei
@ 2021-04-09 9:04 ` shyouhei
2021-04-13 12:50 ` [ruby-core:103425] " eregontp
` (12 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: shyouhei @ 2021-04-09 9:04 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by shyouhei (Shyouhei Urabe).
My attempt https://github.com/ruby/ruby/pull/4371
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91430
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103425] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (8 preceding siblings ...)
2021-04-09 9:04 ` [ruby-core:103339] " shyouhei
@ 2021-04-13 12:50 ` eregontp
2021-04-14 1:00 ` [ruby-core:103444] " xtkoba+ruby
` (11 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: eregontp @ 2021-04-13 12:50 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by Eregon (Benoit Daloze).
@xtkoba Your 4 patches look good to me, could you commit them?
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91518
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103444] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (9 preceding siblings ...)
2021-04-13 12:50 ` [ruby-core:103425] " eregontp
@ 2021-04-14 1:00 ` xtkoba+ruby
2021-04-29 13:27 ` [ruby-core:103656] " eregontp
` (10 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-04-14 1:00 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).
File ruby-trivial-undefind-macros-0002.patch added
Thanks to user:shyouhei's work, we are now able to notice undefined identifiers evaluated in `#if` directives using GCC with `-Wundef`.
I attach an additional patch that fixes undefined identifiers from being evaluated.
Note that there must still remain a whole bunch of `#if HAVE_...` that I do not aware of because it is defined in my environment.
user:Eregon I am not sure these patches conform to the coding style. Especally I doubt if the macro of the name `_RVALUE_EMBED_LEN_MAX` is allowed. Could anyone brush up and commit them in place of me?
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91536
* 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)
ruby-trivial-undefind-macros-0002.patch (1.44 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103656] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (10 preceding siblings ...)
2021-04-14 1:00 ` [ruby-core:103444] " xtkoba+ruby
@ 2021-04-29 13:27 ` eregontp
2021-04-29 13:39 ` [ruby-core:103657] " xtkoba+ruby
` (9 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: eregontp @ 2021-04-29 13:27 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by Eregon (Benoit Daloze).
Target version set to 3.1
Assignee set to Eregon (Benoit Daloze)
I made a PR with @xtkoba's patches and additional fixes, as well as enabling undef warnings:
https://github.com/ruby/ruby/pull/4428
@xtkoba Importing patches is quite time-consuming, it would be better if you can already make commits, with a PR or just on a branch next time.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91752
* Author: Eregon (Benoit Daloze)
* Status: Open
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103657] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (11 preceding siblings ...)
2021-04-29 13:27 ` [ruby-core:103656] " eregontp
@ 2021-04-29 13:39 ` xtkoba+ruby
2021-05-04 22:56 ` [ruby-core:103717] " mame
` (8 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-04-29 13:39 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).
user:Eregon Thank you very much. I have just learnt how to use GitHub. I will do it by myself next time.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91753
* Author: Eregon (Benoit Daloze)
* Status: Open
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103717] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (12 preceding siblings ...)
2021-04-29 13:39 ` [ruby-core:103657] " xtkoba+ruby
@ 2021-05-04 22:56 ` mame
2021-05-04 22:58 ` [ruby-core:103718] " mame
` (7 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: mame @ 2021-05-04 22:56 UTC (permalink / raw)
To: ruby-core
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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103718] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (13 preceding siblings ...)
2021-05-04 22:56 ` [ruby-core:103717] " mame
@ 2021-05-04 22:58 ` mame
2021-05-04 23:41 ` [ruby-core:103720] " xtkoba+ruby
` (6 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: mame @ 2021-05-04 22:58 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by mame (Yusuke Endoh).
Maybe [icc 2021.2 x64](http://rubyci.s3.amazonaws.com/icc-x64/ruby-master/log/20210504T190003Z.fail.html.gz) is also broken.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91812
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103720] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (14 preceding siblings ...)
2021-05-04 22:58 ` [ruby-core:103718] " mame
@ 2021-05-04 23:41 ` xtkoba+ruby
2021-05-05 0:57 ` [ruby-core:103721] " eregontp
` (5 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-05-04 23:41 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).
I propose `-Wundef` warnings not be made into errors for the time being.
PR: https://github.com/ruby/ruby/pull/4455
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91814
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103721] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (15 preceding siblings ...)
2021-05-04 23:41 ` [ruby-core:103720] " xtkoba+ruby
@ 2021-05-05 0:57 ` eregontp
2021-05-05 1:20 ` [ruby-core:103723] " xtkoba+ruby
` (4 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: eregontp @ 2021-05-05 0:57 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by Eregon (Benoit Daloze).
I'll take a look tomorrow.
If we need a fix faster, I think it's OK to merge @xtkoba's PR.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91815
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103723] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (16 preceding siblings ...)
2021-05-05 0:57 ` [ruby-core:103721] " eregontp
@ 2021-05-05 1:20 ` xtkoba+ruby
2021-05-05 3:57 ` [ruby-core:103728] " xtkoba+ruby
` (3 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-05-05 1:20 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).
The remaining problems seem due to insufficient simulation of `RBIMPL_HAS_*` in `include/ruby/internal/has/*` for GCC <= 4.x and ICC.
My temporary patch would not be necessary if errors did not manifest themselves one after another.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91817
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103728] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (17 preceding siblings ...)
2021-05-05 1:20 ` [ruby-core:103723] " xtkoba+ruby
@ 2021-05-05 3:57 ` xtkoba+ruby
2021-05-05 4:09 ` [ruby-core:103729] " mame
` (2 subsequent siblings)
21 siblings, 0 replies; 23+ messages in thread
From: xtkoba+ruby @ 2021-05-05 3:57 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by xtkoba (Tee KOBAYASHI).
I missed one more error, for which a new ticket is open now (#17850).
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91822
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103729] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (18 preceding siblings ...)
2021-05-05 3:57 ` [ruby-core:103728] " xtkoba+ruby
@ 2021-05-05 4:09 ` mame
2021-05-05 11:56 ` [ruby-core:103733] " eregontp
2021-05-05 12:38 ` [ruby-core:103737] " mame
21 siblings, 0 replies; 23+ messages in thread
From: mame @ 2021-05-05 4:09 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by mame (Yusuke Endoh).
* @nobu fixed the error on old GCC: 5bde2e61db8148cd5a7974f640aee38be60bf368
* I think I fixed the error on icc (but not confirmed yet): e71c9ca529f1dce2c3816653cd974ce786eea7d8
* @nobu is now creating a patch fo M1 macOS.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91823
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103733] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (19 preceding siblings ...)
2021-05-05 4:09 ` [ruby-core:103729] " mame
@ 2021-05-05 11:56 ` eregontp
2021-05-05 12:38 ` [ruby-core:103737] " mame
21 siblings, 0 replies; 23+ messages in thread
From: eregontp @ 2021-05-05 11:56 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by Eregon (Benoit Daloze).
https://rubyci.org/ looks good now except `macOS Big Sur (ARM)`, thank you @mame, @nobu, @xtkoba for the fixes, and sorry for the breakage (the CI on GitHub passed).
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91828
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
* [ruby-core:103737] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository
2021-03-26 17:04 [ruby-core:103040] [Ruby master Feature#17752] Enable -Wundef for C extensions in repository eregontp
` (20 preceding siblings ...)
2021-05-05 11:56 ` [ruby-core:103733] " eregontp
@ 2021-05-05 12:38 ` mame
21 siblings, 0 replies; 23+ messages in thread
From: mame @ 2021-05-05 12:38 UTC (permalink / raw)
To: ruby-core
Issue #17752 has been updated by mame (Yusuke Endoh).
Status changed from Assigned to Closed
@eregon No worries. This change revealed an actual issue #17850 anyway, great! I think other issues than #17850 are all addressed, so I'm closing this ticket.
----------------------------------------
Feature #17752: Enable -Wundef for C extensions in repository
https://bugs.ruby-lang.org/issues/17752#change-91832
* Author: Eregon (Benoit Daloze)
* Status: Closed
* 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/
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2021-05-05 12:38 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [ruby-core:103262] " xtkoba+ruby
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
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).