build: add kernel-specific warnings

In some cases, we'll want to be more aggressive or care about different things
when building the kernel. In this case, a warning is added for symbols which
may be duplicated between the kernel and downstream users.

This warning was introduced in clang 21, which is not yet the minimum
supported compiler version. REDUCE_EXPORTS needs to be ON to trigger it.
This commit is contained in:
Cory Fields 2025-02-05 18:28:30 +00:00 committed by sedited
parent 64294c8909
commit 24c3b47010
No known key found for this signature in database
GPG Key ID: 9B79B45691DB4173

View File

@ -83,9 +83,25 @@ add_library(bitcoinkernel
$<TARGET_OBJECTS:leveldb>
$<TARGET_OBJECTS:crc32c>
)
# Compiler warnings that apply only to the kernel and its dependencies.
# These can be more strict and/or warnings that only apply to shared
# libs.
add_library(kernel_warn_interface INTERFACE)
if(NOT MSVC)
try_append_cxx_flags("-Wunique-object-duplication" TARGET kernel_warn_interface SKIP_LINK)
endif()
# Also manually apply the warnings to the kernel's internal dependencies
target_link_libraries(bitcoin_clientversion PRIVATE kernel_warn_interface)
target_link_libraries(bitcoin_crypto PRIVATE kernel_warn_interface)
target_link_libraries(leveldb PRIVATE kernel_warn_interface)
target_link_libraries(crc32c PRIVATE kernel_warn_interface)
target_link_libraries(bitcoinkernel
PRIVATE
core_interface
kernel_warn_interface
secp256k1_objs
$<$<PLATFORM_ID:Windows>:bcrypt>
$<TARGET_NAME_IF_EXISTS:USDT::headers>