Skip to content

Commit c9908ee

Browse files
committed
Disable optimizations for ASan instrumented builds
ASan instrumentation does not support the MSVC debug runtime, but still it does not make sense to enable optimizations for such builds, since they are not meant for production usage anyway, and although memory corruption issues are still found in optimized builds, the generated diagnostics are close to being useless, and apparently sometimes even outright wrong. Therefore, we disable all optimizations for ASan instrumented builds. We also introduce and use `ZEND_WIN32_NEVER_INLINE` for ASan enabled builds to avoid inlining of functions, so we get even better diagnostics.
1 parent 05f3cd2 commit c9908ee

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Zend/zend_portability.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ char *alloca();
289289
(_default)
290290
#endif
291291

292-
#if ZEND_DEBUG
292+
#if ZEND_DEBUG || defined(ZEND_WIN32_NEVER_INLINE)
293293
# define zend_always_inline inline
294294
# define zend_never_inline
295295
#else

win32/build/confutils.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,8 +3425,13 @@ function toolset_setup_build_mode()
34253425
ADD_FLAG("CFLAGS", "/Zi");
34263426
ADD_FLAG("LDFLAGS", "/incremental:no /debug /opt:ref,icf");
34273427
}
3428-
// Equivalent to Release_TSInline build -> best optimization
3429-
ADD_FLAG("CFLAGS", "/LD /MD /W3 /Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0");
3428+
ADD_FLAG("CFLAGS", "/LD /MD /W3");
3429+
if (PHP_SANITIZER == "yes" && CLANG_TOOLSET) {
3430+
ADD_FLAG("CFLAGS", "/Od /D NDebug /D NDEBUG /D ZEND_WIN32_NEVER_INLINE /D ZEND_DEBUG=0");
3431+
} else {
3432+
// Equivalent to Release_TSInline build -> best optimization
3433+
ADD_FLAG("CFLAGS", "/Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0");
3434+
}
34303435

34313436
// if you have VS.Net /GS hardens the binary against buffer overruns
34323437
// ADD_FLAG("CFLAGS", "/GS");

0 commit comments

Comments
 (0)