Project

General

Profile

Actions

Bug #21340

closed

Bump autoconf version to properly handle C23 bool/stdbool defines

Added by christo (Chris Alberti) 9 days ago. Updated about 7 hours ago.

Status:
Closed
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) 9 days 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) 9 days 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) 9 days 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.

Updated by ntkme (Natsuki Natsume) 7 days ago · Edited

google-protobuf is also failing to compile native extension on windows ruby head and 3.4.4 with msys2 gcc 15.

In file included from
D:/rubyinstaller-head-x64/include/ruby-3.5.0+1/ruby/defines.h:74,
from
D:/rubyinstaller-head-x64/include/ruby-3.5.0+1/ruby/ruby.h:25,
                 from D:/rubyinstaller-head-x64/include/ruby-3.5.0+1/ruby.h:38,
                 from protobuf.h:13,
                 from protobuf.c:8:
D:/a/_temp/msys64/ucrt64/include/stralign.h: In function 'ua_CharUpperW':
D:/rubyinstaller-head-x64/include/ruby-3.5.0+1/ruby/backward/2/bool.h:31:15:
error: 'true' undeclared (first use in this function)
   31 | # define TRUE true
      |               ^~~~

Opened https://github.com/oneclick/rubyinstaller2/issues/439

Updated by alanwu (Alan Wu) 3 days ago

I've pushed 2297afda7ff3926c51fea700dfbf0f0eb4fea1e5 which I think should resolve build issues without touching the autoconf version.

@ntkme @christo if you have time, please try building with the latest master branch and see if the build issues are resolved. We can get this backported if so.

Updated by christo (Chris Alberti) 3 days ago

alanwu (Alan Wu) wrote in #note-5:

@ntkme @christo if you have time, please try building with the latest master branch and see if the build issues are resolved. We can get this backported if so.

I can confirm this fixes the issue I reported, even when using the configure script from the current stable release.

I tested using the 3.4.4 stable release tarball. Built that as-is with GCC 15.1.0 and tried gem install geoip2_compat which failed with the same errors. Then I patched over the modified stdbool.h with @alanwu's changes from master, rebuilt ruby, and retried gem install geoip2_compat now with no errors.

Thanks for looking into this!

Updated by alanwu (Alan Wu) 1 day ago

  • Status changed from Open to Closed
  • Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.2: WONTFIX, 3.3: REQUIRED, 3.4: REQUIRED

Thanks!

2297afda7ff3926c51fea700dfbf0f0eb4fea1e5 should also work for the 3.3 branch since it also requires VC 2015. #19982

Updated by ntkme (Natsuki Natsume) about 7 hours ago

@alanwu (Alan Wu) I'd like to request 3.2 backport as other GCC 15 fixes have been back ported e.g. https://bugs.ruby-lang.org/issues/21286

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like1Like0Like0Like0