Project

General

Profile

Actions

Bug #21519

closed

`configure` script in Ruby tarballs should be generated with autoconf 2.72+ for C23 compilers

Added by stanhu (Stan Hu) 2 days ago. Updated 2 days ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:122844]

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:

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:

test-bool.txt

It seems that this test is outdated. It needs this autoconf fix for C23:

https://cgit.git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6dcecb780a69bd208088d666b299e92aa7ae7e80.

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.

Actions #2

Updated by stanhu (Stan Hu) 2 days ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0