Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion ffi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 17)

# Preset function visibility to hidden, API functions
# are annotated explicitly to use 'default' visibility.
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_C_VISIBILITY_PRESET "hidden")

find_package(LLVM REQUIRED CONFIG)

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
Expand Down Expand Up @@ -316,7 +321,6 @@ endif()
message(STATUS "LLVM target link libraries: ${llvm_libs}")
target_link_libraries(llvmlite ${llvm_libs})


# -flto and --exclude-libs allow removal of unused parts of LLVM
# TODO: these options are just set, they should really be tested for
# suitability.
Expand All @@ -328,6 +332,12 @@ if(UNIX AND NOT APPLE)
if (LLVMLITE_FLTO)
STRING(APPEND FORCED_LINK_FLAGS " -flto")
endif()
if(NOT LLVMLITE_SHARED)
# If LLVM is statically linked, we specify -Bsymbolic to prevent
# that LLVM symbols can be interposed upon by previously
# loaded shared objects that export LLVM symbols.
STRING(APPEND FORCED_LINK_FLAGS " -Wl,-Bsymbolic")
endif()
set_property(TARGET llvmlite APPEND_STRING PROPERTY LINK_FLAGS
"${FORCED_LINK_FLAGS}")
elseif(APPLE)
Expand Down
3 changes: 2 additions & 1 deletion ffi/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#if defined(HAVE_DECLSPEC_DLL)
#define API_EXPORT(RTYPE) __declspec(dllexport) RTYPE
#else
#define API_EXPORT(RTYPE) RTYPE
// Non-windows: use visibility attributes.
#define API_EXPORT(RTYPE) __attribute__((visibility("default"))) RTYPE
#endif

extern "C" {
Expand Down