From dc99cbb02a3b7e00b1ea4ef4b50a4b74da3cf69f Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 17 Oct 2025 21:35:17 +1100 Subject: [PATCH 1/2] Added support for generating PDB symbols with MinGW clang and lld. Also don't disable sibling/tail call optimisation when symbols are enabled. This is hurting our release builds since they're built with symbols. --- docs/source/initialsetup/compilingmame.rst | 6 ++++++ makefile | 5 +++++ scripts/genie.lua | 12 ++++++++++-- scripts/src/main.lua | 2 +- scripts/toolchain.lua | 6 ++++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/source/initialsetup/compilingmame.rst b/docs/source/initialsetup/compilingmame.rst index 1e467fff5520f..56b5339f28b8b 100644 --- a/docs/source/initialsetup/compilingmame.rst +++ b/docs/source/initialsetup/compilingmame.rst @@ -656,6 +656,12 @@ SYMLEVEL similar compilers, **1** includes line number tables and external variables, **2** also includes local variables, and **3** also includes macro definitions. +PDB_SYMBOLS + Set to **1** to generate CodeView format symbols in separate PDB files, + allowing source-level debugging using Microsoft Visual Studio or WinDbg. + This option is only supported for MinGW builds using the clang compiler and + the LLVM linker (lld). This option only takes effect if the **SYMBOLS** + option is set to a non-zero value. ARCHOPTS Additional command-line options to pass to the compiler and linker. This is useful for supplying code generation or ABI options, for example to enable diff --git a/makefile b/makefile index fbd91c978a592..8dc372b205b39 100644 --- a/makefile +++ b/makefile @@ -54,6 +54,7 @@ # OPTIMIZE = 3 # SYMBOLS = 1 # SYMLEVEL = 2 +# PDB_SYMBOLS = 1 # MAP = 1 # PROFILE = 1 # ARCHOPTS = @@ -627,6 +628,10 @@ ifdef SYMLEVEL PARAMS += --SYMLEVEL='$(SYMLEVEL)' endif +ifdef PDB_SYMBOLS +PARAMS += --PDB_SYMBOLS='$(PDB_SYMBOLS)' +endif + ifdef PROFILER PARAMS += --PROFILER='$(PROFILER)' endif diff --git a/scripts/genie.lua b/scripts/genie.lua index 4b3025b5ec83d..9cb7ee2a4df13 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -212,6 +212,11 @@ newoption { description = "Symbols level.", } +newoption { + trigger = "PDB_SYMBOLS", + description = "Generate CodeView PDB symbols.", +} + newoption { trigger = "PROFILER", description = "Include the internal profiler.", @@ -718,9 +723,12 @@ local version = str_to_version(_OPTIONS["gcc_version"]) if _OPTIONS["SYMBOLS"]~=nil and _OPTIONS["SYMBOLS"]~="0" then buildoptions { "-g" .. _OPTIONS["SYMLEVEL"], - "-fno-omit-frame-pointer", - "-fno-optimize-sibling-calls", } + if _OPTIONS["PDB_SYMBOLS"]~=nil and _OPTIONS["PDB_SYMBOLS"]~=0 then + buildoptions { + "-gcodeview", + } + end end --# we need to disable some additional implicit optimizations for profiling diff --git a/scripts/src/main.lua b/scripts/src/main.lua index 8cd4609a6f574..3d6b6dbf47234 100644 --- a/scripts/src/main.lua +++ b/scripts/src/main.lua @@ -47,7 +47,7 @@ end "Symbols", -- always include minimum symbols for executables } - if _OPTIONS["SYMBOLS"] then + if _OPTIONS["SYMBOLS"]~=nil and _OPTIONS["SYMBOLS"]~=0 and (_OPTIONS["PDB_SYMBOLS"]==nil or _OPTIONS["PDB_SYMBOLS"]==0) then local llvm_obdjump = false local objdump_ver = backtick('objdump --version') if string.match(objdump_ver, 'LLVM version ') then diff --git a/scripts/toolchain.lua b/scripts/toolchain.lua index 59e8bdb504a2e..6e8c96605b354 100644 --- a/scripts/toolchain.lua +++ b/scripts/toolchain.lua @@ -604,6 +604,12 @@ function toolchain(_buildDir, _subDir) end function strip() + if _OPTIONS["PDB_SYMBOLS"]~=nil and _OPTIONS["PDB_SYMBOLS"]~=0 then + linkoptions { + "-Wl,--pdb=$(subst .exe,.pdb,$(TARGET))", + } + end + if _OPTIONS["STRIP_SYMBOLS"]~="1" then return true end From c2600a743ef40ae664d678779f3d3d4a3f0beab3 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 20 Oct 2025 00:11:34 +1100 Subject: [PATCH 2/2] docs: Note that other tools can load clang/lld PDB symbols. --- docs/source/initialsetup/compilingmame.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/source/initialsetup/compilingmame.rst b/docs/source/initialsetup/compilingmame.rst index 56b5339f28b8b..1dc59b8a6df5c 100644 --- a/docs/source/initialsetup/compilingmame.rst +++ b/docs/source/initialsetup/compilingmame.rst @@ -659,9 +659,11 @@ SYMLEVEL PDB_SYMBOLS Set to **1** to generate CodeView format symbols in separate PDB files, allowing source-level debugging using Microsoft Visual Studio or WinDbg. - This option is only supported for MinGW builds using the clang compiler and - the LLVM linker (lld). This option only takes effect if the **SYMBOLS** - option is set to a non-zero value. + It can also be used with other tools that can load symbols from PDB files, + e.g. the Intel VTune and AMD µProf performance analysis tools. This option + is only supported for MinGW builds using the clang compiler and the LLVM + linker (lld). This option only takes effect if the **SYMBOLS** option is + set to a non-zero value. ARCHOPTS Additional command-line options to pass to the compiler and linker. This is useful for supplying code generation or ABI options, for example to enable