From 6e0c63b723cc81efcc82c2af778b26e507c71825 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 22 Jul 2025 09:27:05 -0700 Subject: Fix segfault when using -separate-debug-info with unsupported targets (#7777) * Initial plan * Fix segfault when using -separate-debug-info with unsupported targets Add validation to emit a diagnostic error when -separate-debug-info is used with targets other than SPIR-V binary. Previously, this would cause a segfault because the separate debug info logic is only implemented for SPIR-V targets. Changes: - Added new diagnostic error (ID 18) for unsupported separate debug info usage - Added validation in OptionsParser::_parse() to check target compatibility - Created test cases for HLSL and GLSL targets to verify the fix - Updated error message to clarify only SPIR-V binary targets are supported The fix prevents segfaults and provides clear feedback to users about target limitations for the -separate-debug-info option. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address feedback: fix segfault properly instead of preventing it Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --- .../command-line/separate-debug-info-unsupported-glsl.slang | 9 +++++++++ .../command-line/separate-debug-info-unsupported-target.slang | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/diagnostics/command-line/separate-debug-info-unsupported-glsl.slang create mode 100644 tests/diagnostics/command-line/separate-debug-info-unsupported-target.slang (limited to 'tests/diagnostics') diff --git a/tests/diagnostics/command-line/separate-debug-info-unsupported-glsl.slang b/tests/diagnostics/command-line/separate-debug-info-unsupported-glsl.slang new file mode 100644 index 000000000..d8c58245a --- /dev/null +++ b/tests/diagnostics/command-line/separate-debug-info-unsupported-glsl.slang @@ -0,0 +1,9 @@ +// separate-debug-info-unsupported-glsl.slang + +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):-target glsl -separate-debug-info -entry main -stage vertex + +// CHECK: warning 18: '-separate-debug-info' is not supported for target 'glsl' + +void main() +{ +} \ No newline at end of file diff --git a/tests/diagnostics/command-line/separate-debug-info-unsupported-target.slang b/tests/diagnostics/command-line/separate-debug-info-unsupported-target.slang new file mode 100644 index 000000000..da65ec0f8 --- /dev/null +++ b/tests/diagnostics/command-line/separate-debug-info-unsupported-target.slang @@ -0,0 +1,9 @@ +// separate-debug-info-unsupported-target.slang + +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):-target hlsl -separate-debug-info -entry main -stage vertex + +// CHECK: warning 18: '-separate-debug-info' is not supported for target 'hlsl' + +void main() +{ +} \ No newline at end of file -- cgit v1.2.3