From 24c3b47010036d67e6d777d9aa37ae3ef8146254 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 5 Feb 2025 18:28:30 +0000 Subject: [PATCH] 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. --- src/kernel/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index f30ccce388a..244f0098fdf 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -83,9 +83,25 @@ add_library(bitcoinkernel $ $ ) + +# 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 $<$:bcrypt> $