Bug #21519
closed`configure` script in Ruby tarballs should be generated with autoconf 2.72+ for C23 compilers
Description
The autoconf
used to generate configure
in the Ruby source downloads needs to be updated from 2.71 to 2.72 to fix compatibility with C23 compilers, such as GCC 15.
This is related to https://bugs.ruby-lang.org/issues/21024, but this is focused on C, not C++, compilation.
This is also related to gem compilation issues, such as:
- https://github.com/socketry/io-event/issues/136
- https://jira.mongodb.org/browse/RUBY-3675
- https://github.com/cabo/cbor-ruby/issues/27
These gems worked around the problem by using append_cflags
instead of CFLAGS
. That fixes the problem because -std=c99
is omitted entirely, even for gcc
.
However, this masks the problem that for GCC 15, the Ruby headers should include <stdbool.h>
. If a gem really needed to use an older C version, append_cflags
would always throw it out in GCC 15 because bool
is not defined without including that header.
As mentioned in https://gcc.gnu.org/gcc-15/porting_to.html#c23, GCC 15 defaults to C23 now:
In C99 and later you can use #include <stdbool.h> which provides definitions of bool, true, and false compatible with C23.
The configure
script checks whether stdbool.h
is available and defines HAVE_STDBOOL_H
if it is. However, if I install ruby 3.4.4
via mise
with the Docker image fedora:42
, I see this in the build logs:
configure:13530: checking for stdbool.h that conforms to C99
configure:13646: gcc -c -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -O3 -fno-fast-math -ggdb3 conftest.c >&5
conftest.c:103:17: error: #error "bool is not defined"
103 | #error "bool is not defined"
| ^~~~~
conftest.c:106:17: error: #error "false is not defined"
106 | #error "false is not defined"
| ^~~~~
conftest.c:109:17: error: #error "true is not defined"
109 | #error "true is not defined"
| ^~~~~
configure:13646: $? = 1
Attached is the test program used by configure
:
It seems that this test is outdated. It needs this autoconf
fix for C23:
If I install autoconf
and run this:
autoreconf -fiv
./configure
Then it works:
checking for stdbool.h that conforms to C99 or later... yes
If we peek at https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz
:
# curl -O https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz
# tar xzf ruby-3.4.4.tar.gz
# head -3 ruby-3.4.4/configure
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.71.
I believe autoconf
needs to be updated to 2.72.
Updated by stanhu (Stan Hu) 2 days ago
Oh, this is a duplicate of https://bugs.ruby-lang.org/issues/21340.