diff --git a/sycl/include/sycl/detail/os_util.hpp b/sycl/include/sycl/detail/os_util.hpp index 8c4fc17913164..c77cdb4913c36 100644 --- a/sycl/include/sycl/detail/os_util.hpp +++ b/sycl/include/sycl/detail/os_util.hpp @@ -42,12 +42,22 @@ namespace detail { /// Groups the OS-dependent services. class __SYCL_EXPORT OSUtil { +#if !defined(__INTEL_PREVIEW_BREAKING_CHANGES) +#ifdef _WIN32 + // Access control is part of the mangling on Windows, have to preserve this + // for backward ABI compatibility. public: - /// Returns an absolute path to a directory where the object was found. - static std::string getCurrentDSODir(); - +#endif /// Returns a directory component of a path. static std::string getDirName(const char *Path); +#endif + +public: + /// Returns an absolute path to a directory where the object was found. +#if defined(__INTEL_PREVIEW_BREAKING_CHANGES) + __SYCL_DLL_LOCAL +#endif + static std::string getCurrentDSODir(); #ifdef __SYCL_RT_OS_WINDOWS static constexpr const char *DirSep = "\\"; diff --git a/sycl/source/detail/os_util.cpp b/sycl/source/detail/os_util.cpp index c8ee3b8f33c11..018ba97cff05c 100644 --- a/sycl/source/detail/os_util.cpp +++ b/sycl/source/detail/os_util.cpp @@ -69,6 +69,20 @@ bool procMapsAddressInRange(std::istream &Stream, uintptr_t Addr) { return Addr >= Start && Addr < End; } +#if defined(__INTEL_PREVIEW_BREAKING_CHANGES) +static std::string getDirName(const char *Path) +#else +std::string OSUtil::getDirName(const char *Path) +#endif +{ + std::string Tmp(Path); + // dirname(3) needs a writable C string: a null-terminator is written where a + // path should split. + size_t TruncatedSize = strlen(dirname(const_cast(Tmp.c_str()))); + Tmp.resize(TruncatedSize); + return Tmp; +} + /// Returns an absolute path to a directory where the object was found. std::string OSUtil::getCurrentDSODir() { // Examine /proc/self/maps and find where this function (getCurrendDSODir) @@ -130,21 +144,12 @@ std::string OSUtil::getCurrentDSODir() { char Path[PATH_MAX]; Stream.getline(Path, PATH_MAX - 1); Path[PATH_MAX - 1] = '\0'; - return OSUtil::getDirName(Path); + return getDirName(Path); } assert(false && "Unable to find the current function in /proc/self/maps"); return ""; } -std::string OSUtil::getDirName(const char *Path) { - std::string Tmp(Path); - // dirname(3) needs a writable C string: a null-terminator is written where a - // path should split. - size_t TruncatedSize = strlen(dirname(const_cast(Tmp.c_str()))); - Tmp.resize(TruncatedSize); - return Tmp; -} - #elif defined(__SYCL_RT_OS_WINDOWS) /// Returns an absolute path where the object was found. @@ -169,6 +174,7 @@ std::string OSUtil::getCurrentDSODir() { return Path; } +#if !defined(__INTEL_PREVIEW_BREAKING_CHANGES) std::string OSUtil::getDirName(const char *Path) { std::string Tmp(Path); // Remove trailing directory separators @@ -181,6 +187,7 @@ std::string OSUtil::getDirName(const char *Path) { // If no directory separator is present return initial path like dirname does return Tmp; } +#endif #elif defined(__SYCL_RT_OS_DARWIN) std::string OSUtil::getCurrentDSODir() { diff --git a/sycl/source/detail/persistent_device_code_cache.hpp b/sycl/source/detail/persistent_device_code_cache.hpp index d2038aaa65969..78441a251aa75 100644 --- a/sycl/source/detail/persistent_device_code_cache.hpp +++ b/sycl/source/detail/persistent_device_code_cache.hpp @@ -24,10 +24,6 @@ namespace sycl { inline namespace _V1 { namespace detail { -/* This is temporary solution until std::filesystem is available when SYCL RT - * is moved to c++17 standard*/ -std::string getDirName(const char *Path); - /* The class manages inter-process synchronization: * - Path passed to the constructor is appended with .lock and used as lock * file. diff --git a/sycl/tools/sycl-trace/collector.cpp b/sycl/tools/sycl-trace/collector.cpp index a58cc24cdfd24..79df84994923a 100644 --- a/sycl/tools/sycl-trace/collector.cpp +++ b/sycl/tools/sycl-trace/collector.cpp @@ -18,7 +18,7 @@ sycl::detail::SpinLock GlobalLock; bool HasZEPrinter = false; -std::string getCurrentDSODir() { +static std::string getCurrentDSODir() { auto CurrentFunc = reinterpret_cast(&getCurrentDSODir); Dl_info Info; int RetCode = dladdr(CurrentFunc, &Info); diff --git a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp index 455f271f1d2d4..d715676045975 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp @@ -65,7 +65,7 @@ static OSModuleHandle getOSModuleHandle(const void *VirtAddr) { // cribbed from sycl/source/detail/os_util.cpp /// Returns an absolute path where the object was found. -std::wstring getCurrentDSODir() { +static std::wstring getCurrentDSODir() { wchar_t Path[MAX_PATH]; auto Handle = getOSModuleHandle(reinterpret_cast(&getCurrentDSODir)); DWORD Ret = GetModuleFileName(