mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Linux: Allow building with GCC > 8, only GCC 6/7 trigger the Object::cast_to optimization issue
And likewise, prevent building with mingw-gcc for Windows if it's GCC 6/7. The check for the Server platform was unnecessary as its `release` template doesn't use `-O3`/`-Ofast`.
This commit is contained in:
parent
df4d769f99
commit
a87391d256
3 changed files with 24 additions and 20 deletions
|
|
@ -86,16 +86,6 @@ def configure(env):
|
|||
env["LD"] = "clang++"
|
||||
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
|
||||
env.extra_suffix = ".llvm"
|
||||
elif (os.system("gcc --version > /dev/null 2>&1") == 0): # GCC
|
||||
# Hack to prevent building this branch with GCC 6+, which trigger segfaults due to UB when dereferencing pointers in Object::cast_to
|
||||
# This is fixed in the master branch, for 2.1 we just prevent using too recent GCC versions.
|
||||
import subprocess
|
||||
gcc_major = subprocess.check_output(['gcc', '-dumpversion']).decode('ascii').split('.')[0]
|
||||
if (int(gcc_major) > 5):
|
||||
print("Your configured compiler appears to be GCC %s, which triggers issues in release builds for this version of Godot (fixed in Godot 3.0+)." % gcc_major)
|
||||
print("You can use the Clang compiler instead with the `use_llvm=yes` option, or configure another compiler such as GCC 5 using the CC, CXX and LD flags.")
|
||||
print("Aborting..")
|
||||
sys.exit(255)
|
||||
|
||||
if (env["use_sanitizer"] == "yes"):
|
||||
env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
|
||||
|
|
@ -125,6 +115,18 @@ def configure(env):
|
|||
if (env["debug_release"] == "yes"):
|
||||
env.Prepend(CCFLAGS=['-g2'])
|
||||
|
||||
if (os.system("gcc --version > /dev/null 2>&1") == 0): # GCC
|
||||
# Hack to prevent segfaults due to UB when dereferencing NULL `this` in `Object::cast_to` with `-O3`.
|
||||
# This is fixed in 3.0, for 2.1 we just prevent using the known affected GCC versions (6 and 7).
|
||||
# GCC 5 or GCC 8 and later seem to be fine.
|
||||
import subprocess
|
||||
gcc_major = int(subprocess.check_output(['gcc', '-dumpversion']).decode('ascii').split('.')[0])
|
||||
if (gcc_major == 6 or gcc_major == 7):
|
||||
print("Your configured compiler appears to be GCC %d, which triggers issues in release builds for this version of Godot (fixed in Godot 3.0+)." % gcc_major)
|
||||
print("You can use the Clang compiler instead with the `use_llvm=yes` option, or configure another compiler such as GCC 5 using the CC, CXX and LD flags.")
|
||||
print("Aborting..")
|
||||
sys.exit(255)
|
||||
|
||||
elif (env["target"] == "release_debug"):
|
||||
|
||||
env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue