From 5c5fd64175e44e486f8952c6b996a169d0f582d7 Mon Sep 17 00:00:00 2001 From: Nora Abi Akar <nora.abiakar@gmail.com> Date: Fri, 2 Jul 2021 10:25:14 +0300 Subject: [PATCH] Compile all arbor source files with `-fvisibility=hidden` (#1599) The visibility of symbols in the python shared library is set to 'hidden'. However, examining the dynamic symbol table of the generated `.so` file revealed that all the symbols of the static arbor libraries are still visible. This causes some issues on the Mac M1. To resolve, all source files are now compiled with `-fvisibility=hidden`. --- CMakeLists.txt | 8 ++++++++ mechanisms/generate_catalogue | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ecb0a47..94c6e21d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,10 +246,18 @@ else() set_arch_target(ARB_CXXOPT_ARCH ${ARB_ARCH}) set(ARB_CXX_FLAGS_TARGET_FULL ${ARB_CXX_FLAGS_TARGET} ${ARB_CXXOPT_ARCH}) endif() + +# Compile with `-fvisibility=hidden` to ensure that the symbols of the generated +# arbor static libraries are hidden from the dynamic symbol tables of any shared +# libraries that link against them. +list(APPEND ARB_CXX_FLAGS_TARGET_FULL + "$<$<BUILD_INTERFACE:$<COMPILE_LANGUAGE:CXX>>:-fvisibility=hidden>" + "$<$<BUILD_INTERFACE:$<COMPILE_LANGUAGE:CUDA>>:-Xcompiler=-fvisibility=hidden>") separate_arguments(ARB_CXX_FLAGS_TARGET_FULL) target_compile_options(arbor-private-deps INTERFACE ${ARB_CXX_FLAGS_TARGET_FULL}) target_compile_options(arborenv-private-deps INTERFACE ${ARB_CXX_FLAGS_TARGET_FULL}) +target_compile_options(arborio-private-deps INTERFACE ${ARB_CXX_FLAGS_TARGET_FULL}) # Profiling and test features #----------------------------- diff --git a/mechanisms/generate_catalogue b/mechanisms/generate_catalogue index 8e8df375..8f4b46bb 100755 --- a/mechanisms/generate_catalogue +++ b/mechanisms/generate_catalogue @@ -120,7 +120,7 @@ const mechanism_catalogue& global_${catalogue}_catalogue() { #ifdef STANDALONE extern "C" { - const void* get_catalogue() { + [[gnu::visibility("default")]] const void* get_catalogue() { static auto cat = arb::build_${catalogue}_catalogue(); return (void*)&cat; } -- GitLab