Bug 2336567 - dnf5 failed to build with GCC 15 (" #warning "<cstdbool> is deprecated in C++17, remove the #include" [-Werror=cpp]" via ruby.h)
Summary: dnf5 failed to build with GCC 15 (" #warning "<cstdbool> is deprecated in C++...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: ruby
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Jarek Prokop
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: gcc-15-mass-prebuild 2340083
TreeView+ depends on / blocked
 
Reported: 2025-01-09 15:46 UTC by Dave Malcolm
Modified: 2025-01-27 14:21 UTC (History)
12 users (show)

Fixed In Version: ruby-3.4.1-22.fc42
Clone Of:
Environment:
Last Closed: 2025-01-27 12:05:20 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Pagure 203 0 None None None 2025-01-24 17:24:52 UTC
Github ruby ruby pull 12628 0 None open Backport [Bug #21024] <cstdbool> header has been useless 2025-01-24 17:24:52 UTC
Ruby 21024 0 None None None 2025-01-10 17:04:26 UTC

Description Dave Malcolm 2025-01-09 15:46:46 UTC
I'm experimentally rebuilding rawhide with the not-yet-released GCC 15 to see if anything breaks, and to help write the porting guide.  See https://fedoraproject.org/wiki/User:Dmalcolm/gcc-15

My test build with GCC 15 failed:
https://copr.fedorainfracloud.org/coprs/dmalcolm/gcc-15-smoketest-3.failed/build/8476268/

whereas my test build with GCC 14 succeeded:
https://copr.fedorainfracloud.org/coprs/dmalcolm/gcc-15-smoketest-3.failed.checker/build/8478297/

Looking at the failure logs e.g.
https://download.copr.fedorainfracloud.org/results/dmalcolm/gcc-15-smoketest-3.failed/fedora-rawhide-x86_64/08476268-dnf5/builder-live.log.gz

I see:

In file included from /usr/include/ruby/internal/stdbool.h:31,
                 from /usr/include/ruby/backward/2/bool.h:22,
                 from /usr/include/ruby/defines.h:74,
                 from /usr/include/ruby/ruby.h:25,
                 from /usr/include/ruby.h:38,
                 from /builddir/build/BUILD/dnf5-5.2.8.1-build/dnf5-5.2.8.1/redhat-linux-build/bindings/ruby/libdnf5/CMakeFiles/ruby_advisory.dir/advisoryRUBY_wrap.cxx:912:
/usr/include/c++/15/cstdbool:48:6: error: #warning "<cstdbool> is deprecated in C++17, remove the #include" [-Werror=cpp]
   48 | #    warning "<cstdbool> is deprecated in C++17, remove the #include"
      |      ^~~~~~~



Reproducible: Didn't try

Comment 1 Dave Malcolm 2025-01-09 15:48:32 UTC
Looks like anything that includes ruby.h will get this warning; I wonder if it's new with GCC 15?

Jonathan: did something change in the C++ stdlib that might have triggered this as a new warning?

Comment 2 Jonathan Wakely 2025-01-09 16:00:43 UTC
Yes, it's new in GCC 15.

<cstdbool> is the C++-only version of C <stdbool.h> which is completely pointless in C++ because bool/true/false are always defined as keywords in C++. Including <cstdbool> in C++ code is useless and should be removed from any code silly enough to do it.

Comment 3 Jonathan Wakely 2025-01-09 16:06:04 UTC
https://github.com/ruby/ruby/blob/5fab31b15e32622c4b71d1d347a41937e9f9c212/include/ruby/internal/stdbool.h#L28-L32

This is just silly. It should just include <stdbool.h> and be done with it. Or remove this entire file and stop trying to bodge stdbool for pre-C99 systems.

Comment 4 Jonathan Wakely 2025-01-09 16:07:59 UTC
dnf5 builds with -Werror which is the work of the devil. The package maintainers should remove that, or deal with failures like this themselves.

Comment 5 Petr Pisar 2025-01-10 15:31:35 UTC
# rpm -qf /usr/include/ruby/internal/stdbool.h
ruby-devel-3.4.1-19.fc42.x86_64

Moving to ruby component to remove the pointless and deprecated inclusion of <cstdbool>.

Comment 6 Jarek Prokop 2025-01-10 17:04:26 UTC
To reproduce currently
Required packages: ruby-devel g++ >= 15.0.0

I couldn't find g++ 15 anywhere reasonably, so I just borrowed the repo used in the copr and in a Fedora Rawhide container executed:
~~~
# echo "[gcc_15]
name=pre-release GCC 15 Repo
baseurl=https://fedorapeople.org/~dmalcolm/gcc/gcc-15-mass-prebuild/$basearch
type=rpm-md
skip_if_unavailable=True
gpgcheck=0
repo_gpgcheck=0
enabled=1
enabled_metadata=1" > /etc/yum.repos.d/gcc_15.repo
~~~

With the repo added
~~~
# dnf install --assumeyes g++ ruby-devel
~~~

Minimal file required to trigger this:
~~~
$ cat main.cpp
#include <ruby.h>

int main(void) {
	return 0;
}
~~~

Then just compile it to get the warning with GCC 15 installed:
~~~
# g++ main.cpp
In file included from /usr/include/ruby/internal/stdbool.h:30,
                 from /usr/include/ruby/backward/2/bool.h:22,
                 from /usr/include/ruby/defines.h:74,
                 from /usr/include/ruby/ruby.h:25,
                 from /usr/include/ruby.h:38,
                 from reproducer.cpp:1:
/usr/include/c++/15/cstdbool:48:6: warning: #warning "<cstdbool> is deprecated in C++17, remove the #include" [-Wcpp]
   48 | #    warning "<cstdbool> is deprecated in C++17, remove the #include"
      |      ^~~~~~~
~~~
You can also add `-Werror` to fail the compilation intentionally when the warning is present and receive a non-zero status in that case.

Comment 7 Jun Aruga 2025-01-13 13:34:19 UTC
Jarek reported this issue on the upstream Ruby on the Ruby bug ticket.[1]
Then it seems it was fixed on the upstream Ruby master branch by this commit.[2]
Thanks!

[1] https://bugs.ruby-lang.org/issues/21024
[2] https://github.com/ruby/ruby/commit/1b3037081ef9fc121b83e213d997a069acd5904b

Comment 8 Jonathan Wakely 2025-01-13 14:32:57 UTC
(In reply to Jun Aruga from comment #7)
> Jarek reported this issue on the upstream Ruby on the Ruby bug ticket.[1]
> Then it seems it was fixed on the upstream Ruby master branch by this
> commit.[2]

That's great, thanks.

> Thanks!
> 
> [1] https://bugs.ruby-lang.org/issues/21024

A comment there says "That patch will break C++-11 and C++-14." -- how? I think that's wrong, so I commented on the PR.

Comment 9 Jun Aruga 2025-01-13 17:24:38 UTC
> A comment there says "That patch will break C++-11 and C++-14." -- how? I
> think that's wrong, so I commented on the PR.

As I commented as the upstream PR [1],I think the "That patch" in the comment doesn't mean the upstream PR, but means the `0001-Stop-including-cstdbool-in-include-ruby-internal-std.patch` attached by Jarek on the above Ruby bug ticket. The patch file is deleting the part of the `include <cstdbool>`. So, the "That patch (0001-Stop-including-cstdbool-in-include-ruby-internal-std.patch file) will break C++-11 and C++-14." means sense to me.

[1] https://github.com/ruby/ruby/pull/12551/commits/1b3037081ef9fc121b83e213d997a069acd5904b#r1913540808

Comment 10 Jonathan Wakely 2025-01-13 20:04:26 UTC
No, it doesn't make sense. #include <cstdbool> is useless in all versions of C++, so the include can be removed for all versions. It won't break anything.

Comment 11 Jarek Prokop 2025-01-24 17:24:52 UTC
I'd say removing it in previous Ruby versions is a nice-to-have, but I took the liberty to request/do backport upstream for Ruby 3.4 and port the patch downstream to Fedora Rawhide where GCC is now version 15.
I might have selfish motivation of wanting to have all-green CI on my libdnf5 github PR :).

Comment 12 Fedora Update System 2025-01-27 12:02:26 UTC
FEDORA-2025-2d1d8ca6d0 (ruby-3.4.1-22.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-2d1d8ca6d0

Comment 13 Fedora Update System 2025-01-27 12:05:20 UTC
FEDORA-2025-2d1d8ca6d0 (ruby-3.4.1-22.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 14 Petr Pisar 2025-01-27 14:21:02 UTC
Thanks. I confirm it fixes the problem for DNF5.


Note You need to log in before you can comment on or make changes to this bug.