fix dlopen bug

This commit is contained in:
jianghui58 2021-07-10 09:07:23 +08:00
parent 69a0120187
commit 7a08494b57
4 changed files with 11 additions and 4 deletions

View File

@ -588,6 +588,7 @@ build_lite()
COMPILE_MINDDATA_LITE="off"
CMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}
CMAKE_TOOLCHAIN_NAME=${TOOLCHAIN_NAME}
CMAKE_BUILD_TYPE=${LITE_BUILD_TYPE}
else
CMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake
ANDROID_NATIVE_API_LEVEL="19"

View File

@ -57,7 +57,7 @@ int DynamicLibraryLoader::Open(const char *lib_path) {
#endif
if (handler_ == nullptr) {
LOG_ERROR("open path failed");
LOG_ERROR("handler is nullptr.");
return RET_ERROR;
}
return RET_OK;

View File

@ -77,15 +77,16 @@ schema::MetaGraphT *Converter::Convert(const std::unique_ptr<converter::Flags> &
}
// load plugin
static std::vector<std::shared_ptr<DynamicLibraryLoader>> dl_loaders;
if (!flag->pluginsPath.empty()) {
DynamicLibraryLoader dynamic_library_loader{};
for (auto &path : flag->pluginsPath) {
auto status = dynamic_library_loader.Open(path.c_str());
auto dl_loader = std::make_shared<DynamicLibraryLoader>();
auto status = dl_loader->Open(path.c_str());
if (status != RET_OK) {
MS_LOG(ERROR) << "open dynamic library failed. " << path;
return nullptr;
}
dynamic_library_loader.Close();
dl_loaders.emplace_back(dl_loader);
}
}

View File

@ -15,3 +15,8 @@ add_library(mslite_converter_plugin SHARED ${REG_SRC})
target_link_libraries(mslite_converter_plugin mindspore::glog)
add_dependencies(mslite_converter_plugin fbs_src)
add_dependencies(mslite_converter_plugin fbs_inner_src)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND (NOT WIN32))
add_custom_command(TARGET mslite_converter_plugin POST_BUILD COMMAND strip
${CMAKE_CURRENT_BINARY_DIR}/libmslite_converter_plugin.so)
endif()