[#106355] [Ruby master Bug#18373] RBS build failure: '/include/x86_64-linux/ruby/config.h', needed by 'constants.o'. — "vo.x (Vit Ondruch)" <noreply@...>
Issue #18373 has been reported by vo.x (Vit Ondruch).
28 messages
2021/12/01
[ruby-core:106494] [Ruby master Bug#18387] Backport of fix for #16798 to Ruby 2.6 introduced C99 syntax
From:
"usa (Usaku NAKAMURA)" <noreply@...>
Date:
2021-12-05 17:17:39 UTC
List:
ruby-core #106494
Issue #18387 has been updated by usa (Usaku NAKAMURA).
it's unintentionally, so I'll fix it later. thx!
----------------------------------------
Bug #18387: Backport of fix for #16798 to Ruby 2.6 introduced C99 syntax
https://bugs.ruby-lang.org/issues/18387#change-95150
* Author: jeremyevans0 (Jeremy Evans)
* Status: Closed
* Priority: Normal
* Assignee: usa (Usaku NAKAMURA)
* Backport: 2.6: REQUIRED, 2.7: DONTNEED, 3.0: DONTNEED
----------------------------------------
Building Ruby 2.6.9 on OpenBSD/sparc64 fails with the following error:
```
cc -O2 -pipe -fPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -DCANONICALIZATION_FOR_MATHN -DOPENSSL_NO_STATIC_ENGINE -I/usr/local/include -I. -I.ext/include/sparc64-openbsd -I./include -I. -I./enc/unicode/12.1.0 -o hash.o -c hash.c
hash.c: In function 'keylist_delete':
hash.c:5661: error: 'for' loop initial declaration used outside C99 mode
```
The system compiler in this case is gcc 4.2.1, which defaults to C89/C90. I believe Ruby didn't switch to C99 until Ruby 2.7, so I think this is a bug that should be fixed in the next release of Ruby 2.6.
This issue was introduced by commit:fe85a3d5271c4e3aeda42ec32e9c3f9ee02b6897, a backport of commit:08529a61153e5c40f57a65272211357511d6e6db.
This patch should hopefully fix it (untested):
```diff
diff --git a/hash.c b/hash.c
index 38440f4b96..65a0419af3 100644
--- a/hash.c
+++ b/hash.c
@@ -5655,10 +5655,10 @@ env_invert(void)
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;
```
I'm not sure if this is the only C99 issue introduced in Ruby 2.6.9, so other changes between 2.6.8 and 2.6.9 should be audited to ensure they do not introduce C99 syntax.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>