Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
jobs:
build-linux:
# Stay one LTS before latest to increase portability of Linux artifacts.
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
name: ${{ matrix.name }}
timeout-minutes: 120
strategy:
Expand Down
49 changes: 16 additions & 33 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -656,14 +656,14 @@ cc_version_metadata1 = cc_version["metadata1"]
if cc_version_major == -1:
print_warning(
"Couldn't detect compiler version, skipping version checks. "
"Build may fail if the compiler doesn't support C++17 fully."
"Build may fail if the compiler doesn't support C++20 fully."
)
elif methods.using_gcc(env):
if cc_version_major < 9:
if cc_version_major < 12:
print_error(
"Detected GCC version older than 9, which does not fully support "
"C++17, or has bugs when compiling Redot. Supported versions are 9 "
"and later. Use a newer GCC version, or Clang 6 or later by passing "
"Detected GCC version older than 12, which does not fully support "
"C++20. Supported versions are 12 and later. Use a newer GCC "
"version, or Clang 16 or later by passing "
'"use_llvm=yes" to the SCons command line.'
)
Exit(255)
Expand All @@ -685,35 +685,20 @@ elif methods.using_clang(env):
)
Exit(255)
else:
if cc_version_major < 6:
if cc_version_major < 16:
print_error(
"Detected Clang version older than 6, which does not fully support "
"C++17. Supported versions are Clang 6 and later."
"Detected Clang version older than 16, which does not fully support "
"C++20. Supported versions are Clang 16 and later."
)
Exit(255)
elif env["debug_paths_relative"] and cc_version_major < 10:
print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.")
env["debug_paths_relative"] = False

elif env.msvc:
# Ensure latest minor builds of Visual Studio 2017/2019.
# https://github.com/godotengine/godot/pull/94995#issuecomment-2336464574
if cc_version_major == 16 and cc_version_minor < 11:
print_error(
"Detected Visual Studio 2019 version older than 16.11, which has bugs "
"when compiling Redot. Use a newer VS2019 version, or VS2022."
)
Exit(255)
if cc_version_major == 15 and cc_version_minor < 9:
print_error(
"Detected Visual Studio 2017 version older than 15.9, which has bugs "
"when compiling Redot. Use a newer VS2017 version, or VS2019/VS2022."
)
Exit(255)
if cc_version_major < 15:
if cc_version_major < 17:
print_error(
"Detected Visual Studio 2015 or earlier, which is unsupported in Redot. "
"Supported versions are Visual Studio 2017 and later."
"Detected Visual Studio version older than VS2022, which has bugs "
"when compiling Redot. Use a newer version."
)
Exit(255)

Expand Down Expand Up @@ -824,20 +809,18 @@ if env["lto"] != "none":
print("Using LTO: " + env["lto"])

# Set our C and C++ standard requirements.
# C++17 is required as we need guaranteed copy elision as per GH-36436.
# Prepending to make it possible to override.
# This needs to come after `configure`, otherwise we don't have env.msvc.
if not env.msvc:
# Specifying GNU extensions support explicitly, which are supported by
# both GCC and Clang. Both currently default to gnu17 and gnu++17.
# both GCC and Clang. Both currently default to gnu17 and gnu++20.
env.Prepend(CFLAGS=["-std=gnu17"])
env.Prepend(CXXFLAGS=["-std=gnu++17"])
env.Prepend(CXXFLAGS=["-std=gnu++20"])
else:
# MSVC started offering C standard support with Visual Studio 2019 16.8, which covers all
# of our supported VS2019 & VS2022 versions; VS2017 will only pass the C++ standard.
env.Prepend(CXXFLAGS=["/std:c++17"])
# MSVC started offering C standard support with Visual Studio 2019 16.8
env.Prepend(CXXFLAGS=["/std:c++20"])
if cc_version_major < 16:
print_warning("Visual Studio 2017 cannot specify a C-Standard.")
print_warning("Visual Studio 2017 or older cannot specify a C-Standard.")
else:
env.Prepend(CFLAGS=["/std:c17"])
# MSVC is non-conforming with the C++ standard by default, so we enable more conformance.
Expand Down
70 changes: 20 additions & 50 deletions core/io/marshalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#include "core/typedefs.h"
#include "core/variant/variant.h"

#include <bit>
#include <concepts>

// uintr_t is only for pairing with real_t, and we only need it in here.
#ifdef REAL_T_IS_DOUBLE
typedef uint64_t uintr_t;
Expand Down Expand Up @@ -71,74 +74,45 @@ union MarshallReal {
real_t r;
};

static inline unsigned int encode_uint16(uint16_t p_uint, uint8_t *p_arr) {
for (int i = 0; i < 2; i++) {
*p_arr = p_uint & 0xFF;
p_arr++;
template <std::unsigned_integral T>
constexpr unsigned int encode_uint(T p_uint, uint8_t *p_arr) {
for (std::size_t i = 0; i < sizeof(T); ++i) {
p_arr[i] = static_cast<uint8_t>(p_uint & 0xFF);
p_uint >>= 8;
}
return static_cast<unsigned int>(sizeof(T));
}

return sizeof(uint16_t);
static inline unsigned int encode_uint16(uint16_t p_uint, uint8_t *p_arr) {
return encode_uint<uint16_t>(p_uint, p_arr);
}

static inline unsigned int encode_uint32(uint32_t p_uint, uint8_t *p_arr) {
for (int i = 0; i < 4; i++) {
*p_arr = p_uint & 0xFF;
p_arr++;
p_uint >>= 8;
}

return sizeof(uint32_t);
return encode_uint<uint32_t>(p_uint, p_arr);
}

static inline unsigned int encode_half(float p_float, uint8_t *p_arr) {
encode_uint16(Math::make_half_float(p_float), p_arr);

return sizeof(uint16_t);
return encode_uint16(Math::make_half_float(p_float), p_arr);
}

static inline unsigned int encode_float(float p_float, uint8_t *p_arr) {
MarshallFloat mf;
mf.f = p_float;
encode_uint32(mf.i, p_arr);

return sizeof(uint32_t);
return encode_uint32(std::bit_cast<uint32_t>(p_float), p_arr);
}

static inline unsigned int encode_uint64(uint64_t p_uint, uint8_t *p_arr) {
for (int i = 0; i < 8; i++) {
*p_arr = p_uint & 0xFF;
p_arr++;
p_uint >>= 8;
}

return sizeof(uint64_t);
return encode_uint<uint64_t>(p_uint, p_arr);
}

static inline unsigned int encode_double(double p_double, uint8_t *p_arr) {
MarshallDouble md;
md.d = p_double;
encode_uint64(md.l, p_arr);

return sizeof(uint64_t);
return encode_uint64(std::bit_cast<uint64_t>(p_double), p_arr);
}

static inline unsigned int encode_uintr(uintr_t p_uint, uint8_t *p_arr) {
for (size_t i = 0; i < sizeof(uintr_t); i++) {
*p_arr = p_uint & 0xFF;
p_arr++;
p_uint >>= 8;
}

return sizeof(uintr_t);
return encode_uint<uintr_t>(p_uint, p_arr);
}

static inline unsigned int encode_real(real_t p_real, uint8_t *p_arr) {
MarshallReal mr;
mr.r = p_real;
encode_uintr(mr.i, p_arr);

return sizeof(uintr_t);
return encode_uintr(std::bit_cast<uintr_t>(p_real), p_arr);
}

static inline int encode_cstring(const char *p_string, uint8_t *p_data) {
Expand Down Expand Up @@ -190,9 +164,7 @@ static inline float decode_half(const uint8_t *p_arr) {
}

static inline float decode_float(const uint8_t *p_arr) {
MarshallFloat mf;
mf.i = decode_uint32(p_arr);
return mf.f;
return std::bit_cast<float>(decode_uint32(p_arr));
}

static inline uint64_t decode_uint64(const uint8_t *p_arr) {
Expand All @@ -209,9 +181,7 @@ static inline uint64_t decode_uint64(const uint8_t *p_arr) {
}

static inline double decode_double(const uint8_t *p_arr) {
MarshallDouble md;
md.l = decode_uint64(p_arr);
return md.d;
return std::bit_cast<double>(decode_uint64(p_arr));
}

class EncodedObjectAsID : public RefCounted {
Expand Down
2 changes: 1 addition & 1 deletion core/os/spin_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static_assert(std::atomic_bool::is_always_lock_free);

class SpinLock {
union {
mutable std::atomic<bool> locked = ATOMIC_VAR_INIT(false);
mutable std::atomic<bool> locked = false;
char aligner[Thread::CACHE_LINE_BYTES];
};

Expand Down
4 changes: 1 addition & 3 deletions modules/mono/mono_gc_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,14 @@ struct GCHandleIntPtr {

_FORCE_INLINE_ bool operator==(const GCHandleIntPtr &p_other) { return value == p_other.value; }
_FORCE_INLINE_ bool operator!=(const GCHandleIntPtr &p_other) { return value != p_other.value; }

GCHandleIntPtr() = delete;
};
}

static_assert(sizeof(GCHandleIntPtr) == sizeof(void *));

/// Manual release of the GC handle must be done when using this struct
struct MonoGCHandleData {
GCHandleIntPtr handle = { nullptr };
GCHandleIntPtr handle{ .value = nullptr };
gdmono::GCHandleType type = gdmono::GCHandleType::NIL;

_FORCE_INLINE_ bool is_released() const { return !handle.value; }
Expand Down
Loading
Loading