From fcc6897016b818cd1603613fe64fba8706599156 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Fri, 14 Jun 2019 10:30:46 -0700 Subject: [PATCH] [BUILD] Enable more visible symbols by default (#3365) --- CMakeLists.txt | 10 ++++++++-- Jenkinsfile | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d064c959f17b..a140c597a89f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ tvm_option(USE_SGX "Build with SGX" OFF) tvm_option(USE_RTTI "Build with RTTI" ON) tvm_option(USE_MSVC_MT "Build with MT" OFF) tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF) +tvm_option(HIDE_PRIVATE_SYMBOLS "Compile with -fvisibility=hidden." OFF) # 3rdparty libraries tvm_option(DLPACK_PATH "Path to DLPACK" "3rdparty/dlpack/include") @@ -97,8 +98,13 @@ else(MSVC) set(CMAKE_C_FLAGS "-O0 -g -Wall -fPIC ${CMAKE_C_FLAGS} -rdynamic") set(CMAKE_CXX_FLAGS "-O0 -g -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS} -rdynamic") else() - set(CMAKE_C_FLAGS "-O2 -Wall -fPIC -fvisibility=hidden ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -fvisibility=hidden -std=c++11 ${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") + if (HIDE_PRIVATE_SYMBOLS) + message("Hide private symbols...") + set(CMAKE_C_FLAGS "-fvisibility=hidden ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-fvisibility=hidden ${CMAKE_CXX_FLAGS}") + endif(HIDE_PRIVATE_SYMBOLS) endif () if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) diff --git a/Jenkinsfile b/Jenkinsfile index bdbb3ecb6427..c50297402ddb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -183,6 +183,7 @@ stage('Build') { echo set\\(NNPACK_PATH /NNPACK/build/\\) >> config.cmake echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake + echo set\\(HIDE_PRIVATE_SYMBOLS ON\\) >> config.cmake """ make(ci_cpu, 'build', '-j4') pack_lib('cpu', tvm_lib)