From 7e93e8164c74f61b61ea66f215304abdf453965b Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 2 Jun 2021 13:44:04 -0400 Subject: Downstream compiler location fix. (#1866) * #include an absolute path didn't work - because paths were taken to always be relative. * Move logic to determine how to load a downstream shared library to DownstreamCompilerUtil::loadSharedLibrary. Handle if the given path is directory or a file. * Improve comment. * Special handling for a downstream compiler loading SharedLibrary detection - take into account filename may be different. * Handle cases if path is set but paths can't be determined. * Fix typo. Co-authored-by: T. Foley --- source/compiler-core/slang-dxc-compiler.cpp | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'source/compiler-core/slang-dxc-compiler.cpp') diff --git a/source/compiler-core/slang-dxc-compiler.cpp b/source/compiler-core/slang-dxc-compiler.cpp index 0b46bd09e..f5db290b1 100644 --- a/source/compiler-core/slang-dxc-compiler.cpp +++ b/source/compiler-core/slang-dxc-compiler.cpp @@ -397,30 +397,9 @@ SlangResult DXCDownstreamCompiler::disassemble(SlangCompileTarget sourceBlobTarg { ComPtr library; - // If the user supplies a path to their preferred version of DXC - // we just use this. - if (path.getLength() != 0) - { - // We *assume* path is the path to d3dcompiler. - ComPtr dxil; - - // Attempt to load dxil from same path that d3dcompiler is located - const String parentPath = Path::getParentDirectory(path); - if (parentPath.getLength()) - { - String dxilPath = Path::combine(parentPath, "dxil"); - // Try to load dxil along this path first - // If it fails - then DXC may load from a different place and thats ok. - loader->loadSharedLibrary(dxilPath.getBuffer(), dxil.writeRef()); - } - - SLANG_RETURN_ON_FAIL(loader->loadSharedLibrary(path.getBuffer(), library.writeRef())); - } - else - { - SLANG_RETURN_ON_FAIL(loader->loadSharedLibrary("dxcompiler", library.writeRef())); - } - + const char* dependentNames[] = {"dxil", nullptr } ; + SLANG_RETURN_ON_FAIL(DownstreamCompilerUtil::loadSharedLibrary(path, loader, dependentNames, "dxcompiler", library)); + SLANG_ASSERT(library); if (!library) { -- cgit v1.2.3