2
0
Эх сурвалжийг харах

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.
Chris B 2 жил өмнө
parent
commit
4d7b69c81d

+ 11 - 13
include/dxc/Support/dxcapi.use.h

@@ -31,28 +31,26 @@ protected:
 
 #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;