Skip to content

Commit

Permalink
SCons: Re-allow upcoming GCC 8.4, fixes C++17 copy elision
Browse files Browse the repository at this point in the history
Follow-up to godotengine#36484.

The patches for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521 have now
landed in the `releases/gcc-8` branch and will be in GCC 8.4.
  • Loading branch information
akien-mga committed Feb 26, 2020
1 parent 2d980f6 commit dd4eb54
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
20 changes: 11 additions & 9 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -334,23 +334,25 @@ if selected_platform in platform_list:

# 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
if version is not None and methods.using_gcc(env):
major = int(version[0])
minor = int(version[1])
# GCC 8 before 8.4 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.")
if major == 8 and minor < 4:
print("Detected GCC 8 version < 8.4, 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):
elif version is not None and methods.using_clang(env):
major = int(version[0])
# 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":
Expand Down
6 changes: 5 additions & 1 deletion methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,18 @@ def is_vanilla_clang(env):


def get_compiler_version(env):
"""
Returns an array of version numbers as strings: [major, minor, patch].
The return array should have at least two values (major, minor).
"""
if using_gcc(env):
version = decode_utf8(subprocess.check_output([env['CXX'], '-dumpversion']).strip())
elif using_clang(env):
# Not using -dumpversion as it used to return 4.2.1: https://reviews.llvm.org/D56803
version = decode_utf8(subprocess.check_output([env['CXX'], '--version']).strip())
else: # TODO: Implement for MSVC
return None
match = re.search('[0-9][0-9.]*', version)
match = re.search('[0-9]+\.[0-9.]*', version)
if match is not None:
return match.group().split('.')
else:
Expand Down

0 comments on commit dd4eb54

Please sign in to comment.