Bug #61598
closedgcc-14: FTBFS "error: call to non-'constexpr' function 'virtual unsigned int DoutPrefixProvider::get_subsys() const'"
0%
Description
gcc 14 has introduced a change which results in ceph build failures:
[ 270s] /home/abuild/rpmbuild/BUILD/ceph-18.0.0-4135-g87cd54281c8/src/osd/osd_types.h: In lambda function: [ 270s] /home/abuild/rpmbuild/BUILD/ceph-18.0.0-4135-g87cd54281c8/src/common/dout.h:184:73: error: call to non-'constexpr' function 'virtual unsigned int DoutPrefixProvider::get_subsys() const' [ 270s] 184 | dout_impl(pdpp->get_cct(), ceph::dout::need_dynamic(pdpp->get_subsys()), v) \ [ 270s] | ~~~~~~~~~~~~~~~~^~ [ 270s] /home/abuild/rpmbuild/BUILD/ceph-18.0.0-4135-g87cd54281c8/src/common/dout.h:155:58: note: in definition of macro 'dout_impl' [ 270s] 155 | return (cctX->_conf->subsys.template should_gather<sub, v>()); \ [ 270s] | ^~~ [ 270s] /home/abuild/rpmbuild/BUILD/ceph-18.0.0-4135-g87cd54281c8/src/osd/osd_types.h:3618:3: note: in expansion of macro 'ldpp_dout' [ 270s] 3618 | ldpp_dout(dpp, 10) << "build_prior all_probe " << all_probe << dendl; [ 270s] | ^~~~~~~~~ [ 270s] /home/abuild/rpmbuild/BUILD/ceph-18.0.0-4135-g87cd54281c8/src/common/dout.h:51:20: note: 'virtual unsigned int DoutPrefixProvider::get_subsys() const' declared here [ 270s] 51 | virtual unsigned get_subsys() const = 0; [ 270s] | ^~~~~~~~~~
The gcc change is described at https://gcc.gnu.org/pipermail/gcc-patches/2023-May/617196.html.
The ceph FTBFS was mentioned in a followup post at https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618384.html, and apparently this failure is now expected, as DoutPrefixProvider::get_subsys()
isn't declared constexpr
but really should be.
I tried to fix this experimentally by simply declaring constexpr get_subsys()
, e.g.:
diff --git a/src/common/dout.h b/src/common/dout.h index a1375fbb910..6e91750708a 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -61,7 +61,7 @@ class NoDoutPrefix : public DoutPrefixProvider { std::ostream& gen_prefix(std::ostream& out) const override { return out; } CephContext *get_cct() const override { return cct; } - unsigned get_subsys() const override { return subsys; } + constexpr unsigned get_subsys() const override { return subsys; } }; // a prefix provider with static (const char*) prefix @@ -88,7 +88,7 @@ class DoutPrefixPipe : public DoutPrefixProvider { return out; } CephContext *get_cct() const override { return dpp.get_cct(); } - unsigned get_subsys() const override { return dpp.get_subsys(); } + constexpr unsigned get_subsys() const override { return dpp.get_subsys(); } virtual void add_prefix(std::ostream& out) const = 0; };
...but that has some problems:
1) Instead of an outright build failure, I get warning: virtual functions cannot be 'constexpr' before C++20 [-Winvalid-constexpr]
. I imaging this is undesirable.
2) Even if 1 is desirable, there's plenty of other subclasses of DoutPrefixProvider
which would all also need to have their get_subsys()
methods declared conxtexpr
for the build to complete.
TBH the whole dout
thing is black magic to me, so I could really use some assistance with how best to fix this.
Updated by Tim Serong 25 days ago
- Is duplicate of Bug #64050: FTBFS on fedora rawhide(f40) with gcc-14 added