Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Revert "Don't allow to load library linking to another folder" (#26141)

Ilya Lavrenovfe624f1134f6
diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt
index efdae4b2683..6b5cf4b7a64 100644
--- a/src/common/util/CMakeLists.txt
+++ b/src/common/util/CMakeLists.txt
@@ -41,10 +41,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::p
if (WIN32)
target_link_libraries(${TARGET_NAME} PRIVATE Shlwapi)
endif()
-
-if(LINUX)
- target_link_libraries(${TARGET_NAME} PRIVATE stdc++fs)
-endif()
target_include_directories(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${UTIL_INCLUDE_DIR}>)
ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
diff --git a/src/common/util/include/openvino/util/file_util.hpp b/src/common/util/include/openvino/util/file_util.hpp
index 7b28bda704a..88b9110abec 100644
--- a/src/common/util/include/openvino/util/file_util.hpp
+++ b/src/common/util/include/openvino/util/file_util.hpp
@@ -12,20 +12,6 @@
#include "openvino/util/util.hpp"
-#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
-# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L) && (_MSC_VER >= 1913))
-# if __has_include(<filesystem>)
-# include <filesystem>
-namespace fs = std::filesystem;
-# endif
-# else
-# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
-# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM
-# include <experimental/filesystem>
-namespace fs = std::experimental::filesystem;
-# endif
-#endif
-
namespace ov {
namespace util {
@@ -411,12 +397,5 @@ inline std::basic_string<C> make_path(const std::basic_string<C>& folder, const
return folder + ov::util::FileTraits<C>::file_separator + file;
}
-/**
- * @brief If the library path is symlink & the symlink file location is not in the real file folder, return true. Others
- * return false.
- * @param path - Library file path to check
- * @return Bool value
- */
-bool is_symlink_in_different_path(std::string library_path);
} // namespace util
} // namespace ov
diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp
index 8fa9e5e06b1..2846355e9ae 100644
--- a/src/common/util/src/file_util.cpp
+++ b/src/common/util/src/file_util.cpp
@@ -704,14 +704,3 @@ const char* ov::util::trim_file_name(const char* const fname) {
#endif
return fname_trim_ptr;
}
-
-bool ov::util::is_symlink_in_different_path(std::string library_path) {
-#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
- if (fs::is_symlink(library_path) && ov::util::get_absolute_file_path(ov::util::get_directory(library_path)) !=
- ov::util::get_directory(ov::util::get_absolute_file_path(library_path)))
- return true;
- return false;
-#else
- return false;
-#endif
-}
diff --git a/src/core/dev_api/openvino/core/so_extension.hpp b/src/core/dev_api/openvino/core/so_extension.hpp
index 5db9879dc1c..931344b5fc4 100644
--- a/src/core/dev_api/openvino/core/so_extension.hpp
+++ b/src/core/dev_api/openvino/core/so_extension.hpp
@@ -3,7 +3,6 @@
//
#pragma once
-#include "openvino/core/except.hpp"
#include "openvino/core/extension.hpp"
#include "openvino/core/visibility.hpp"
#include "openvino/util/file_util.hpp"
@@ -41,8 +40,6 @@ inline std::string resolve_extension_path(const std::string& path) {
}
inline std::vector<Extension::Ptr> load_extensions(const std::string& path) {
- OPENVINO_ASSERT(!ov::util::is_symlink_in_different_path(path),
- "Cannot load extension with symlink path: \"" + path + "\".");
const std::string resolved_path = resolve_extension_path(path);
auto so = ov::util::load_shared_object(resolved_path.c_str());
using CreateFunction = void(std::vector<Extension::Ptr>&);
diff --git a/src/frontends/common/src/manager.cpp b/src/frontends/common/src/manager.cpp
index 30bfc0a46c2..0a31f9a2c42 100644
--- a/src/frontends/common/src/manager.cpp
+++ b/src/frontends/common/src/manager.cpp
@@ -106,8 +106,6 @@ public:
}
void register_front_end(const std::string& name, const std::string& library_path) {
- OPENVINO_ASSERT(!ov::util::is_symlink_in_different_path(library_path),
- "Cannot register plugin with symlink path: \"" + library_path + "\".");
auto lib_path = ov::util::from_file_path(ov::util::get_plugin_path(library_path));
PluginInfo plugin;
plugin.m_file_path = lib_path;
diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp
index f8fcf26b006..237c246ab38 100644
--- a/src/inference/src/dev/core_impl.cpp
+++ b/src/inference/src/dev/core_impl.cpp
@@ -1189,8 +1189,7 @@ void ov::CoreImpl::register_plugin(const std::string& plugin,
if (device_name.find('.') != std::string::npos) {
OPENVINO_THROW("Device name must not contain dot '.' symbol");
}
- OPENVINO_ASSERT(!ov::util::is_symlink_in_different_path(plugin),
- "Cannot registe plugin with symlink path: \"" + plugin + "\".");
+
PluginDescriptor desc{ov::util::get_plugin_path(plugin), properties};
register_plugin_in_registry_unsafe(device_name, desc);
}
diff --git a/src/inference/tests/functional/ov_core_test.cpp b/src/inference/tests/functional/ov_core_test.cpp
index acba5cc4912..26eb38e3fd1 100644
--- a/src/inference/tests/functional/ov_core_test.cpp
+++ b/src/inference/tests/functional/ov_core_test.cpp
@@ -95,22 +95,4 @@ TEST(CoreBaseTest, LoadOVFolderOverCWPathPluginXML) {
remove_plugin_xml(ov_file_path);
}
-# if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
-TEST(CoreBaseTest, AddExtensionwithSymlinkInDiffPlace) {
- std::string openvino_template_extension =
- ov::util::make_plugin_library_name<char>(ov::test::utils::getExecutableDirectory(),
- std::string("openvino_template_extension") + OV_BUILD_POSTFIX);
-
- // Symlink file & the real file doesn't locale in the diff place. Will throw
- fs::create_directory("test_link");
- std::string symlink_for_extension_copy_file = "test_link/symlink_for_extension_copy_file";
-
- fs::create_symlink(openvino_template_extension, symlink_for_extension_copy_file);
- ov::Core core;
- EXPECT_NO_THROW(core.add_extension(openvino_template_extension));
- EXPECT_THROW(core.add_extension(symlink_for_extension_copy_file), std::runtime_error);
-
- ASSERT_TRUE(fs::remove_all("test_link"));
-}
-# endif
#endif