Skip to content

Commit

Permalink
Fix AppVeyor Linux tests failing loading dxil.so (#5024)
Browse files Browse the repository at this point in the history
`dlopen` and `dlsym` do not set `errno` on failure, instead errors are provided in string format via `dlerror()`. Since we don't currently have a good way to propagate string errors we don't propagate them through our API, but this does correct code that otherwise was returning success on failing `dlopen`/`dlsym` calls.

(cherry picked from commit 4d7b69c)
  • Loading branch information
llvm-beanz authored and pow2clk committed Feb 24, 2023
1 parent 6d3574a commit 0795b94
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions include/dxc/Support/dxcapi.use.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,26 @@ class DxcDllSupport {

#ifdef _WIN32
m_dll = LoadLibraryA(dllName);
#else
m_dll = ::dlopen(dllName, RTLD_LAZY);
#endif

if (m_dll == nullptr) return HRESULT_FROM_WIN32(GetLastError());

#ifdef _WIN32
m_createFn = (DxcCreateInstanceProc)GetProcAddress(m_dll, fnName);
#else
m_createFn = (DxcCreateInstanceProc)::dlsym(m_dll, fnName);
#endif


if (m_createFn == nullptr) {
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
#ifdef _WIN32
FreeLibrary(m_dll);
m_dll = nullptr;
return hr;
}
#else
m_dll = ::dlopen(dllName, RTLD_LAZY);
if (m_dll == nullptr) return E_FAIL;
m_createFn = (DxcCreateInstanceProc)::dlsym(m_dll, fnName);

if (m_createFn == nullptr) {
::dlclose(m_dll);
#endif
m_dll = nullptr;
return hr;
return E_FAIL;
}
#endif

// Only basic functions used to avoid requiring additional headers.
m_createFn2 = nullptr;
Expand Down

0 comments on commit 0795b94

Please sign in to comment.