Project

General

Profile

Actions

Bug #17809

closed

Ruby 2.6.7 backported C99 code that breaks older compilers

Added by tas50 (Tim Smith) 30 days ago. Updated 26 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:103490]

Description

Hey folks,

It looks like the 2.6.7 release inadvertently backported some C99 code from HEAD onto the Ruby 2.6 branch that shouldn't be requiring C99 compilers. This is causing us some pain and failures in our older versions of Chef that use Ruby 2.6 and are built without the C99 flag set on compilers.

Here's the patch we apply the 2.6.7 codebase to remove the C99 code:
https://github.com/chef/omnibus-software/blob/master/config/patches/ruby/ruby-2.6.7_c99.patch

Here's the commit that backported the C99 code:
https://github.com/ruby/ruby/commit/fe85a3d5271c4e3aeda42ec32e9c3f9ee02b6897

The particular line in the commit causing failures:
https://github.com/ruby/ruby/blob/fe85a3d5271c4e3aeda42ec32e9c3f9ee02b6897/hash.c#L5661

The failure we see while compiling:

gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

compiling hash.c
compiling load.c
compiling marshal.c

Error:

    hash.c: In function 'keylist_delete':
hash.c:5661: error: 'for' loop initial declarations are only allowed in C99 mode
hash.c:5661: note: use option -std=c99 or -std=gnu99 to compile your code
gmake: *** [Makefile:419: hash.o] Error 1
gmake: *** Waiting for unfinished jobs....`

Updated by nobu (Nobuyoshi Nakada) 28 days ago

  • Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN to 2.6: REQUIRED, 2.7: REQUIRED, 3.0: DONTNEED

Is this only?

diff --git a/hash.c b/hash.c
index 63b228f501e..f6555a09dd4 100644
--- a/hash.c
+++ b/hash.c
@@ -6115,10 +6115,10 @@ env_invert(VALUE _)
 static void
 keylist_delete(VALUE keys, VALUE key)
 {
-    long keylen, elen;
+    long keylen, elen, i;
     const char *keyptr, *eptr;
     RSTRING_GETMEM(key, keyptr, keylen);
-    for (long i=0; i<RARRAY_LEN(keys); i++) {
+    for (i=0; i<RARRAY_LEN(keys); i++) {
         VALUE e = RARRAY_AREF(keys, i);
         RSTRING_GETMEM(e, eptr, elen);
         if (elen != keylen) continue;

Updated by jeremyevans0 (Jeremy Evans) 26 days ago

  • Backport changed from 2.6: REQUIRED, 2.7: REQUIRED, 3.0: DONTNEED to 2.6: REQUIRED, 2.7: DONTNEED, 3.0: DONTNEED
  • Status changed from Open to Closed

I think this is only required for 2.6, since we switched to C99 before 2.7, so I've updated the backport field.

Actions

Also available in: Atom PDF