@@ -513,7 +513,14 @@ endif()
513513if (WIN32 )
514514 target_compile_options (${HS_EXT_NAME} PRIVATE ${HS_CMAKE_COMMON_FLAGS} )
515515else ()
516- target_compile_options (${HS_EXT_NAME} PRIVATE -fPIC -D_GLIBCXX_USE_CXX11_ABI=1 )
516+ # Hide all symbols by default to prevent conflicts with other C++ extensions
517+ # (e.g., numpy, scipy, sklearn) that may use the same C++ runtime symbols
518+ target_compile_options (${HS_EXT_NAME} PRIVATE
519+ -fPIC
520+ -D_GLIBCXX_USE_CXX11_ABI=1
521+ -fvisibility=hidden
522+ -fvisibility-inlines-hidden
523+ )
517524 target_link_options (${HS_EXT_NAME} PRIVATE -O0 )
518525endif ()
519526
@@ -523,6 +530,7 @@ if("$ENV{AUDITWHEEL_PLAT}" MATCHES "musllinux")
523530 target_link_options (${HS_EXT_NAME} PRIVATE
524531 -Wl,-s
525532 -Wl,--gc-sections
533+ -Wl,--exclude-libs,ALL
526534 -static-libgcc
527535 -Wl,--whole-archive
528536 -l:libstdc++.a
@@ -541,12 +549,16 @@ elseif(NOT WIN32)
541549 -Wl,--no-as-needed
542550 -Wl,--copy-dt-needed-entries
543551 -Wl,--no-allow-shlib-undefined
552+ -Wl,--exclude-libs,ALL
544553 )
545554 target_link_libraries (${HS_EXT_NAME} PRIVATE ${HS_LIBS} )
546555 target_link_libraries (${HS_EXT_NAME} PRIVATE -Wl,--push-state -Wl,-Bstatic -lstdc++ -Wl,--pop-state )
547556 else ()
548- # Other Linux platforms
549- target_link_options (${HS_EXT_NAME} PRIVATE -Wl,--no-as-needed )
557+ # Other Linux platforms (local dev, CI without auditwheel)
558+ target_link_options (${HS_EXT_NAME} PRIVATE
559+ -Wl,--no-as-needed
560+ -Wl,--exclude-libs,ALL
561+ )
550562 target_link_libraries (${HS_EXT_NAME} PRIVATE ${HS_LIBS} )
551563 target_link_libraries (${HS_EXT_NAME} PRIVATE stdc++ )
552564 endif ()
0 commit comments