Page MenuHomeFreeBSD

src: Use c++17 as the default C++ standard
AcceptedPublic

Authored by jhb on Mon, Mar 3, 9:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 4, 8:06 AM
Unknown Object (File)
Tue, Mar 4, 7:42 AM
Unknown Object (File)
Tue, Mar 4, 3:46 AM
Subscribers

Details

Summary

Previously the compiler's default C++ standard was used unlike C where
bsd.sys.mk explicitly sets a default language version. Setting an
explicit default version will give a more uniform experience across
different compilers and compiler versions.

c++17 was chosen to match the default C standard. It is well
supported by a wide range of clang (5+) and GCC (9+) versions.

C++17 is also the default C++ standard in recent versions of clang
(16+) and GCC (11+). As a result, many of the explicit CXXSTD
settings in Makefiles had the effect of lowering the C++ standard
instead of raising it as was originally intended and are removed.

Note that the remaining explicit CXXSTD settings for atf and liblutok
explicitly lower the standard to C++11 due to use of the deprecated
auto_ptr<> template which is removed in later versions.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 62747
Build 59631: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Mon, Mar 3, 9:50 PM

This passes most of make tinderbox (it is finishing the last few arches for me still). It will need an exp-run as well.

This LGTM. C++20 would be nicer, because it would simplify one thing in the fusefs tests, but that would require a whole new tinderbox run.

This revision is now accepted and ready to land.Mon, Mar 3, 9:54 PM

My gut feeling is that C++ 20 is too new still, but we may want to more clearly define what "too new" means. GDB's standard is something like "what is the max C++ version supported by the newest compiler that can be installed on the oldest supported Linux LTS" or some such, and GDB is currently at C++17.

share/mk/bsd.sys.mk
25

Possibly worth noting: I think both GCC and clang actually default to gnu++17, but I'm not aware of any GNU-isms that we depend on (we have a small C++ corpus in base anyway), and I think it might be beneficial if we can stick to "standard" C++ in base.

My gut feeling is that C++ 20 is too new still, but we may want to more clearly define what "too new" means.

Probably, yeah. I'd be fine with "some tests aren't available if your compiler doesn't support C++20."