From 7326c154d4997e5db977d2404fcac2c4f2b44e78 Mon Sep 17 00:00:00 2001 From: duckdoom5 Date: Wed, 22 Jan 2025 19:01:09 +0100 Subject: [PATCH] Add additional debug configuration I've added the DebugOpt config for a better debugging experience. This version enables some optimizations and uses `_ITERATOR_DEBUG_LEVEL=0` to remove many of the slowdowns of traditional debugging while still keeping the debuggability of the app intact. It uses the release versions of llvm and crt. --- Directory.Build.props | 1 + build/Helpers.lua | 8 +++++++- build/LLVM.lua | 18 ++++++++++++++++++ build/build.sh | 2 +- build/llvm/LLVM.lua | 3 +++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index c3a4d2e5..1f59b4e8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,6 +4,7 @@ $(MSBuildThisFileDirectory) x86;x64 + Debug;DebugOpt;Release false true MIT diff --git a/build/Helpers.lua b/build/Helpers.lua index 468d383e..0625bfef 100644 --- a/build/Helpers.lua +++ b/build/Helpers.lua @@ -36,6 +36,7 @@ newoption { allowed = { { "Release", "Release" }, { "Debug", "Debug" }, + { "DebugOpt", "DebugOpt" }, } } @@ -104,10 +105,15 @@ function SetupNativeProject() filter { "configurations:Debug" } defines { "DEBUG" } + + filter { "configurations:DebugOpt" } + defines { "DEBUG", "_ITERATOR_DEBUG_LEVEL=0" } + optimize "Debug" + runtime "Release" filter { "configurations:Release" } defines { "NDEBUG" } - optimize "On" + optimize "Full" -- Compiler-specific options diff --git a/build/LLVM.lua b/build/LLVM.lua index 9ac89c54..bf17b2f2 100644 --- a/build/LLVM.lua +++ b/build/LLVM.lua @@ -38,6 +38,18 @@ function SetupLLVMIncludes() local c = filter() if LLVMDirPerConfiguration then + filter { "configurations:DebugOpt" } + includedirs + { + path.join(LLVMRootDirRelease, "include"), + path.join(LLVMRootDirRelease, "llvm/include"), + path.join(LLVMRootDirRelease, "lld/include"), + path.join(LLVMRootDirRelease, "clang/include"), + path.join(LLVMRootDirRelease, "clang/lib"), + path.join(LLVMRootDirRelease, "build/include"), + path.join(LLVMRootDirRelease, "build/clang/include"), + } + filter { "configurations:Debug" } includedirs { @@ -121,6 +133,9 @@ function SetupLLVMLibs() filter {} if LLVMDirPerConfiguration then + filter { "configurations:DebugOpt" } + libdirs { path.join(LLVMRootDirRelease, "build/lib") } + filter { "configurations:Debug" } libdirs { path.join(LLVMRootDirDebug, "build/lib") } @@ -129,6 +144,9 @@ function SetupLLVMLibs() else local LLVMBuildDir = get_llvm_build_dir() libdirs { path.join(LLVMBuildDir, "lib") } + + filter { "configurations:DebugOpt", "toolset:msc*" } + libdirs { path.join(LLVMBuildDir, "RelWithDebInfo/lib") } filter { "configurations:Debug", "toolset:msc*" } libdirs { path.join(LLVMBuildDir, "Debug/lib") } diff --git a/build/build.sh b/build/build.sh index d53f103e..c6ff907a 100755 --- a/build/build.sh +++ b/build/build.sh @@ -3,7 +3,7 @@ set -e builddir=$(cd "$(dirname "$0")"; pwd) platform=x64 vs=vs2022 -configuration=Release +configuration=DebugOpt build_only=false ci=false target_framework= diff --git a/build/llvm/LLVM.lua b/build/llvm/LLVM.lua index 0a08c061..69447136 100644 --- a/build/llvm/LLVM.lua +++ b/build/llvm/LLVM.lua @@ -137,6 +137,9 @@ function get_llvm_package_name(rev, conf, arch) end function get_llvm_configuration_name(debug) + if string.find(_OPTIONS["configuration"], "DebugOpt") then + return os.istarget("windows") and "RelWithDebInfo" or "Release" + end if string.find(_OPTIONS["configuration"], "Debug") then return "Debug" end