aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/cxx')
-rw-r--r--libbuild2/cxx/init.cxx51
1 files changed, 33 insertions, 18 deletions
diff --git a/libbuild2/cxx/init.cxx b/libbuild2/cxx/init.cxx
index 8159d18..3185eaa 100644
--- a/libbuild2/cxx/init.cxx
+++ b/libbuild2/cxx/init.cxx
@@ -335,7 +335,12 @@ namespace build2
{
case compiler_type::gcc:
{
- if (mj >= 11)
+ if (mj >= 14)
+ {
+ o = "-std=c++26";
+ cplusplus = 202400;
+ }
+ else if (mj >= 11)
{
o = "-std=c++23";
cplusplus = 202302;
@@ -367,25 +372,29 @@ namespace build2
}
case compiler_type::clang:
{
- // Clang 10.0.0 targeting MSVC 16.4 and 16.5 (preview) in the
- // c++2a mode uncovers some Concepts-related bugs in MSVC STL
- // (LLVM bug #44956). So in this case we map `latest` to
- // c++17.
- //
- // While reportedly this has been fixed in the later versions
- // of MSVC, instead of somehow passing the version of MSVC
- // Clang is targeting, we will just assume that Clang 11
- // and later are used with a sufficiently new version of
- // MSVC.
- //
-
- if (mj >= 13)
+ if (mj >= 18)
+ {
+ o = "-std=c++26";
+ cplusplus = 202400;
+ }
+ else if (mj >= 13)
{
o = "-std=c++2b";
cplusplus = 202302;
}
else if (mj == 10 && latest && tt.system == "win32-msvc")
{
+ // Clang 10.0.0 targeting MSVC 16.4 and 16.5 (preview) in
+ // the c++2a mode uncovers some Concepts-related bugs in
+ // MSVC STL (LLVM bug #44956). So in this case we map
+ // `latest` to c++17.
+ //
+ // While reportedly this has been fixed in the later
+ // versions of MSVC, instead of somehow passing the version
+ // of MSVC Clang is targeting, we will just assume that
+ // Clang 11 and later are used with a sufficiently new
+ // version of MSVC.
+ //
o = "-std=c++17";
cplusplus = 201703;
}
@@ -446,7 +455,7 @@ namespace build2
// 26 to 2c for compatibility with older versions of the
// compilers.
//
- // @@ TMP: update C++26 __cplusplus value once known.
+ // @@ TMP: update C++26 __cplusplus value once known (and above).
//
o = "-std=";
@@ -481,6 +490,12 @@ namespace build2
{
case compiler_type::msvc:
{
+ // Let's enable the new preprocessor in this mode. For background,
+ // see MSVC issue 10537317.
+ //
+ if (mj > 19 || (mj == 19 && mi >= 39))
+ prepend ("/Zc:preprocessor");
+
// Starting with 15.5 (19.12) Visual Studio-created projects
// default to the strict mode. However, this flag currently tends
// to trigger too many compiler bugs. So for now we leave it to
@@ -498,8 +513,8 @@ namespace build2
// Unless disabled by the user, try to enable C++ modules.
//
- // NOTE: see also diagnostics about modules support required in compile
- // rule.
+ // NOTE: see also diagnostics about modules support required (if
+ // attempting to use) in compile rule.
//
if (!modules.value || *modules.value)
{
@@ -580,7 +595,7 @@ namespace build2
// around Clang 16 so we don't support anything earlier than
// that (it's not practically usable anyway).
//
- // Clang enable modules by default in c++20 or later but they
+ // Clang enables modules by default in c++20 or later but they
// don't yet (as of Clang 18) define __cpp_modules. When they
// do, we can consider enabling modules by default on our side.
// For now, we only enable modules if forced with explicit