Skip to content

Commit 0795b94

Browse files
llvm-beanzGreg Roth
authored andcommitted
Fix AppVeyor Linux tests failing loading dxil.so (#5024)
`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)
1 parent 6d3574a commit 0795b94

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

include/dxc/Support/dxcapi.use.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,26 @@ class DxcDllSupport {
3131

3232
#ifdef _WIN32
3333
m_dll = LoadLibraryA(dllName);
34-
#else
35-
m_dll = ::dlopen(dllName, RTLD_LAZY);
36-
#endif
37-
3834
if (m_dll == nullptr) return HRESULT_FROM_WIN32(GetLastError());
39-
40-
#ifdef _WIN32
4135
m_createFn = (DxcCreateInstanceProc)GetProcAddress(m_dll, fnName);
42-
#else
43-
m_createFn = (DxcCreateInstanceProc)::dlsym(m_dll, fnName);
44-
#endif
45-
36+
4637
if (m_createFn == nullptr) {
4738
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
48-
#ifdef _WIN32
4939
FreeLibrary(m_dll);
40+
m_dll = nullptr;
41+
return hr;
42+
}
5043
#else
44+
m_dll = ::dlopen(dllName, RTLD_LAZY);
45+
if (m_dll == nullptr) return E_FAIL;
46+
m_createFn = (DxcCreateInstanceProc)::dlsym(m_dll, fnName);
47+
48+
if (m_createFn == nullptr) {
5149
::dlclose(m_dll);
52-
#endif
5350
m_dll = nullptr;
54-
return hr;
51+
return E_FAIL;
5552
}
53+
#endif
5654

5755
// Only basic functions used to avoid requiring additional headers.
5856
m_createFn2 = nullptr;

0 commit comments

Comments
 (0)