aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstrap-mingw.bat3
-rwxr-xr-xbootstrap.sh3
-rw-r--r--build/root.build2
-rw-r--r--build2/cxx/init.cxx48
4 files changed, 50 insertions, 6 deletions
diff --git a/bootstrap-mingw.bat b/bootstrap-mingw.bat
index 28c7edd..c95d534 100644
--- a/bootstrap-mingw.bat
+++ b/bootstrap-mingw.bat
@@ -76,6 +76,9 @@ set "src=%src% %libbutl%\butl\*.cxx"
rem Get the compile options.
rem
+rem Note that for as long as we support GCC 4.9 we have to compile in the
+rem C++14 mode since 4.9 doesn't recognize c++1z.
+rem
set "ops=-std=c++1y"
:ops_next
shift
diff --git a/bootstrap.sh b/bootstrap.sh
index 3496a1f..54cc9f2 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -130,5 +130,8 @@ src="$src build2/install/*.cxx"
src="$src build2/pkgconfig/*.cxx"
src="$src $libbutl/butl/*.cxx"
+# Note that for as long as we support GCC 4.9 we have to compile in the C++14
+# mode since 4.9 doesn't recognize c++1z.
+#
set -x
"$cxx" "-I$libbutl" -I. '-DBUILD2_HOST_TRIPLET="'"$host"'"' -std=c++1y "$@" -o build2/b-boot $src -lpthread
diff --git a/build/root.build b/build/root.build
index 1d79e22..517da8b 100644
--- a/build/root.build
+++ b/build/root.build
@@ -2,7 +2,7 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-cxx.std = 14
+cxx.std = latest
using cxx
diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx
index 61b2c3c..e5641be 100644
--- a/build2/cxx/init.cxx
+++ b/build2/cxx/init.cxx
@@ -42,7 +42,49 @@ namespace build2
{
string r;
- if (ci.id.type == "msvc")
+ const string& t (ci.id.type);
+ uint64_t mj (ci.version.major);
+ uint64_t mi (ci.version.minor);
+ uint64_t p (ci.version.patch);
+
+ // Translate "latest" to the compiler/version-appropriate option.
+ //
+ if (v == "latest")
+ {
+ if (t == "msvc")
+ {
+ // VC14u3 and later has /std:c++latest.
+ //
+ if (mj > 19 || (mj == 19 && (mi > 0 || (mi == 0 && p >= 24215))))
+ r = "/std:c++latest";
+ }
+ else if (t == "gcc")
+ {
+ if (mj >= 5) r = "-std=c++1z"; // 17
+ else if (mj == 4 && mi >= 8) r = "-std=c++1y"; // 14
+ else if (mj == 4 && mi >= 4) r = "-std=c++0x"; // 11
+ }
+ else if (t == "clang")
+ {
+ if (mj > 3 || (mj == 3 && mi >= 5)) r = "-std=c++1z"; // 17
+ else if (mj == 3 && mi >= 4) r = "-std=c++1y"; // 14
+ else /* ??? */ r = "-std=c++0x"; // 11
+ }
+ else if (t == "icc")
+ {
+ if (mj >= 17) r = "-std=c++1z"; // 17
+ else if (mj > 15 || (mj == 15 && p >= 3)) r = "-std=c++1y"; // 14
+ else /* ??? */ r = "-std=c++0x"; // 11
+ }
+ else
+ assert (false);
+
+ return r;
+ }
+
+ // Otherwise translate the standard value.
+ //
+ if (t == "msvc")
{
// C++ standard-wise, with VC you got what you got up until 14u2.
// Starting with 14u3 there is now the /std: switch which defaults
@@ -59,10 +101,6 @@ namespace build2
//
if (v != "98" && v != "03")
{
- uint64_t mj (ci.version.major);
- uint64_t mi (ci.version.minor);
- uint64_t p (ci.version.patch);
-
bool sup (false);
if (v == "11") // C++11 since VS2010/10.0.