From 5023b1f257b245cf3f6d75143808a5fdcb2058f6 Mon Sep 17 00:00:00 2001
From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Date: Tue, 6 Oct 2026 08:36:02 +0200
Subject: [PATCH] gh-157789: Use compiler option ``-Og`` in case of clang-cl
debug builds (GH-157791)
Use compiler option ``-Og`` in case of clang-cl debug builds on Windows to reduce stack usage.
(cherry picked from commit 9028df36bb9e2942b19164f6708f9cf8a55c5ce9)
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
---
.../next/Windows/2026-09-19-13-18-48.gh-issue-157789.o6-rmo.rst | 2 ++
PCbuild/pyproject-clangcl.props | 1 +
2 files changed, 3 insertions(+)
create mode 100644 Misc/NEWS.d/next/Windows/2026-09-19-13-18-48.gh-issue-157789.o6-rmo.rst
diff --git a/Misc/NEWS.d/next/Windows/2026-09-19-13-18-48.gh-issue-157789.o6-rmo.rst b/Misc/NEWS.d/next/Windows/2026-09-19-13-18-48.gh-issue-157789.o6-rmo.rst
new file mode 100644
index 000000000000000..f7f998b9eced36a
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2026-09-19-13-18-48.gh-issue-157789.o6-rmo.rst
@@ -0,0 +1,2 @@
+Use compiler option ``-Og`` in case of clang-cl debug builds on Windows to
+reduce stack usage. Patch by Chris Eibl.
diff --git a/PCbuild/pyproject-clangcl.props b/PCbuild/pyproject-clangcl.props
index 70a81ca7da306c3..14843f18823ca9b 100644
--- a/PCbuild/pyproject-clangcl.props
+++ b/PCbuild/pyproject-clangcl.props
@@ -50,6 +50,7 @@
-m32 %(AdditionalOptions)
-m64 %(AdditionalOptions)
-flto=thin %(AdditionalOptions)
+ %(AdditionalOptions) -Xclang -Og
-fprofile-instr-generate=$(_CLANG_PROFILE_PATH)$(TargetName)_%m.profraw %(AdditionalOptions)
-fprofile-instr-use=$(OutDir)instrumented\profdata.profdata -Wno-profile-instr-unprofiled %(AdditionalOptions)