mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Merge pull request #101040 from akien-mga/2.1-build-fixes
[2.1] Build fixes for modern toolchains
This commit is contained in:
commit
44184ed0c3
19 changed files with 129 additions and 36 deletions
15
SConstruct
15
SConstruct
|
|
@ -295,10 +295,23 @@ if selected_platform in platform_list:
|
|||
# must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
|
||||
detect.configure(env)
|
||||
|
||||
# Set our C and C++ standard requirements.
|
||||
# Prepending to make it possible to override.
|
||||
is_msvc = os.name == "nt" and os.getenv("VCINSTALLDIR") and (platform_arg == "windows" or platform_arg == "uwp")
|
||||
if (not is_msvc):
|
||||
# Specifying GNU extensions support explicitly, which are supported by both GCC and Clang.
|
||||
# We don't support C++17 so stick to earlier standards.
|
||||
# When 2.1 was actively worked on, we were using GCC 5 which defaults to C++98, so use that.
|
||||
env.Prepend(CFLAGS=["-std=gnu11"])
|
||||
env.Prepend(CXXFLAGS=["-std=gnu++98"])
|
||||
else:
|
||||
# MSVC doesn't support setting C++ to pre-C++14 standards, so do nothing and hope it works.
|
||||
pass
|
||||
|
||||
if (env["warnings"] == 'yes'):
|
||||
print("WARNING: warnings=yes is deprecated; assuming warnings=all")
|
||||
|
||||
if (os.name == "nt" and os.getenv("VCINSTALLDIR") and (platform_arg == "windows" or platform_arg == "uwp")): # MSVC, needs to stand out of course
|
||||
if (is_msvc): # MSVC
|
||||
disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4800'] # Truncations, narrowing conversions...
|
||||
if (env["warnings"] == 'extra'):
|
||||
env.Append(CCFLAGS=['/Wall']) # Implies /W4
|
||||
|
|
|
|||
|
|
@ -213,3 +213,5 @@ for c in list(old_doc):
|
|||
for c in list(new_doc):
|
||||
write_class(c)
|
||||
write_string(f, '</doc>\n')
|
||||
|
||||
f.close()
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ def make_class_list(class_list, columns):
|
|||
|
||||
s += '\n'
|
||||
f.write(s)
|
||||
f.close()
|
||||
|
||||
|
||||
def dokuize_text(txt):
|
||||
|
|
@ -324,6 +325,7 @@ def make_doku_class(node):
|
|||
f.write('\n')
|
||||
f.write(dokuize_text(d.text.strip()))
|
||||
f.write('\n')
|
||||
f.close()
|
||||
|
||||
|
||||
for file in input_list:
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ def make_class_list(class_list, columns):
|
|||
for n in range(0, columns):
|
||||
f.write("--+-------+")
|
||||
f.write("\n")
|
||||
f.close()
|
||||
|
||||
|
||||
def rstize_text(text, cclass):
|
||||
|
|
@ -504,6 +505,7 @@ def make_rst_class(node):
|
|||
f.write(rstize_text(d.text.strip(), name))
|
||||
f.write("\n\n")
|
||||
f.write('\n')
|
||||
f.close()
|
||||
|
||||
|
||||
for file in input_list:
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ def build_shader_header(target, source, env):
|
|||
line = fs.readline()
|
||||
|
||||
fd.write(";\n")
|
||||
fd.close()
|
||||
|
||||
return 0
|
||||
|
||||
|
|
@ -1105,6 +1106,7 @@ def update_version():
|
|||
f.write("#define VERSION_STATUS " + str(version.status) + "\n")
|
||||
import datetime
|
||||
f.write("#define VERSION_YEAR " + str(datetime.datetime.now().year) + "\n")
|
||||
f.close()
|
||||
|
||||
|
||||
def parse_cg_file(fname, uniforms, sizes, conditionals):
|
||||
|
|
@ -1175,6 +1177,7 @@ def build_cg_shader(sname):
|
|||
fd.write('\t\tVP_%s,\n' % vp_uniforms[i].upper())
|
||||
|
||||
fd.write("\t};\n")
|
||||
fd.close()
|
||||
|
||||
|
||||
import glob
|
||||
|
|
@ -1230,6 +1233,7 @@ void unregister_module_types() {
|
|||
|
||||
f = open("modules/register_module_types.gen.cpp", "w")
|
||||
f.write(modules_cpp)
|
||||
f.close()
|
||||
|
||||
return module_list
|
||||
|
||||
|
|
@ -1464,6 +1468,7 @@ def save_active_platforms(apnames, ap):
|
|||
wf = x + "/logo.gen.h"
|
||||
logow = open(wf, "w")
|
||||
logow.write(str)
|
||||
logow.close()
|
||||
|
||||
|
||||
def no_verbose(sys, env):
|
||||
|
|
|
|||
|
|
@ -176,3 +176,4 @@ for x in functions:
|
|||
f.write("\n\n")
|
||||
f.write("}\n")
|
||||
f.write("\n\n")
|
||||
f.close()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import shutil
|
||||
from compat import open_utf8
|
||||
from distutils.version import LooseVersion
|
||||
from detect import get_ndk_version
|
||||
|
||||
Import('env')
|
||||
|
|
@ -143,6 +142,7 @@ manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$", env.android_manifest_c
|
|||
manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$", env.android_permission_chunk)
|
||||
manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$", env.android_appattributes_chunk)
|
||||
pp_baseout.write(manifest)
|
||||
pp_baseout.close()
|
||||
|
||||
|
||||
lib = env_android.add_shared_library("#bin/libgodot", [android_objects], SHLIBSUFFIX=env["SHLIBSUFFIX"])
|
||||
|
|
@ -167,10 +167,16 @@ if lib_arch_dir != '':
|
|||
else: # release_debug, debug
|
||||
lib_type_dir = 'debug'
|
||||
|
||||
# HACK: Replaced use of now obsoleted distutils.version.LooseVersion with this simple method,
|
||||
# which isn't bullet proof but should be sufficient here with "x.y.z" parameters.
|
||||
# Alternatives imply adding more dependencies.
|
||||
def version_tuple(v):
|
||||
return tuple(map(int, (v.split("."))))
|
||||
|
||||
out_dir = '#platform/android/java/libs/' + lib_type_dir + '/' + lib_arch_dir
|
||||
env_android.Command(out_dir + '/libgodot_android.so', '#bin/libgodot' + env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE"))
|
||||
ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"])
|
||||
if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"):
|
||||
if ndk_version != None and version_tuple(ndk_version) >= version_tuple("15.0.4075724"):
|
||||
if env['android_stl'] == 'yes':
|
||||
stl_lib_path = str(env['ANDROID_NDK_ROOT']) + '/sources/cxx-stl/llvm-libc++/libs/' + lib_arch_dir + '/libc++_shared.so'
|
||||
env_android.Command(out_dir + '/libc++_shared.so', stl_lib_path, Copy("$TARGET", "$SOURCE"))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import os
|
|||
import sys
|
||||
import string
|
||||
import platform
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
def is_active():
|
||||
return True
|
||||
|
|
@ -193,8 +192,14 @@ def configure(env):
|
|||
|
||||
lib_sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + env['ndk_platform'] + "/" + env['ARCH']
|
||||
|
||||
# HACK: Replaced use of now obsoleted distutils.version.LooseVersion with this simple method,
|
||||
# which isn't bullet proof but should be sufficient here with "x.y.z" parameters.
|
||||
# Alternatives imply adding more dependencies.
|
||||
def version_tuple(v):
|
||||
return tuple(map(int, (v.split("."))))
|
||||
|
||||
ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"])
|
||||
if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"):
|
||||
if ndk_version != None and version_tuple(ndk_version) >= version_tuple("15.0.4075724"):
|
||||
print("Using NDK unified headers")
|
||||
sysroot = env["ANDROID_NDK_ROOT"] + "/sysroot"
|
||||
env.Append(CPPFLAGS=["--sysroot="+sysroot])
|
||||
|
|
@ -251,9 +256,9 @@ def configure(env):
|
|||
if (sys.platform.startswith("darwin")):
|
||||
env['SHLIBSUFFIX'] = '.so'
|
||||
|
||||
if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"):
|
||||
if ndk_version != None and version_tuple(ndk_version) >= version_tuple("15.0.4075724"):
|
||||
if env['android_stl'] == 'yes':
|
||||
if LooseVersion(ndk_version) >= LooseVersion("17.1.4828580"):
|
||||
if version_tuple(ndk_version) >= version_tuple("17.1.4828580"):
|
||||
env.Append(LINKFLAGS=['-Wl,--exclude-libs,libgcc.a','-Wl,--exclude-libs,libatomic.a','-nostdlib++'])
|
||||
else:
|
||||
env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libandroid_support.a"])
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@ def configure(env):
|
|||
|
||||
env['OBJSUFFIX'] = '.bc'
|
||||
env['LIBSUFFIX'] = '.bc'
|
||||
env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
|
||||
env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
|
||||
|
||||
# env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2'])
|
||||
|
||||
|
|
|
|||
|
|
@ -716,7 +716,10 @@ bool OS_JavaScript::main_loop_iterate() {
|
|||
/* clang-format on */
|
||||
}
|
||||
}
|
||||
process_joysticks();
|
||||
|
||||
if (emscripten_sample_gamepad_data() == EMSCRIPTEN_RESULT_SUCCESS)
|
||||
process_joysticks();
|
||||
|
||||
return Main::iteration();
|
||||
}
|
||||
|
||||
|
|
@ -805,8 +808,11 @@ void OS_JavaScript::process_joysticks() {
|
|||
int joy_count = emscripten_get_num_gamepads();
|
||||
for (int i = 0; i < joy_count; i++) {
|
||||
EmscriptenGamepadEvent state;
|
||||
emscripten_get_gamepad_status(i, &state);
|
||||
if (state.connected) {
|
||||
EMSCRIPTEN_RESULT query_result = emscripten_get_gamepad_status(i, &state);
|
||||
// Chromium reserves gamepads slots, so NO_DATA is an expected result.
|
||||
ERR_CONTINUE(query_result != EMSCRIPTEN_RESULT_SUCCESS &&
|
||||
query_result != EMSCRIPTEN_RESULT_NO_DATA);
|
||||
if (query_result == EMSCRIPTEN_RESULT_SUCCESS && state.connected) {
|
||||
|
||||
int num_buttons = MIN(state.numButtons, 18);
|
||||
int num_axes = MIN(state.numAxes, 8);
|
||||
|
|
|
|||
|
|
@ -40,16 +40,6 @@ def configure(env):
|
|||
env["CC"] = "clang"
|
||||
env["CXX"] = "clang++"
|
||||
env["LD"] = "clang++"
|
||||
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)
|
||||
|
||||
is64 = sys.maxsize > 2**32
|
||||
|
||||
|
|
|
|||
|
|
@ -326,6 +326,18 @@ def configure(env):
|
|||
|
||||
if (env["bits"] == "64"):
|
||||
env.Append(CCFLAGS=['-O3'])
|
||||
|
||||
if (os.system(mingw_prefix + "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([mingw_prefix + '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)
|
||||
else:
|
||||
env.Append(CCFLAGS=['-O2'])
|
||||
|
||||
|
|
|
|||
|
|
@ -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'])
|
||||
|
|
|
|||
13
thirdparty/freetype/patches/xcode16-compat.patch
vendored
Normal file
13
thirdparty/freetype/patches/xcode16-compat.patch
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/thirdparty/freetype/src/gzip/ftzconf.h b/thirdparty/freetype/src/gzip/ftzconf.h
|
||||
index 3abf0ba03b..d88a82a2ee 100644
|
||||
--- a/thirdparty/freetype/src/gzip/ftzconf.h
|
||||
+++ b/thirdparty/freetype/src/gzip/ftzconf.h
|
||||
@@ -215,7 +215,7 @@
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
-#if !defined(MACOS) && !defined(TARGET_OS_MAC)
|
||||
+#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
2
thirdparty/freetype/src/gzip/ftzconf.h
vendored
2
thirdparty/freetype/src/gzip/ftzconf.h
vendored
|
|
@ -215,7 +215,7 @@
|
|||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(MACOS) && !defined(TARGET_OS_MAC)
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
|
|
|
|||
6
thirdparty/libmpcdec/mpc_bits_reader.c
vendored
6
thirdparty/libmpcdec/mpc_bits_reader.c
vendored
|
|
@ -98,7 +98,7 @@ const mpc_uint32_t Cnk_lost[MAX_ENUM / 2][MAX_ENUM] =
|
|||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 103, 55, 3347, 12419, 56459, 16987, 313105, 54177, 3076873, 3739321, 3132677, 66353813, 123012781, 236330717}
|
||||
};
|
||||
|
||||
static const mpc_uint8_t log2[32] =
|
||||
static const mpc_uint8_t mpc_log2[32] =
|
||||
{ 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6};
|
||||
|
||||
static const mpc_uint8_t log2_lost[32] =
|
||||
|
|
@ -136,8 +136,8 @@ mpc_int32_t mpc_bits_golomb_dec(mpc_bits_reader * r, const mpc_uint_t k)
|
|||
mpc_uint32_t mpc_bits_log_dec(mpc_bits_reader * r, mpc_uint_t max)
|
||||
{
|
||||
mpc_uint32_t value = 0;
|
||||
if (log2[max - 1] > 1)
|
||||
value = mpc_bits_read(r, log2[max - 1] - 1);
|
||||
if (mpc_log2[max - 1] > 1)
|
||||
value = mpc_bits_read(r, mpc_log2[max - 1] - 1);
|
||||
if (value >= log2_lost[max - 1])
|
||||
value = ((value << 1) | mpc_bits_read(r, 1)) - log2_lost[max - 1];
|
||||
return value;
|
||||
|
|
|
|||
BIN
thirdparty/libmpcdec/patches/msvc-log2.patch
vendored
Normal file
BIN
thirdparty/libmpcdec/patches/msvc-log2.patch
vendored
Normal file
Binary file not shown.
8
thirdparty/speex/fftwrap.c
vendored
8
thirdparty/speex/fftwrap.c
vendored
|
|
@ -330,7 +330,11 @@ void spx_fft_float(void *table, float *in, float *out)
|
|||
#endif
|
||||
for (i=0;i<N;i++)
|
||||
_in[i] = (int)floor(.5+in[i]);
|
||||
#ifdef USE_SMALLFT
|
||||
spx_fft(table, (float *)_in, (float *)_out);
|
||||
#else
|
||||
spx_fft(table, _in, _out);
|
||||
#endif
|
||||
for (i=0;i<N;i++)
|
||||
out[i] = _out[i];
|
||||
#if 0
|
||||
|
|
@ -366,7 +370,11 @@ void spx_ifft_float(void *table, float *in, float *out)
|
|||
#endif
|
||||
for (i=0;i<N;i++)
|
||||
_in[i] = (int)floor(.5+in[i]);
|
||||
#ifdef USE_SMALLFT
|
||||
spx_ifft(table, (float *)_in, (float *)_out);
|
||||
#else
|
||||
spx_ifft(table, _in, _out);
|
||||
#endif
|
||||
for (i=0;i<N;i++)
|
||||
out[i] = _out[i];
|
||||
#if 0
|
||||
|
|
|
|||
28
thirdparty/speex/patches/speex-gcc13-incompatible-pointers.patch
vendored
Normal file
28
thirdparty/speex/patches/speex-gcc13-incompatible-pointers.patch
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
diff --git a/thirdparty/speex/fftwrap.c b/thirdparty/speex/fftwrap.c
|
||||
index ac71bbfcb7..9765630e12 100644
|
||||
--- a/thirdparty/speex/fftwrap.c
|
||||
+++ b/thirdparty/speex/fftwrap.c
|
||||
@@ -330,7 +330,11 @@ void spx_fft_float(void *table, float *in, float *out)
|
||||
#endif
|
||||
for (i=0;i<N;i++)
|
||||
_in[i] = (int)floor(.5+in[i]);
|
||||
+#ifdef USE_SMALLFT
|
||||
+ spx_fft(table, (float *)_in, (float *)_out);
|
||||
+#else
|
||||
spx_fft(table, _in, _out);
|
||||
+#endif
|
||||
for (i=0;i<N;i++)
|
||||
out[i] = _out[i];
|
||||
#if 0
|
||||
@@ -366,7 +370,11 @@ void spx_ifft_float(void *table, float *in, float *out)
|
||||
#endif
|
||||
for (i=0;i<N;i++)
|
||||
_in[i] = (int)floor(.5+in[i]);
|
||||
+#ifdef USE_SMALLFT
|
||||
+ spx_ifft(table, (float *)_in, (float *)_out);
|
||||
+#else
|
||||
spx_ifft(table, _in, _out);
|
||||
+#endif
|
||||
for (i=0;i<N;i++)
|
||||
out[i] = _out[i];
|
||||
#if 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue