From e873f3ac0780c651a02f48404d14acc48408937e Mon Sep 17 00:00:00 2001 From: zhoufeng Date: Tue, 19 Apr 2022 19:50:23 +0800 Subject: [PATCH] set symbols of openssl static library to hidden Signed-off-by: zhoufeng --- cmake/external_libs/openssl.cmake | 1 + mindspore/ccsrc/CMakeLists.txt | 11 ++++------- tests/ut/cpp/CMakeLists.txt | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cmake/external_libs/openssl.cmake b/cmake/external_libs/openssl.cmake index 767c96e80f9..644284936c9 100644 --- a/cmake/external_libs/openssl.cmake +++ b/cmake/external_libs/openssl.cmake @@ -62,6 +62,7 @@ if(BUILD_LITE) add_library(mindspore::crypto ALIAS openssl::crypto) else() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR APPLE) + set(openssl_CFLAGS -fvisibility=hidden) mindspore_add_pkg(openssl VER 1.1.1k LIBS ssl crypto diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index 1648e9781f6..9a571338627 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -367,9 +367,10 @@ if(ENABLE_GPU) ${CUDA_PATH}/lib64/libcusolver.so ${CUDA_PATH}/lib64/libcufft.so ${CUDA_PATH}/lib64/libcusparse.so) - if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - target_link_libraries(mindspore_backend PRIVATE mindspore::crypto mindspore::ssl) - endif() +endif() + +if(NOT WIN32) + target_link_libraries(mindspore_backend PRIVATE mindspore::crypto mindspore::ssl) endif() if(ENABLE_DEBUGGER) @@ -536,10 +537,6 @@ if(USE_GLOG) target_link_libraries(_c_expression PRIVATE mindspore::glog) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - target_link_libraries(mindspore PUBLIC mindspore::crypto mindspore::ssl) -endif() - if(ENABLE_GPU) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") target_link_libraries(_c_expression PRIVATE mindspore::crypto mindspore::ssl) diff --git a/tests/ut/cpp/CMakeLists.txt b/tests/ut/cpp/CMakeLists.txt index 8ce571199b2..d156076b15e 100644 --- a/tests/ut/cpp/CMakeLists.txt +++ b/tests/ut/cpp/CMakeLists.txt @@ -268,7 +268,7 @@ endif() if(CMAKE_SYSTEM_NAME MATCHES "Linux") target_link_libraries(ut_tests PRIVATE mindspore::gtest mindspore::event mindspore::event_pthreads - mindspore::event_openssl ${PYTHON_LIBRARIES} pthread util dl) + mindspore::event_openssl mindspore::ssl mindspore::crypto ${PYTHON_LIBRARIES} pthread util dl) if(ENABLE_MINDDATA) target_link_libraries(ut_tests PRIVATE mindspore::sqlite mindspore::jpeg_turbo mindspore::turbojpeg mindspore::opencv_core mindspore::opencv_imgcodecs mindspore::opencv_imgproc mindspore::tinyxml2