Project

General

Profile

Actions

Bug #21340

open

Bump autoconf version to properly handle C23 bool/stdbool defines

Added by christo (Chris Alberti) 1 day ago. Updated about 18 hours ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
3.4.3, 3.5.0, any built with GCC 15 (so C23)
[ruby-core:122101]

Description

Right now if I install a recent release using rbenv or asdf, or manually download the latest release 3.4.3 or the preview 3.5.0, the included ./configure seems to have been generated by an old version of autoconf. After running ./configure, I end up with a config.h containing HAVE__BOOL = 1, but not containing HAVE_STD_BOOL_H = 1.

If I grab the source from github (latest, or 3.4.3 tag) and run autoconf myself (I'm currently on 2.72), I get a config.h with both HAVE__BOOL = 1 and HAVE_STD_BOOL_H = 1 defined.

This ends up meaning that in the official releases, Ruby's internal/stdbool.h skips using <stdbool.h> and moves on to defining bool/true/false itself.

This is not valid as of C23 (which is now default in GCC 15). On my end I found this because I was seeing build failures in the geoip2_compat gem related to issues with the bool type definition on GCC 15. I submitted a patch to the gem's repo for a workaround (include <stdbool.h> before ruby.h), but this might come back to bite other native extension gem compiles as well.

It looks like autoconf was patched to fix the HAVE_STD_BOOL_H define for C23 in this commit.

I can tell that the ./configure included in the official ruby releases was created with an older version of autoconf because I still see the line:

Check for stdbool.h that conforms to C99

rather than the updated version (which appears in my ./configure created with autoconf 2.72)

Check for stdbool.h that conforms to C99 or later

I'd happily submit a PR if the setup around packaging the official releases is public and someone can point me to it! I wasn't able to find it on a quick search.


Files

config.h_GCC14 (14.7 KB) config.h_GCC14 From the 3.4.3 stable release tar.gz, built with GCC 14 christo (Chris Alberti), 05/15/2025 01:32 PM
config.h_GCC15 (14.7 KB) config.h_GCC15 From the 3.4.3 stable release tar.gz, built with GCC 15 christo (Chris Alberti), 05/15/2025 01:44 PM

Updated by nobu (Nobuyoshi Nakada) 1 day ago

  • Status changed from Open to Feedback

Isn't HAVE_STDBOOL_H defined?
HAVE_STD_BOOL_H should be for std_bool.h.

Updated by christo (Chris Alberti) about 20 hours ago

nobu (Nobuyoshi Nakada) wrote in #note-1:

Isn't HAVE_STDBOOL_H defined?
HAVE_STD_BOOL_H should be for std_bool.h.

Not if you build on GCC 15 (or C23) using the ./configure script packaged with the official ruby release tar.gz.

GCC 15 bumps the default C standard to gnu23 which is where the issue is introduced. The problem is that the test in Ruby's old ./configure is broken on C23 because of the new native definitions of bool/true/false. Read the autoconf commit I linked for context. They fixed this in 2022.

If you run the included ./configure with GCC 14 or lower, or with GCC 15 with -std=gnu17 or lower, you get a config.h which does define HAVE_STDBOOL_H.

If you run the included ./configure with GCC 15 or a lower version with -std=gnu23, you get a config.h which does not define HAVE_STDBOOL_H.

If you use the latest autoconf (2.72 on my system) to recreate the ./configure script, then run that new ./configure on GCC15 (or -std=gnu23), you get a config.h which does correctly define HAVE_STDBOOL_H.

Please reopen this... Should be a pretty easy win.

Updated by alanwu (Alan Wu) about 18 hours ago ยท Edited

  • Status changed from Feedback to Open

We see this on CI that uses Ubuntu 24.04, since it uses autoconf 2.71 like the environment that makes the release tarballs.

https://github.com/ruby/ruby/actions/runs/15047656643/job/42294231514#step:8:159

checking for stdbool.h that conforms to C99... no

(OP had a typo in the macro name)

I'd happily submit a PR if the setup around packaging the official releases is public and someone can point me to it! I wasn't able to find it on a quick search.

I think it's here:

If we want 2.72, we can't get it from Ubuntu for now.

This might also be the cause for #21290.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0