Skip to content

Commit

Permalink
Merge pull request #98900 from akien-mga/3.2-ci-build-warnings-fixes
Browse files Browse the repository at this point in the history
[3.2] Misc. build and warning fixes to pass CI and compile with recent SCons and GCC/Clang
  • Loading branch information
akien-mga authored Nov 7, 2024
2 parents 2407df9 + b35c7ee commit a030197
Show file tree
Hide file tree
Showing 51 changed files with 3,857 additions and 3,750 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on: [push, pull_request]
# Global Settings
env:
SCONSFLAGS: platform=android verbose=yes warnings=all werror=yes debug_symbols=no --jobs=2
ANDROID_HOME: /home/runner/work/godot/godot/android-sdk
ANDROID_NDK_ROOT: /home/runner/work/godot/godot/android-sdk/ndk/21.1.6352462
ANDROID_NDK_VERSION: 21.1.6352462

jobs:
Expand All @@ -13,7 +15,7 @@ jobs:
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
Expand All @@ -22,18 +24,23 @@ jobs:
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
sudo apt-get update
- name: Set up Java 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Install Android NDK r21
- name: Set up Java 8, Android SDK and NDK
run: |
sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install 'ndk;${{env.ANDROID_NDK_VERSION}}'
# Not using actions/setup-java and android-actions/setup-android as I couldn't make them work for such old Java/SDK/NDK combination.
sudo apt-get install openjdk-8-jdk
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
mkdir -p ${{env.ANDROID_HOME}}
cd ${{env.ANDROID_HOME}}
# Using an old version to be compatible with older Java.
curl -LO https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
unzip commandlinetools-linux-8512546_latest.zip
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${{env.ANDROID_HOME}} --licenses
# https://github.com/godotengine/build-containers/blob/3.2/Dockerfile.android
./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}}'
# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
Expand All @@ -48,8 +55,6 @@ jobs:
scons --version
- name: Compilation
env:
ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/${{env.ANDROID_NDK_VERSION}}/
run: |
scons target=release tools=no android_arch=armv7
scons target=release tools=no android_arch=arm64v8
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ios_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/javascript_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
Expand All @@ -48,7 +48,7 @@ jobs:
scons --version
- name: Set up Emscripten latest
uses: mymindstorm/setup-emsdk@v7
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Editor w/ Mono (target=release_debug, tools=yes)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
Expand All @@ -73,7 +73,7 @@ jobs:
# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/macos_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
name: Editor (target=release_debug, tools=yes)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/server_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Linux Headless w/ Mono (target=release_debug, tools=yes)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
Expand All @@ -68,7 +68,7 @@ jobs:
# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent Azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
name: Editor (target=release_debug, tools=yes)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
Expand Down
17 changes: 10 additions & 7 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,21 @@ if selected_platform in platform_list:
else: # Rest of the world
version = methods.get_compiler_version(env) or [-1, -1]

shadow_local_warning = []
all_plus_warnings = ["-Wwrite-strings"]
common_warnings = []

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

if env["warnings"] == "extra":
# Note: enable -Wimplicit-fallthrough for Clang (already part of -Wextra for GCC)
# once we switch to C++11 or later (necessary for our FALLTHROUGH macro).
env.Append(CCFLAGS=["-Wall", "-Wextra", "-Wno-unused-parameter"] + all_plus_warnings + shadow_local_warning)
env.Append(CCFLAGS=["-Wall", "-Wextra", "-Wwrite-strings", "-Wno-unused-parameter"] + common_warnings)
env.Append(CXXFLAGS=["-Wctor-dtor-privacy", "-Wnon-virtual-dtor"])
if methods.using_gcc(env):
env.Append(
Expand All @@ -434,9 +437,9 @@ if selected_platform in platform_list:
if version[0] >= 9:
env.Append(CCFLAGS=["-Wattribute-alias=2"])
elif env["warnings"] == "all":
env.Append(CCFLAGS=["-Wall"] + shadow_local_warning)
env.Append(CCFLAGS=["-Wall"] + common_warnings)
elif env["warnings"] == "moderate":
env.Append(CCFLAGS=["-Wall", "-Wno-unused"] + shadow_local_warning)
env.Append(CCFLAGS=["-Wall", "-Wno-unused"] + common_warnings)
else: # 'no'
env.Append(CCFLAGS=["-w"])
if env["werror"]:
Expand Down
5 changes: 4 additions & 1 deletion core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,9 @@ struct _OSCoreBindImg {
};

void _OS::print_all_textures_by_size() {

// HACK: This is broken, was fixed in 3.4+, we don't bother here.
// Just comment out to silence warnings.
/*
List<_OSCoreBindImg> imgs;
int total = 0;
{
Expand Down Expand Up @@ -1031,6 +1033,7 @@ void _OS::print_all_textures_by_size() {
total -= E->get().vram;
}
*/
}

void _OS::print_resources_by_type(const Vector<String> &p_types) {
Expand Down
5 changes: 0 additions & 5 deletions core/compressed_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {

int idx = 0;
int total_compression_size = 0;
int total_string_size = 0;

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

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

compressed.write[idx] = ps;
total_compression_size += ps.compressed.size();
total_string_size += src_s.size();
idx++;
}

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

int btindex = 0;
int collisions = 0;

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

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

htw[i] = btindex;
Expand Down
10 changes: 5 additions & 5 deletions core/cowdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define COWDATA_H_

#include <string.h>
#include <type_traits>

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

if (!__has_trivial_destructor(T)) {
if (!std::is_trivially_destructible<T>::value) {
uint32_t *count = _get_size();
T *data = (T *)(count + 1);

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

// initialize new elements
if (__has_trivial_copy(T)) {
if (std::is_trivially_copyable<T>::value) {
memcpy(mem_new, _ptr, current_size * sizeof(T));

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

// construct the newly created elements

if (!__has_trivial_constructor(T)) {
if (!std::is_trivially_constructible<T>::value) {
T *elems = _get_data();

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

} else if (p_size < current_size) {

if (!__has_trivial_destructor(T)) {
if (!std::is_trivially_destructible<T>::value) {
// deinitialize no longer needed elements
for (uint32_t i = p_size; i < *_get_size(); i++) {
T *t = &_get_data()[i];
Expand Down
5 changes: 3 additions & 2 deletions core/io/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ void RotatedFileLogger::rotate_file() {

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

String backup_name = base_path.get_basename() + timestamp;
if (base_path.get_extension() != String()) {
Expand Down
Loading

0 comments on commit a030197

Please sign in to comment.