From 2ccfdb582b646d9bda07f0f13b97cb8c37a452aa Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 10 Feb 2026 20:53:39 +0000 Subject: [PATCH] build: avoid exporting secp256k1 symbols Take advantage of the new secp256k1 option to avoid visibility attributes on API functions. While most users of a shared libsecp always want API functions exported so that they can actually be linked against, we always build it statically. When that static lib is linked into a (static or shared) libbitcoinkernel, by default its symbols end up exported there as well. As libsecp is an implementation detail of the kernel (and any future Core lib), its symbols should never be exported. --- cmake/secp256k1.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/secp256k1.cmake b/cmake/secp256k1.cmake index 5302f516d89..c82f361aba0 100644 --- a/cmake/secp256k1.cmake +++ b/cmake/secp256k1.cmake @@ -9,6 +9,11 @@ function(add_secp256k1 subdir) message("Configuring secp256k1 subtree...") set(BUILD_SHARED_LIBS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS OFF) + + # Unconditionally prevent secp's symbols from being exported by our libs + set(CMAKE_C_VISIBILITY_PRESET hidden) + set(SECP256K1_ENABLE_API_VISIBILITY_ATTRIBUTES OFF CACHE BOOL "" FORCE) + set(SECP256K1_ENABLE_MODULE_ECDH OFF CACHE BOOL "" FORCE) set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE) set(SECP256K1_ENABLE_MODULE_MUSIG ON CACHE BOOL "" FORCE)