Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCons: Cleanup DEBUG, _DEBUG and NDEBUG defines #66303

Merged
merged 1 commit into from
Sep 23, 2022
Merged
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
4 changes: 3 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ if env_base["target"] == "debug":
# DEV_ENABLED enables *engine developer* code which should only be compiled for those
# working on the engine itself.
env_base.Append(CPPDEFINES=["DEV_ENABLED"])
else:
# Disable assert() for production targets (only used in thirdparty code).
env_base.Append(CPPDEFINES=["NDEBUG"])

# SCons speed optimization controlled by the `fast_unsafe` option, which provide
# more than 10 s speed up for incremental rebuilds.
Expand Down Expand Up @@ -669,7 +672,6 @@ if selected_platform in platform_list:
print(" Use `tools=no target=release` to build a release export template.")
Exit(255)
suffix += ".opt"
env.Append(CPPDEFINES=["NDEBUG"])
elif env["target"] == "release_debug":
if env["tools"]:
suffix += ".opt.tools"
Expand Down
4 changes: 0 additions & 4 deletions core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ double OS::get_unix_time() const {
return 0;
}

void OS::debug_break() {
// something
}

void OS::_set_logger(CompositeLogger *p_logger) {
if (_logger) {
memdelete(_logger);
Expand Down
2 changes: 0 additions & 2 deletions core/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ class OS {

virtual Error move_to_trash(const String &p_path) { return FAILED; }

virtual void debug_break();

virtual int get_exit_code() const;
// `set_exit_code` should only be used from `SceneTree` (or from a similar
// level, e.g. from the `Main::start` if leaving without creating a `SceneTree`).
Expand Down
8 changes: 0 additions & 8 deletions core/os/pool_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include "core/os/os.h"
#include "core/string/print_string.h"

#include <assert.h>

#define COMPACT_CHUNK(m_entry, m_to_pos) \
do { \
void *_dst = &((unsigned char *)pool)[m_to_pos]; \
Expand Down Expand Up @@ -169,11 +167,6 @@ bool PoolAllocator::find_entry_index(EntryIndicesPos *p_map_pos, const Entry *p_

PoolAllocator::ID PoolAllocator::alloc(int p_size) {
ERR_FAIL_COND_V(p_size < 1, POOL_ALLOCATOR_INVALID_ID);
#ifdef DEBUG_ENABLED
if (p_size > free_mem) {
OS::get_singleton()->debug_break();
}
#endif
ERR_FAIL_COND_V(p_size > free_mem, POOL_ALLOCATOR_INVALID_ID);

mt_lock();
Expand Down Expand Up @@ -482,7 +475,6 @@ void *PoolAllocator::get(ID p_mem) {
ERR_FAIL_COND_V(!e, nullptr);
}
if (e->lock == 0) {
//assert(0);
mt_unlock();
ERR_PRINT("e->lock == 0");
return nullptr;
Expand Down
5 changes: 0 additions & 5 deletions drivers/unix/os_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include <sys/sysctl.h>
#endif

#include <assert.h>
#include <dlfcn.h>
#include <errno.h>
#include <poll.h>
Expand Down Expand Up @@ -104,10 +103,6 @@ static void _setup_clock() {
}
#endif

void OS_Unix::debug_break() {
assert(false);
}

static void handle_interrupt(int sig) {
if (!EngineDebugger::is_active()) {
return;
Expand Down
1 change: 0 additions & 1 deletion drivers/unix/os_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class OS_Unix : public OS {

virtual int get_processor_count() const override;

virtual void debug_break() override;
virtual void initialize_debugging() override;

virtual String get_executable_path() const override;
Expand Down
1 change: 0 additions & 1 deletion misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
Expand Down
2 changes: 1 addition & 1 deletion modules/denoise/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ env_oidn.Append(
"__STDC_LIMIT_MACROS",
"DISABLE_VERBOSE",
"MKLDNN_ENABLE_CONCURRENT_EXEC",
"NDEBUG",
]
)
env_oidn.AppendUnique(CPPDEFINES=["NDEBUG"]) # No assert() even in debug builds.

env_thirdparty = env_oidn.Clone()
env_thirdparty.disable_warnings()
Expand Down
3 changes: 2 additions & 1 deletion modules/raycast/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ if env["builtin_embree"]:
thirdparty_sources = [thirdparty_dir + file for file in embree_src]

env_raycast.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "include"])
env_raycast.Append(CPPDEFINES=["EMBREE_TARGET_SSE2", "EMBREE_LOWEST_ISA", "TASKING_INTERNAL", "NDEBUG"])
env_raycast.Append(CPPDEFINES=["EMBREE_TARGET_SSE2", "EMBREE_LOWEST_ISA", "TASKING_INTERNAL"])
env_raycast.AppendUnique(CPPDEFINES=["NDEBUG"]) # No assert() even in debug builds.

if not env.msvc:
if env["arch"] == "x86_64":
Expand Down
5 changes: 1 addition & 4 deletions platform/android/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,9 @@ def configure(env):
env.Append(CCFLAGS=[opt])
elif env["optimize"] == "size": # optimize for size
env.Append(CCFLAGS=["-Oz"])
env.Append(CPPDEFINES=["NDEBUG"])
elif env["target"] == "debug":
env.Append(LINKFLAGS=["-O0"])
env.Append(CCFLAGS=["-O0", "-g", "-fno-limit-debug-info"])
env.Append(CPPDEFINES=["_DEBUG"])
env.Append(CPPFLAGS=["-UNDEBUG"])
env.Append(CCFLAGS=["-O0", "-g"])

# LTO

Expand Down
5 changes: 2 additions & 3 deletions platform/ios/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def configure(env):
## Build type

if env["target"].startswith("release"):
env.Append(CPPDEFINES=["NDEBUG", ("NS_BLOCK_ASSERTIONS", 1)])
env.Append(CPPDEFINES=[("NS_BLOCK_ASSERTIONS", 1)])
if env["optimize"] == "speed": # optimize for speed (default)
# `-O2` is more friendly to debuggers than `-O3`, leading to better crash backtraces
# when using `target=release_debug`.
Expand All @@ -67,8 +67,7 @@ def configure(env):
env.Append(LINKFLAGS=["-Os"])

elif env["target"] == "debug":
env.Append(CCFLAGS=["-gdwarf-2", "-O0"])
env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1)])
env.Append(CCFLAGS=["-g", "-O0"])

## LTO

Expand Down
1 change: 0 additions & 1 deletion platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ def configure_msvc(env, vcvars_msvc_config):

elif env["target"] == "debug":
env.AppendUnique(CCFLAGS=["/Zi", "/FS", "/Od", "/EHsc"])
# Allow big objects. Only needed for debug, see MinGW branch for rationale.
env.Append(LINKFLAGS=["/DEBUG"])

if env["debug_symbols"]:
Expand Down