diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-02-23 17:43:15 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-02-23 21:13:29 +0100 |
commit | 214d852ffd864b75564643b49b2c960d469be3ed (patch) | |
tree | ce4c04601edc36291e16f0dc7b6dd12dfcad67ac /SConstruct | |
parent | a920f9727a29c854dcc7f193f691f02aad15d94d (diff) |
SCons: Add GCC/Clang minimum version check
Prevent using GCC 8 as it does not properly support C++17's
guaranteed copy elision which we now need.
(Upstream bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521)
Follow-up to #36457 and #36436.
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct index e20499a756..08a87dbe6c 100644 --- a/SConstruct +++ b/SConstruct @@ -332,6 +332,36 @@ if selected_platform in platform_list: # We apply it to CCFLAGS (both C and C++ code) in case it impacts C features. env.Prepend(CCFLAGS=['/std:c++17', '/permissive-']) + # Enforce our minimal compiler version requirements + version = methods.get_compiler_version(env) + major = int(version[0]) if version is not None else -1 + if methods.using_gcc(env): + # GCC 8 has a regression in the support of guaranteed copy elision + # which causes a build failure: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521 + if major == 8: + print("Detected GCC version 8, which is not supported due to a regression " + "in its C++17 guaranteed copy elision support. Use a newer GCC " + "version, or Clang 6 or later by passing \"use_llvm=yes\" to the " + "SCons command line.") + sys.exit(255) + elif major < 7: + print("Detected GCC version older than 7, which does not fully support " + "C++17. Supported versions are GCC 7, 9 and later. Use a newer GCC " + "version, or Clang 6 or later by passing \"use_llvm=yes\" to the " + "SCons command line.") + sys.exit(255) + elif methods.using_clang(env): + # Apple LLVM versions differ from upstream LLVM version \o/, compare + # in https://en.wikipedia.org/wiki/Xcode#Toolchain_versions + if (env["platform"] == "osx" or env["platform"] == "iphone") and major < 10: + print("Detected Apple Clang version older than 10, which does not fully " + "support C++17. Supported versions are Apple Clang 10 and later.") + sys.exit(255) + elif major < 6: + print("Detected Clang version older than 6, which does not fully support " + "C++17. Supported versions are Clang 6 and later.") + sys.exit(255) + # Configure compiler warnings if env.msvc: # Truncations, narrowing conversions, signed/unsigned comparisons... |