summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2024-08-06 11:28:41 +0300
committerthegeorg <[email protected]>2024-08-06 12:56:38 +0300
commitdb9505d66cb73d62c7beaff1980941cfb1aec0ea (patch)
tree70d2c9e73730f2552cf1f345c5e96f037092800a
parentde4d7efd8871b850e3ea79164d7661e2299836b7 (diff)
Define -D_DEBUG and -DNDEBUG disregarding target platform
I have found out that Windows build omits`Y_ASSERT` statements when compiled in `--build=relwithdebinfo` The reason is simple: most people know about `ifndef NDEBUG`, yet nobody checks `ifdef _DEBUG` (codesearch queries over util [for NDEBUG](https://a.yandex-team.ru/search?search=NDEBUG%2C%255Eutil%2Cw%2Carcadia%2C%2C200) and [for _DEBUG](https://a.yandex-team.ru/search?search=_DEBUG%2C%255Eutil%2Cw%2Carcadia%2C%2C200)). This PR makes these two values consistent with each other disregarding the target platform. https://stackoverflow.com/questions/2290509/debug-vs-ndebug/2290616#2290616 https://learn.microsoft.com/en-us/visualstudio/debugger/enabling-debug-features-in-visual-cpp-d-debug 7bab996a4a9e0db5e11a92d804733f50200b745c
-rw-r--r--build/conf/compilers/msvc_compiler.conf6
-rw-r--r--build/ymake.core.conf21
-rwxr-xr-xbuild/ymake_conf.py12
3 files changed, 23 insertions, 16 deletions
diff --git a/build/conf/compilers/msvc_compiler.conf b/build/conf/compilers/msvc_compiler.conf
index 9550b9effb5..c6cf77de2f0 100644
--- a/build/conf/compilers/msvc_compiler.conf
+++ b/build/conf/compilers/msvc_compiler.conf
@@ -28,10 +28,8 @@ when ($IDE_MSVS == "yes") {
DEBUG_INFO_FLAGS=/Zi /FS
}
-# For the flags regarding runtime library selection, see
-# https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
-CFLAGS_DEBUG = /Od /Ob0 /Oi /D_DEBUG /MTd
-CFLAGS_RELEASE = /O2 /Ob2 /Oi /DNDEBUG /MT
+CFLAGS_DEBUG = /Od /Ob0 /Oi
+CFLAGS_RELEASE = /O2 /Ob2 /Oi
MASMFLAGS=
_MASM_IO=/nologo /c /Fo${output;suf=${OBJECT_SUF}:SRC} ${input:SRC}
diff --git a/build/ymake.core.conf b/build/ymake.core.conf
index 8b864929bfe..469b5ac0cd4 100644
--- a/build/ymake.core.conf
+++ b/build/ymake.core.conf
@@ -4842,6 +4842,27 @@ when ($CLANG && $DEBUGINFO_LINES_ONLY == "yes" && $NO_DEBUGINFO != "yes") {
DEBUG_INFO_FLAGS=-gline-tables-only
}
+# NB: Assertions under sanitizers are disabled as they cause
+# a couple _relocation out of range_ problems plus an
+# ICE when building contrib/libs/hyperscan/runtime_avx512.
+when ($BUILD_TYPE == "release" || $BUILD_TYPE == "minsizerel" || $BUILD_TYPE == "valgrind-release" || $BUILD_TYPE == "profile" || $BUILD_TYPE == "gprof" || $BUILD_TYPE == "debugnoasserts" || $SANITIZER_TYPE != "") {
+ CFLAGS += -DNDEBUG
+ when ($OS_WINDOWS) {
+ # FIXME: defining _DEBUG on Linux gives more relation problems and breaks certain tests
+ CFLAGS += -U_DEBUG
+ # For the flags regarding runtime library selection, see
+ # https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
+ CFLAGS += /MT
+ }
+}
+otherwise {
+ CFLAGS += -UNDEBUG
+ when ($OS_WINDOWS) {
+ CFLAGS += -D_DEBUG
+ CFLAGS += /MTd
+ }
+}
+
# TODO: configurable tar and touch
PACK_TGZ=${cwd:ARCADIA_BUILD_ROOT} tar -czf ${rootrel:OUTPUT} ${rootrel:INPUT} ${hide;kv:"p AR"} ${hide;kv:"pc light-red"}
diff --git a/build/ymake_conf.py b/build/ymake_conf.py
index 1db5338b428..bdb3c7e8d92 100755
--- a/build/ymake_conf.py
+++ b/build/ymake_conf.py
@@ -609,9 +609,6 @@ class Build(object):
if self.is_size_optimized:
emit('_BUILD_SIZE_OPTIMIZED', 'yes')
- if self.with_ndebug:
- emit('_BUILD_WITH_NDEBUG', 'yes')
-
toolchain_type, compiler_type, linker_type = Compilers[self.tc.type]
toolchain = toolchain_type(self.tc, self)
compiler = compiler_type(self.tc, self)
@@ -664,10 +661,6 @@ class Build(object):
return bool(sanitizer) and not is_negative_str(sanitizer)
@property
- def with_ndebug(self):
- return self.build_type in ('release', 'minsizerel', 'valgrind-release', 'profile', 'gprof', 'debugnoasserts')
-
- @property
def is_valgrind(self):
return self.build_type == 'valgrind' or self.build_type == 'valgrind-release'
@@ -1598,11 +1591,6 @@ class GnuCompiler(Compiler):
else:
self.optimize = '-O3'
- if self.build.with_ndebug:
- self.c_defines.append('-DNDEBUG')
- else:
- self.c_defines.append('-UNDEBUG')
-
if self.build.profiler_type in (Profiler.Generic, Profiler.GProf):
self.c_foptions.append('-fno-omit-frame-pointer')