From 59937a869001fd797d172fcdd3edbe65b08a98b0 Mon Sep 17 00:00:00 2001 From: u130b8 <115743848+u130b8@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:59:31 +0300 Subject: [PATCH] comment the no_crt situation --- build.cmd | 2 +- progmgr/progmgr.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.cmd b/build.cmd index d72b240..578afa9 100644 --- a/build.cmd +++ b/build.cmd @@ -15,7 +15,7 @@ if "%1" == "debug" ( set CL=/MT /Od /Zi /RTC1 /Fdprogmgr.pdb /fsanitize=address /DUNICODE /DPROGMGR_GIT_HASH="%GIT_HASH%" set LINK=/DEBUG ) else ( - set CL=/O1 /GS- /DUNICODE /DNDEBUG /DPROGMGR_NO_CRT /DPROGMGR_GIT_HASH="%GIT_HASH%" + set CL=/O1 /GS- /DUNICODE /DNDEBUG /DPROGMGR_GIT_HASH="%GIT_HASH%" set LINK=/NODEFAULTLIB /OPT:REF /OPT:ICF ) diff --git a/progmgr/progmgr.c b/progmgr/progmgr.c index 705fac9..3eacc33 100644 --- a/progmgr/progmgr.c +++ b/progmgr/progmgr.c @@ -166,7 +166,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, return 0; } -#ifdef PROGMGR_NO_CRT +// NOTE(u130b8): We're compiling without the C runtime by default in Release builds. +// But in Debug builds, we need the C runtime, otherwise the address sanitizer and +// MSVC debug tools break because they use the wWinMainCRTStartup entrypoint to initialize. + +#ifdef NDEBUG #pragma function(memset) void *memset(char* dst, int value, size_t count) { while (count--) { *dst++ = value; }