Skip to content

Commit a030197

Browse files
authored
Merge pull request #98900 from akien-mga/3.2-ci-build-warnings-fixes
[3.2] Misc. build and warning fixes to pass CI and compile with recent SCons and GCC/Clang
2 parents 2407df9 + b35c7ee commit a030197

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3857
-3750
lines changed

.github/workflows/android_builds.yml

+16-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on: [push, pull_request]
44
# Global Settings
55
env:
66
SCONSFLAGS: platform=android verbose=yes warnings=all werror=yes debug_symbols=no --jobs=2
7+
ANDROID_HOME: /home/runner/work/godot/godot/android-sdk
8+
ANDROID_NDK_ROOT: /home/runner/work/godot/godot/android-sdk/ndk/21.1.6352462
79
ANDROID_NDK_VERSION: 21.1.6352462
810

911
jobs:
@@ -13,7 +15,7 @@ jobs:
1315
name: Template (target=release, tools=no)
1416

1517
steps:
16-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
1719

1820
# Azure repositories are not reliable, we need to prevent azure giving us packages.
1921
- name: Make apt sources.list use the default Ubuntu repositories
@@ -22,18 +24,23 @@ jobs:
2224
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
2325
sudo apt-get update
2426
25-
- name: Set up Java 8
26-
uses: actions/setup-java@v1
27-
with:
28-
java-version: 8
29-
30-
- name: Install Android NDK r21
27+
- name: Set up Java 8, Android SDK and NDK
3128
run: |
32-
sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install 'ndk;${{env.ANDROID_NDK_VERSION}}'
29+
# Not using actions/setup-java and android-actions/setup-android as I couldn't make them work for such old Java/SDK/NDK combination.
30+
sudo apt-get install openjdk-8-jdk
31+
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
32+
mkdir -p ${{env.ANDROID_HOME}}
33+
cd ${{env.ANDROID_HOME}}
34+
# Using an old version to be compatible with older Java.
35+
curl -LO https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
36+
unzip commandlinetools-linux-8512546_latest.zip
37+
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${{env.ANDROID_HOME}} --licenses
38+
# https://github.com/godotengine/build-containers/blob/3.2/Dockerfile.android
39+
./cmdline-tools/bin/sdkmanager --sdk_root=${{env.ANDROID_HOME}} 'build-tools;28.0.3' 'platforms;android-28' 'cmake;3.10.2.4988404' 'ndk;${{env.ANDROID_NDK_VERSION}}'
3340
3441
# Use python 3.x release (works cross platform)
3542
- name: Set up Python 3.x
36-
uses: actions/setup-python@v2
43+
uses: actions/setup-python@v5
3744
with:
3845
# Semantic version range syntax or exact version of a Python version
3946
python-version: '3.x'
@@ -48,8 +55,6 @@ jobs:
4855
scons --version
4956
5057
- name: Compilation
51-
env:
52-
ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/${{env.ANDROID_NDK_VERSION}}/
5358
run: |
5459
scons target=release tools=no android_arch=armv7
5560
scons target=release tools=no android_arch=arm64v8

.github/workflows/ios_builds.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
name: Template (target=release, tools=no)
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515

1616
# Use python 3.x release (works cross platform)
1717
- name: Set up Python 3.x
18-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v5
1919
with:
2020
# Semantic version range syntax or exact version of a Python version
2121
python-version: '3.x'

.github/workflows/javascript_builds.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: Template (target=release, tools=no)
1414

1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717

1818
# Azure repositories are not reliable, we need to prevent azure giving us packages.
1919
- name: Make apt sources.list use the default Ubuntu repositories
@@ -25,14 +25,14 @@ jobs:
2525
# Additional cache for Emscripten generated system libraries
2626
- name: Load Emscripten cache
2727
id: javascript-template-emscripten-cache
28-
uses: actions/cache@v2
28+
uses: actions/cache@v4
2929
with:
3030
path: ${{env.EM_CACHE_FOLDER}}
3131
key: ${{env.EM_VERSION}}-${{github.job}}
3232

3333
# Use python 3.x release (works cross platform)
3434
- name: Set up Python 3.x
35-
uses: actions/setup-python@v2
35+
uses: actions/setup-python@v5
3636
with:
3737
# Semantic version range syntax or exact version of a Python version
3838
python-version: '3.x'
@@ -48,7 +48,7 @@ jobs:
4848
scons --version
4949
5050
- name: Set up Emscripten latest
51-
uses: mymindstorm/setup-emsdk@v7
51+
uses: mymindstorm/setup-emsdk@v14
5252
with:
5353
version: ${{env.EM_VERSION}}
5454
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}

.github/workflows/linux_builds.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Editor w/ Mono (target=release_debug, tools=yes)
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515

1616
# Azure repositories are not reliable, we need to prevent azure giving us packages.
1717
- name: Make apt sources.list use the default Ubuntu repositories
@@ -28,7 +28,7 @@ jobs:
2828
2929
# Use python 3.x release (works cross platform; best to keep self contained in it's own step)
3030
- name: Set up Python 3.x
31-
uses: actions/setup-python@v2
31+
uses: actions/setup-python@v5
3232
with:
3333
# Semantic version range syntax or exact version of a Python version
3434
python-version: '3.x'
@@ -56,7 +56,7 @@ jobs:
5656
name: Template w/ Mono (target=release, tools=no)
5757

5858
steps:
59-
- uses: actions/checkout@v2
59+
- uses: actions/checkout@v4
6060

6161
# Azure repositories are not reliable, we need to prevent azure giving us packages.
6262
- name: Make apt sources.list use the default Ubuntu repositories
@@ -73,7 +73,7 @@ jobs:
7373
7474
# Use python 3.x release (works cross platform)
7575
- name: Set up Python 3.x
76-
uses: actions/setup-python@v2
76+
uses: actions/setup-python@v5
7777
with:
7878
# Semantic version range syntax or exact version of a Python version
7979
python-version: '3.x'

.github/workflows/macos_builds.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
name: Editor (target=release_debug, tools=yes)
1313

1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616

1717
# Use python 3.x release (works cross platform; best to keep self contained in it's own step)
1818
- name: Set up Python 3.x
19-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@v5
2020
with:
2121
# Semantic version range syntax or exact version of a Python version
2222
python-version: '3.x'
@@ -42,11 +42,11 @@ jobs:
4242
name: Template (target=release, tools=no)
4343

4444
steps:
45-
- uses: actions/checkout@v2
45+
- uses: actions/checkout@v4
4646

4747
# Use python 3.x release (works cross platform)
4848
- name: Set up Python 3.x
49-
uses: actions/setup-python@v2
49+
uses: actions/setup-python@v5
5050
with:
5151
# Semantic version range syntax or exact version of a Python version
5252
python-version: '3.x'

.github/workflows/server_builds.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Linux Headless w/ Mono (target=release_debug, tools=yes)
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515

1616
# Azure repositories are not reliable, we need to prevent azure giving us packages.
1717
- name: Make apt sources.list use the default Ubuntu repositories
@@ -27,7 +27,7 @@ jobs:
2727
2828
# Use python 3.x release (works cross platform; best to keep self contained in it's own step)
2929
- name: Set up Python 3.x
30-
uses: actions/setup-python@v2
30+
uses: actions/setup-python@v5
3131
with:
3232
# Semantic version range syntax or exact version of a Python version
3333
python-version: '3.x'
@@ -52,7 +52,7 @@ jobs:
5252
name: Linux Server w/ Mono (target=release, tools=no)
5353

5454
steps:
55-
- uses: actions/checkout@v2
55+
- uses: actions/checkout@v4
5656

5757
# Azure repositories are not reliable, we need to prevent azure giving us packages.
5858
- name: Make apt sources.list use the default Ubuntu repositories
@@ -68,7 +68,7 @@ jobs:
6868
6969
# Use python 3.x release (works cross platform)
7070
- name: Set up Python 3.x
71-
uses: actions/setup-python@v2
71+
uses: actions/setup-python@v5
7272
with:
7373
# Semantic version range syntax or exact version of a Python version
7474
python-version: '3.x'

.github/workflows/static_checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-20.04
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v2
10+
uses: actions/checkout@v4
1111

1212
# Azure repositories are not reliable, we need to prevent Azure giving us packages.
1313
- name: Make apt sources.list use the default Ubuntu repositories

.github/workflows/windows_builds.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414
name: Editor (target=release_debug, tools=yes)
1515

1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1818

1919
# Use python 3.x release (works cross platform; best to keep self contained in it's own step)
2020
- name: Set up Python 3.x
21-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v5
2222
with:
2323
# Semantic version range syntax or exact version of a Python version
2424
python-version: '3.x'
@@ -44,11 +44,11 @@ jobs:
4444
name: Template (target=release, tools=no)
4545

4646
steps:
47-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v4
4848

4949
# Use python 3.x release (works cross platform)
5050
- name: Set up Python 3.x
51-
uses: actions/setup-python@v2
51+
uses: actions/setup-python@v5
5252
with:
5353
# Semantic version range syntax or exact version of a Python version
5454
python-version: '3.x'

SConstruct

+10-7
Original file line numberDiff line numberDiff line change
@@ -407,18 +407,21 @@ if selected_platform in platform_list:
407407
else: # Rest of the world
408408
version = methods.get_compiler_version(env) or [-1, -1]
409409

410-
shadow_local_warning = []
411-
all_plus_warnings = ["-Wwrite-strings"]
410+
common_warnings = []
412411

413412
if methods.using_gcc(env):
414-
env.Append(CCFLAGS=["-Wno-misleading-indentation"])
413+
common_warnings += ["-Wno-misleading-indentation"]
415414
if version[0] >= 7:
416-
shadow_local_warning = ["-Wshadow-local"]
415+
common_warnings += ["-Wshadow-local"]
416+
elif methods.using_clang(env):
417+
# We often implement `operator<` for structs of pointers as a requirement
418+
# for putting them in `Set` or `Map`. We don't mind about unreliable ordering.
419+
common_warnings += ["-Wno-ordered-compare-function-pointers"]
417420

418421
if env["warnings"] == "extra":
419422
# Note: enable -Wimplicit-fallthrough for Clang (already part of -Wextra for GCC)
420423
# once we switch to C++11 or later (necessary for our FALLTHROUGH macro).
421-
env.Append(CCFLAGS=["-Wall", "-Wextra", "-Wno-unused-parameter"] + all_plus_warnings + shadow_local_warning)
424+
env.Append(CCFLAGS=["-Wall", "-Wextra", "-Wwrite-strings", "-Wno-unused-parameter"] + common_warnings)
422425
env.Append(CXXFLAGS=["-Wctor-dtor-privacy", "-Wnon-virtual-dtor"])
423426
if methods.using_gcc(env):
424427
env.Append(
@@ -434,9 +437,9 @@ if selected_platform in platform_list:
434437
if version[0] >= 9:
435438
env.Append(CCFLAGS=["-Wattribute-alias=2"])
436439
elif env["warnings"] == "all":
437-
env.Append(CCFLAGS=["-Wall"] + shadow_local_warning)
440+
env.Append(CCFLAGS=["-Wall"] + common_warnings)
438441
elif env["warnings"] == "moderate":
439-
env.Append(CCFLAGS=["-Wall", "-Wno-unused"] + shadow_local_warning)
442+
env.Append(CCFLAGS=["-Wall", "-Wno-unused"] + common_warnings)
440443
else: # 'no'
441444
env.Append(CCFLAGS=["-w"])
442445
if env["werror"]:

core/bind/core_bind.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,9 @@ struct _OSCoreBindImg {
999999
};
10001000

10011001
void _OS::print_all_textures_by_size() {
1002-
1002+
// HACK: This is broken, was fixed in 3.4+, we don't bother here.
1003+
// Just comment out to silence warnings.
1004+
/*
10031005
List<_OSCoreBindImg> imgs;
10041006
int total = 0;
10051007
{
@@ -1031,6 +1033,7 @@ void _OS::print_all_textures_by_size() {
10311033
10321034
total -= E->get().vram;
10331035
}
1036+
*/
10341037
}
10351038

10361039
void _OS::print_resources_by_type(const Vector<String> &p_types) {

core/compressed_translation.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
6262

6363
int idx = 0;
6464
int total_compression_size = 0;
65-
int total_string_size = 0;
6665

6766
for (List<StringName>::Element *E = keys.front(); E; E = E->next()) {
6867

@@ -101,7 +100,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
101100

102101
compressed.write[idx] = ps;
103102
total_compression_size += ps.compressed.size();
104-
total_string_size += src_s.size();
105103
idx++;
106104
}
107105

@@ -148,16 +146,13 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
148146
uint32_t *btw = (uint32_t *)&btwb[0];
149147

150148
int btindex = 0;
151-
int collisions = 0;
152149

153150
for (int i = 0; i < size; i++) {
154151

155152
const Map<uint32_t, int> &t = table[i];
156153
if (t.size() == 0) {
157154
htw[i] = 0xFFFFFFFF; //nothing
158155
continue;
159-
} else if (t.size() > 1) {
160-
collisions += t.size() - 1;
161156
}
162157

163158
htw[i] = btindex;

core/cowdata.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define COWDATA_H_
3333

3434
#include <string.h>
35+
#include <type_traits>
3536

3637
#include "core/error_macros.h"
3738
#include "core/os/memory.h"
@@ -199,7 +200,7 @@ void CowData<T>::_unref(void *p_data) {
199200
return; // still in use
200201
// clean up
201202

202-
if (!__has_trivial_destructor(T)) {
203+
if (!std::is_trivially_destructible<T>::value) {
203204
uint32_t *count = _get_size();
204205
T *data = (T *)(count + 1);
205206

@@ -233,7 +234,7 @@ void CowData<T>::_copy_on_write() {
233234
T *_data = (T *)(mem_new);
234235

235236
// initialize new elements
236-
if (__has_trivial_copy(T)) {
237+
if (std::is_trivially_copyable<T>::value) {
237238
memcpy(mem_new, _ptr, current_size * sizeof(T));
238239

239240
} else {
@@ -292,7 +293,7 @@ Error CowData<T>::resize(int p_size) {
292293

293294
// construct the newly created elements
294295

295-
if (!__has_trivial_constructor(T)) {
296+
if (!std::is_trivially_constructible<T>::value) {
296297
T *elems = _get_data();
297298

298299
for (int i = *_get_size(); i < p_size; i++) {
@@ -303,8 +304,7 @@ Error CowData<T>::resize(int p_size) {
303304
*_get_size() = p_size;
304305

305306
} else if (p_size < current_size) {
306-
307-
if (!__has_trivial_destructor(T)) {
307+
if (!std::is_trivially_destructible<T>::value) {
308308
// deinitialize no longer needed elements
309309
for (uint32_t i = p_size; i < *_get_size(); i++) {
310310
T *t = &_get_data()[i];

core/io/logger.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ void RotatedFileLogger::rotate_file() {
151151

152152
if (FileAccess::exists(base_path)) {
153153
if (max_files > 1) {
154-
char timestamp[21];
154+
const size_t TIMESTAMP_SIZE = 21;
155+
char timestamp[TIMESTAMP_SIZE];
155156
OS::Date date = OS::get_singleton()->get_date();
156157
OS::Time time = OS::get_singleton()->get_time();
157-
sprintf(timestamp, "_%04d-%02d-%02d_%02d-%02d-%02d", date.year, date.month, date.day, time.hour, time.min, time.sec);
158+
snprintf(timestamp, TIMESTAMP_SIZE, "_%04d-%02d-%02d_%02d-%02d-%02d", date.year, date.month, date.day, time.hour, time.min, time.sec);
158159

159160
String backup_name = base_path.get_basename() + timestamp;
160161
if (base_path.get_extension() != String()) {

0 commit comments

Comments
 (0)