@@ -13,6 +13,11 @@ include(GNUInstallDirs)
1313
1414set (CMAKE_CXX_STANDARD 17)
1515
16+ # Preset function visibility to hidden, API functions
17+ # are annotated explicitly to use 'default' visibility.
18+ set (CMAKE_CXX_VISIBILITY_PRESET "hidden" )
19+ set (CMAKE_C_VISIBILITY_PRESET "hidden" )
20+
1621find_package (LLVM REQUIRED CONFIG)
1722
1823message (STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} " )
@@ -316,7 +321,6 @@ endif()
316321message (STATUS "LLVM target link libraries: ${llvm_libs} " )
317322target_link_libraries (llvmlite ${llvm_libs} )
318323
319-
320324# -flto and --exclude-libs allow removal of unused parts of LLVM
321325# TODO: these options are just set, they should really be tested for
322326# suitability.
@@ -328,6 +332,12 @@ if(UNIX AND NOT APPLE)
328332 if (LLVMLITE_FLTO)
329333 STRING (APPEND FORCED_LINK_FLAGS " -flto" )
330334 endif ()
335+ if (NOT LLVMLITE_SHARED)
336+ # If LLVM is statically linked, we specify -Bsymbolic to prevent
337+ # that LLVM symbols can be interposed upon by previously
338+ # loaded shared objects that export LLVM symbols.
339+ STRING (APPEND FORCED_LINK_FLAGS " -Wl,-Bsymbolic" )
340+ endif ()
331341 set_property (TARGET llvmlite APPEND_STRING PROPERTY LINK_FLAGS
332342 "${FORCED_LINK_FLAGS} " )
333343elseif (APPLE )
0 commit comments