mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-25 22:41:36 +02:00
Merge bitcoin/bitcoin#33077: kernel: create monolithic kernel static library
fdbade6f8d
kernel: create monolithic kernel static library (Cory Fields) Pull request description: Currently, consuming `libbitcoinkernel.a` requires all its dependency static libraries to be available. A switch to a monolithic variant, which contains object files from its dependencies, was discussed in the Kernel WG. The necessary preparations in the libsecp256k1 build scripts were completed in https://github.com/bitcoin-core/secp256k1/pull/1678, which are now available in this repository since https://github.com/bitcoin/bitcoin/pull/33036. The changes in this PR were picked from https://github.com/theuni/bitcoin/commits/static_kernel/, with an additional adjustment in `libbitcoinkernel.pc.in`. This PR can be tested as described in https://github.com/bitcoin/bitcoin/pull/30814#issue-2505698234. ACKs for top commit: TheCharlatan: ACKfdbade6f8d
stickies-v: tACKfdbade6f8d
Tree-SHA512: bd9e9dbb0b765bdcb162fb3f4ad3c4e01fe5fa0b7061f97d0bad64442b21db036cbe0e4341fd45d43a8862df76d62c9532ca8945f76423aca753c6b528f70873
This commit is contained in:
@@ -7,5 +7,4 @@ Name: @CLIENT_NAME@ kernel library
|
||||
Description: Experimental library for the @CLIENT_NAME@ validation engine.
|
||||
Version: @CLIENT_VERSION_STRING@
|
||||
Libs: -L${libdir} -lbitcoinkernel
|
||||
Libs.private: -L${libdir} @LIBS_PRIVATE@
|
||||
Cflags: -I${includedir}
|
||||
|
@@ -79,20 +79,23 @@ add_library(bitcoinkernel
|
||||
../validation.cpp
|
||||
../validationinterface.cpp
|
||||
../versionbits.cpp
|
||||
$<TARGET_OBJECTS:bitcoin_clientversion>
|
||||
$<TARGET_OBJECTS:bitcoin_crypto>
|
||||
$<TARGET_OBJECTS:leveldb>
|
||||
$<TARGET_OBJECTS:crc32c>
|
||||
)
|
||||
target_link_libraries(bitcoinkernel
|
||||
PRIVATE
|
||||
core_interface
|
||||
bitcoin_clientversion
|
||||
bitcoin_crypto
|
||||
leveldb
|
||||
secp256k1
|
||||
secp256k1_objs
|
||||
$<$<PLATFORM_ID:Windows>:bcrypt>
|
||||
$<TARGET_NAME_IF_EXISTS:USDT::headers>
|
||||
PUBLIC
|
||||
Boost::headers
|
||||
)
|
||||
|
||||
target_include_directories(bitcoinkernel PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/leveldb/include>)
|
||||
|
||||
# libbitcoinkernel requires default symbol visibility, explicitly
|
||||
# specify that here so that things still work even when user
|
||||
# configures with -DREDUCE_EXPORTS=ON
|
||||
@@ -107,34 +110,6 @@ set_target_properties(bitcoinkernel PROPERTIES
|
||||
add_custom_target(libbitcoinkernel)
|
||||
add_dependencies(libbitcoinkernel bitcoinkernel)
|
||||
|
||||
# When building the static library, install all static libraries the
|
||||
# bitcoinkernel depends on.
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
# Recursively get all the static libraries a target depends on and put them in libs_out
|
||||
function(get_target_static_link_libs target libs_out)
|
||||
get_target_property(linked_libraries ${target} LINK_LIBRARIES)
|
||||
foreach(dep ${linked_libraries})
|
||||
if(TARGET ${dep})
|
||||
add_dependencies(libbitcoinkernel ${dep})
|
||||
get_target_property(dep_type ${dep} TYPE)
|
||||
if(dep_type STREQUAL "STATIC_LIBRARY")
|
||||
list(APPEND ${libs_out} ${dep})
|
||||
get_target_static_link_libs(${dep} ${libs_out})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${libs_out} ${${libs_out}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(all_kernel_static_link_libs "")
|
||||
get_target_static_link_libs(bitcoinkernel all_kernel_static_link_libs)
|
||||
|
||||
install(TARGETS ${all_kernel_static_link_libs} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libbitcoinkernel)
|
||||
list(TRANSFORM all_kernel_static_link_libs PREPEND "-l")
|
||||
# LIBS_PRIVATE is substituted in the pkg-config file.
|
||||
list(JOIN all_kernel_static_link_libs " " LIBS_PRIVATE)
|
||||
endif()
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/libbitcoinkernel.pc.in ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc @ONLY)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/libbitcoinkernel.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT libbitcoinkernel)
|
||||
|
||||
|
Reference in New Issue
Block a user