Skip to content

Commit 0a65cb4

Browse files
author
Alexander Batashev
authored
[SYCL] Exclude current directory from DLL search path (#4741)
1 parent f8014f5 commit 0a65cb4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sycl/source/detail/windows_pi.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <CL/sycl/detail/defines.hpp>
1010

11+
#include <cassert>
1112
#include <string>
1213
#include <windows.h>
1314
#include <winreg.h>
@@ -26,8 +27,15 @@ void *loadOsLibrary(const std::string &PluginPath) {
2627
// NOTE: we restore the old mode to not affect user app behavior.
2728
//
2829
UINT SavedMode = SetErrorMode(SEM_FAILCRITICALERRORS);
30+
// Exclude current directory from DLL search path
31+
if (!SetDllDirectoryA("")) {
32+
assert(false && "Failed to update DLL search path");
33+
}
2934
auto Result = (void *)LoadLibraryA(PluginPath.c_str());
3035
(void)SetErrorMode(SavedMode);
36+
if (!SetDllDirectoryA(nullptr)) {
37+
assert(false && "Failed to restore DLL search path");
38+
}
3139

3240
return Result;
3341
}

0 commit comments

Comments
 (0)