Skip to content

Commit fa3fefa

Browse files
umar456pradeep
authored andcommitted
Set the symbol visibility to hidden
Setting the visibility to hidden to improve link times and reduce the binary size. This reduced the libafcpu.so size from 41MB to 36MB
1 parent 6597199 commit fa3fefa

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ configure_package_config_file(
333333
# TODO(umar): Disable for now. Causing issues with builds on windows.
334334
#export(PACKAGE ArrayFire)
335335

336+
# Unset the visibility to avoid setting policy commands for older versions of
337+
# CMake for examples and tests.
338+
unset(CMAKE_CXX_VISIBILITY_PRESET)
339+
336340
include(CTest)
337341

338342
# Handle depricated BUILD_TEST variable if found.

CMakeModules/InternalUtils.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ macro(arrayfire_set_cmake_default_variables)
6868

6969
set(CMAKE_CXX_STANDARD 11)
7070
set(CMAKE_CXX_EXTENSIONS OFF)
71+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
7172

7273
# Set a default build type if none was specified
7374
if(NOT CMAKE_BUILD_TYPE)

src/backend/cuda/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ endfunction()
115115

116116
arrayfire_get_cuda_cxx_flags(cuda_cxx_flags)
117117
if(NOT MSVC)
118-
set(cuda_cxx_flags "${cuda_cxx_flags} -Xcompiler -fPIC")
118+
set(cuda_cxx_flags "${cuda_cxx_flags} -Xcompiler -fPIC -Xcompiler=${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY}hidden")
119119
endif()
120120

121121
if(AF_WITH_NONFREE AND CMAKE_VERSION VERSION_LESS "3.7")

0 commit comments

Comments
 (0)