diff --git a/PCbuild/build.bat b/PCbuild/build.bat
index 602357048867d6..5d5bddd1f62e9e 100644
--- a/PCbuild/build.bat
+++ b/PCbuild/build.bat
@@ -106,6 +106,7 @@ if "%~1"=="-E" (set IncludeExternals=false) & shift & goto CheckOpts
if "%~1"=="--no-ctypes" (set IncludeCTypes=false) & shift & goto CheckOpts
if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts
if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
+if "%~1"=="--stackref-debug" (set StackRefDebug=true) & shift & goto CheckOpts
if "%IncludeExternals%"=="" set IncludeExternals=true
if "%IncludeCTypes%"=="" set IncludeCTypes=true
@@ -202,6 +203,7 @@ echo on
/p:PyStats=%PyStats%^
/p:UseTailCallInterp=%UseTailCallInterp%^
/p:DisableRemoteDebug=%DisableRemoteDebug%^
+ /p:StackRefDebug=%StackRefDebug%^
%1 %2 %3 %4 %5 %6 %7 %8 %9
@echo off
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index d7544d3a9fb122..d6d810d90f404a 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -110,6 +110,7 @@
_Py_TAIL_CALL_INTERP=1;%(PreprocessorDefinitions)
HAVE_COMPUTED_GOTOS;%(PreprocessorDefinitions)
Py_REMOTE_DEBUG;%(PreprocessorDefinitions)
+ Py_STACKREF_DEBUG;%(PreprocessorDefinitions)
version.lib;ws2_32.lib;pathcch.lib;bcrypt.lib;%(AdditionalDependencies)