feat: hide non-exported symbols on Unix

This commit is contained in:
Sebastian Ullrich 2021-09-17 17:51:49 +02:00
parent ea244c298c
commit d506b8a5ed
2 changed files with 4 additions and 1 deletions

View file

@ -308,6 +308,9 @@ endif()
if(NOT(${CMAKE_SYSTEM_NAME} MATCHES "Windows"))
# export symbols for the interpreter (done via `LEAN_EXPORT` for Windows)
set(LEAN_DYN_EXE_LINKER_FLAGS "${LEAN_DYN_EXE_LINKER_FLAGS} -rdynamic")
# hide all other symbols
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
set(LEANC_EXTRA_FLAGS "${LEANC_EXTRA_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
endif()
# On Windows, add bcrypt for random number generation

View file

@ -49,7 +49,7 @@ extern "C" {
#ifdef _WIN32
#define LEAN_EXPORT __declspec(dllexport)
#else
#define LEAN_EXPORT
#define LEAN_EXPORT __attribute__((visibility("default")))
#endif
// We set `LEAN_EXPORTING` when compiling objects of libleanshared, but not when including this header in any other context.