summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-compiler.cpp22
-rw-r--r--source/slang/slang-diagnostic-defs.h6
-rw-r--r--source/slang/slang-options.cpp34
3 files changed, 54 insertions, 8 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index e31918d58..b13624aac 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -2289,14 +2289,20 @@ SlangResult EndToEndCompileRequest::_maybeWriteDebugArtifact(
if (targetProgram->getOptionSet().getBoolOption(CompilerOptionName::EmitSeparateDebug))
{
const auto dbgArtifact = _getSeparateDbgArtifact(artifact);
- // The artifact's name may have been set to the debug build id hash, use
- // it as the filename if it exists.
- String dbgPath = dbgArtifact->getName();
- if (dbgPath.getLength() == 0)
- dbgPath = _getDebugSpvPath(path);
- else
- dbgPath.append(".dbg.spv");
- return _maybeWriteArtifact(dbgPath, dbgArtifact);
+ // Check if a debug artifact was actually created (only for SPIR-V targets)
+ if (dbgArtifact)
+ {
+ // The artifact's name may have been set to the debug build id hash, use
+ // it as the filename if it exists.
+ String dbgPath = dbgArtifact->getName();
+ if (dbgPath.getLength() == 0)
+ dbgPath = _getDebugSpvPath(path);
+ else
+ dbgPath.append(".dbg.spv");
+ return _maybeWriteArtifact(dbgPath, dbgArtifact);
+ }
+ // If no debug artifact exists (e.g., for non-SPIR-V targets), just silently succeed
+ // The warning about unsupported targets is already issued during option parsing
}
return SLANG_OK;
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index 3dafda3be..bab9a0fb8 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -138,6 +138,12 @@ DIAGNOSTIC(14, Error, unknownProfile, "unknown profile '$0'")
DIAGNOSTIC(15, Error, unknownStage, "unknown stage '$0'")
DIAGNOSTIC(16, Error, unknownPassThroughTarget, "unknown pass-through target '$0'")
DIAGNOSTIC(17, Error, unknownCommandLineOption, "unknown command-line option '$0'")
+DIAGNOSTIC(
+ 18,
+ Warning,
+ separateDebugInfoUnsupportedForTarget,
+ "'-separate-debug-info' is not supported for target '$0'. This option is only supported for "
+ "SPIR-V binary targets.")
DIAGNOSTIC(19, Error, unknownSourceLanguage, "unknown source language '$0'")
DIAGNOSTIC(
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 8fd9d0507..0ada33697 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -3948,6 +3948,40 @@ SlangResult OptionsParser::_parse(int argc, char const* const* argv)
applySettingsToDiagnosticSink(m_requestImpl->getSink(), m_sink, linkage->m_optionSet);
+ // Warn about separate debug info being used with unsupported targets
+ if (linkage->m_optionSet.getBoolOption(CompilerOptionName::EmitSeparateDebug))
+ {
+ // Check all targets to see if any use separate debug info with an unsupported target
+ for (const auto& rawTarget : m_rawTargets)
+ {
+ if (rawTarget.format != CodeGenTarget::SPIRV)
+ {
+ // Get the target name for the warning message
+ UnownedStringSlice targetName =
+ TypeTextUtil::getCompileTargetName(asExternal(rawTarget.format));
+ m_sink->diagnose(
+ SourceLoc(),
+ Diagnostics::separateDebugInfoUnsupportedForTarget,
+ targetName);
+ }
+ }
+
+ // Also check the default target if no explicit targets were specified
+ if (m_rawTargets.getCount() == 0)
+ {
+ if (m_defaultTarget.format != CodeGenTarget::SPIRV)
+ {
+ // Get the target name for the warning message
+ UnownedStringSlice targetName =
+ TypeTextUtil::getCompileTargetName(asExternal(m_defaultTarget.format));
+ m_sink->diagnose(
+ SourceLoc(),
+ Diagnostics::separateDebugInfoUnsupportedForTarget,
+ targetName);
+ }
+ }
+ }
+
return (m_sink->getErrorCount() == 0) ? SLANG_OK : SLANG_FAIL;
}