diff options
| author | Anders Leino <aleino@nvidia.com> | 2025-01-31 19:27:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-31 09:27:20 -0800 |
| commit | a026df756096ca580ca9d19019abd08fa5d2c015 (patch) | |
| tree | c11335fc0834aac4ccfc783b76a539956683b97e /source/slang/slang.cpp | |
| parent | eebe849075c21d163739cbc5e976e7b5b6837e7f (diff) | |
Respect per-target debug options (#6193)
* Base compiler options for targets on target-specific compiler options
Before this change, the target compiler options were based on the linkage-wide compiler
options, which where later again inherited from (basically a no-op).
With this change, the target-specific compiler options are added first, and then
the linkage-wide comnpiler options are inherited from.
* Remove debug instructions if target-specific setting is NONE
This helps to address #6092.
* Make sure the linkage debug info level is sufficient for each target
This closes #6092.
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 21944e4f3..ee0aa4c14 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -842,6 +842,16 @@ Session::createSession(slang::SessionDesc const& inDesc, slang::ISession** outSe } } + // If any target requires debug info, then we will need to enable debug info when lowering to + // target-agnostic IR. The target-agnostic IR will only include debug info if the linkage IR + // options specify that it should, so make sure the linkage debug info level is greater than or + // equal to that of any target. + DebugInfoLevel linkageDebugInfoLevel = linkage->m_optionSet.getDebugInfoLevel(); + for (auto target : linkage->targets) + linkageDebugInfoLevel = + Math::Max(linkageDebugInfoLevel, target->getOptionSet().getDebugInfoLevel()); + linkage->m_optionSet.set(CompilerOptionName::DebugInformation, linkageDebugInfoLevel); + *outSession = asExternal(linkage.detach()); return SLANG_OK; } @@ -1337,7 +1347,10 @@ void Linkage::addTarget(slang::TargetDesc const& desc) optionSet.setProfile(Profile(desc.profile)); optionSet.set(CompilerOptionName::LineDirectiveMode, LineDirectiveMode(desc.lineDirectiveMode)); optionSet.set(CompilerOptionName::GLSLForceScalarLayout, desc.forceGLSLScalarBufferLayout); - optionSet.load(desc.compilerOptionEntryCount, desc.compilerOptionEntries); + + CompilerOptionSet targetOptions; + targetOptions.load(desc.compilerOptionEntryCount, desc.compilerOptionEntries); + optionSet.overrideWith(targetOptions); } #if 0 |
