diff options
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-check.cpp | 35 | ||||
| -rwxr-xr-x | source/slang/slang-compiler.cpp | 6 | ||||
| -rwxr-xr-x | source/slang/slang-compiler.h | 1 | ||||
| -rw-r--r-- | source/slang/slang-diagnostic-defs.h | 9 |
4 files changed, 48 insertions, 3 deletions
diff --git a/source/slang/slang-check.cpp b/source/slang/slang-check.cpp index e97cb0b61..bf004817b 100644 --- a/source/slang/slang-check.cpp +++ b/source/slang/slang-check.cpp @@ -42,7 +42,7 @@ namespace Slang } else { - m_sink->diagnose(SourceLoc(), Diagnostics::failedToLoadDynamicLibrary, path); + m_sink->diagnose(SourceLoc(), Diagnostics::noteFailedToLoadDynamicLibrary, path); } } return res; @@ -133,8 +133,37 @@ namespace Slang { m_downstreamCompilerSet->remove(SlangPassThrough(type)); - SinkSharedLibraryLoader loader(m_sharedLibraryLoader, sink); - locator(m_downstreamCompilerPaths[int(type)], &loader, m_downstreamCompilerSet); + // We want to be able to report a diagnostic to the user if a loader + // was unable to locate the desired downstream compiler, but we + // also need to deal with the fact that the locator might "probe" + // multiple possible library versions/names, and failing to load + // one library should not be taken as a hard error. + // + // The approach we use here is to first apply the `locator` directly + // with our `m_sharedLibraryLoader` and see if it succeeds. If + // it does, then we will move along. + // + if (SLANG_FAILED(locator(m_downstreamCompilerPaths[int(type)], m_sharedLibraryLoader, m_downstreamCompilerSet))) + { + // If the locator reported a failure the first time we invoked + // it, then we will invoke it against with a wrapper shared librar + // loader that reported library load failures to our diagnost `sink`. + // + // This means that in the case of failure the user will see a listing + // of all the libraries that the locator attempted to load but failed + // to find. The user will know that making one or more of these libraries + // available could fix the issue, but we cannot communicate precise + // information to them with this approach (e.g., the difference between + // "I need all of these libraries" vs. "I need at least one of these + // libraries"). + // + if( sink ) + { + sink->diagnose(SourceLoc(), Diagnostics::failedToLoadDownstreamCompiler, type); + } + SinkSharedLibraryLoader loader(m_sharedLibraryLoader, sink); + locator(m_downstreamCompilerPaths[int(type)], &loader, m_downstreamCompilerSet); + } DownstreamCompilerUtil::updateDefaults(m_downstreamCompilerSet); } diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 71582f60d..37a79e6c4 100755 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -105,6 +105,12 @@ namespace Slang } } + void printDiagnosticArg(StringBuilder& sb, PassThroughMode val) + { + sb << TypeTextUtil::getPassThroughName(SlangPassThrough(val)); + } + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!! CompileResult !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SlangResult CompileResult::getSharedLibrary(ComPtr<ISlangSharedLibrary>& outSharedLibrary) diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 4ced85ec8..cbd62d2bc 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -845,6 +845,7 @@ namespace Slang NVRTC = SLANG_PASS_THROUGH_NVRTC, CountOf = SLANG_PASS_THROUGH_COUNT_OF, }; + void printDiagnosticArg(StringBuilder& sb, PassThroughMode val); class SourceFile; diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index c268fd241..044ce0830 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -118,6 +118,15 @@ DIAGNOSTIC( 86, Error, unableToCreateModuleContainer, "unable to create modul DIAGNOSTIC( 87, Error, unableToSetDefaultDownstreamCompiler, "unable to set default downstream compiler for source language '%0' to '%1'") + +// +// 001xx - Downstream Compilers +// + +DIAGNOSTIC( 100, Error, failedToLoadDownstreamCompiler, "failed to load downstream compiler '$0'") +DIAGNOSTIC(99999, Note, noteFailedToLoadDynamicLibrary, "failed to load dynamic library '$0'") + + // // 1xxxx - Lexical analysis // |
