From 0d16228ae22fa2e1a00e62dc099eea08da7717fe Mon Sep 17 00:00:00 2001 From: jarcherNV Date: Fri, 6 Jun 2025 14:30:06 -0700 Subject: Add command line option for separate debug info (#7178) * Add command line option for separate debug info Add command line arg -separate-debug-info which, if provided, produces both a .spv and a .dbg.spv file. The .dbg.spv file contains full debug info and the .spv file has all debug info stripped out. Also add a DebugBuildIdentifier instruction to store a unique hash in both the output files, so they can be more easily matched together. A matching API is provided to allow using the Slang API to retrieve a base and debug SPIRV as well as the debug build identifier string. --- source/slang/slang-options.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index c269b10c4..68f538508 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -820,7 +820,11 @@ void initCommandOptions(CommandOptions& options) "-verify-debug-serial-ir", nullptr, "Verify IR in the front-end."}, - {OptionKind::DumpModule, "-dump-module", nullptr, "Disassemble and print the module IR."}}; + {OptionKind::DumpModule, "-dump-module", nullptr, "Disassemble and print the module IR."}, + {OptionKind::EmitSeparateDebug, + "-separate-debug-info", + nullptr, + "Emit debug data to a separate file, and strip it from the main output file."}}; _addOptions(makeConstArrayView(debuggingOpts), options); /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Experimental !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ @@ -3077,6 +3081,14 @@ SlangResult OptionsParser::_parse(int argc, char const* const* argv) } + break; + } + case OptionKind::EmitSeparateDebug: + { + // This will emit a separate debug file, containing all debug info in + // a .dbg.spv file. The main output SPIRV will have all debug info stripped. + m_compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_MAXIMAL); + linkage->m_optionSet.set(OptionKind::EmitSeparateDebug, true); break; } default: -- cgit v1.2.3