From bb07cdc790ee1c1aa6efba5d9f964da67768a8a9 Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Mon, 15 Jun 2026 23:59:25 -0400 Subject: [PATCH] hiding all symbols from static library --- CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6a0c7ac..1fd03533 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,19 @@ if(PYEQL_ENABLE_EXT) include_directories(${IPHREEQC_INCLUDE_DIRS}) set(IPHREEQC_BUILD_DIR ${IPHREEQC_BASE}/build) add_subdirectory(${IPHREEQC_DIR} ${IPHREEQC_BUILD_DIR}) - set_target_properties(IPhreeqc PROPERTIES POSITION_INDEPENDENT_CODE ON) + + # Hide IPhreeqc's symbols when it is statically linked into _phreeqc.so. + # Upstream IPhreeqc does not build with -fvisibility=hidden, so without + # this every Phreeqc/IPhreeqcLib symbol gets re-exported from _phreeqc.so. + # That collides with phreeqpython's own copy of IPhreeqc (a different + # build), causing segfault once both modules are loaded in the same Python + # process. + # See https://linuxvox.com/blog/c-fvisibility-hidden-fvisibility-inlines-hidden/ + set_target_properties(IPhreeqc PROPERTIES + POSITION_INDEPENDENT_CODE ON + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON) # ------------------------------------------------------- # -------------------------------------------------------