diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-03-10 14:19:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-10 14:19:48 -0500 |
| commit | 3fea56ef77a33273bf5af6f432163b30c0a0e1dc (patch) | |
| tree | 446df8ddd73521b33e836facaea2c27ef84c47fe /source/slang/slang-options.cpp | |
| parent | e39893e8eb1a9411fca4e5f885456a27a770d3a2 (diff) | |
Support for PDB output from DXC (#2693)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Add versioning to CompileOptions for DownstreamCompiler so we can add new options without breaking binary interface.
* Add support for debug info format to API/command line processing.
* Small simplification.
* Add support for adding PDB output from a compilation.
* Use builtin offset of directly.
* Fix typo in debug.
Diffstat (limited to 'source/slang/slang-options.cpp')
| -rw-r--r-- | source/slang/slang-options.cpp | 74 |
1 files changed, 59 insertions, 15 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 5ac0d7663..60bc087de 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -1497,25 +1497,69 @@ struct OptionsParser compileRequest->setOptimizationLevel(level); } - // Note: unlike with `-O` above, we have to consider that other // options might have names that start with `-g` and so cannot // just detect it as a prefix. - else if( argValue == "-g" || argValue == "-g2" ) - { - compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_STANDARD); - } - else if( argValue == "-g0" ) - { - compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_NONE); - } - else if( argValue == "-g1" ) - { - compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_MINIMAL); - } - else if( argValue == "-g3" ) + else if (argValue.startsWith("-g")) { - compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_MAXIMAL); + if (argValue == toSlice("-g")) + { + // The default is standard + compileRequest->setDebugInfoLevel(SLANG_DEBUG_INFO_LEVEL_STANDARD); + } + else if (argValue.getLength() == 3 && argValue[2] >= '0' && argValue[2] <= '3') + { + // Extract the digit into an index + const Index levelIndex = argValue[2] - '0'; + SLANG_ASSERT(levelIndex >= 0 && levelIndex <= 3); + + // Map indices to enum values + const SlangDebugInfoLevel levels[] = + { + SLANG_DEBUG_INFO_LEVEL_NONE, + SLANG_DEBUG_INFO_LEVEL_MINIMAL, + SLANG_DEBUG_INFO_LEVEL_STANDARD, + SLANG_DEBUG_INFO_LEVEL_MAXIMAL + }; + + const auto level = levels[levelIndex]; + compileRequest->setDebugInfoLevel(level); + } + else + { + // Perhaps it's trying to specify a format + auto formatName = argValue.getUnownedSlice().tail(2); + + SlangDebugInfoFormat format; + if (SLANG_FAILED(TypeTextUtil::findDebugInfoFormat(formatName, format))) + { + List<String> debugOptions; + + debugOptions.add(toSlice("-g")); + + for (Int i = 0; i <= 3; ++i) + { + StringBuilder buf; + buf << toSlice("-g") << i; + debugOptions.add(buf); + } + + for (Index i = 0; i < SLANG_DEBUG_INFO_FORMAT_COUNT_OF; ++i) + { + StringBuilder buf; + buf << toSlice("-g") << TypeTextUtil::getDebugInfoFormatName(SlangDebugInfoFormat(i)); + debugOptions.add(buf); + } + + StringBuilder buf; + StringUtil::join(debugOptions, toSlice(", "), buf); + + sink->diagnose(arg.loc, Diagnostics::unknownDebugOption, buf); + return SLANG_FAIL; + } + + compileRequest->setDebugInfoFormat(format); + } } else if( argValue == "-default-image-format-unknown" ) { |
