From 701449c1657e04ac9ca248fbecfa2b1583a4ec95 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Wed, 30 Sep 2026 20:29:33 -0400 Subject: [PATCH 1/4] util: Make SocketError inline constexpr Declare SocketError as an inline variable so the header does not define a separate internal-linkage copy in every translation unit that includes it. Bitcoin Core's build now enables -Wunused-const-variable (bitcoin/bitcoin#36275), which with GCC warns about unused const variables defined in headers and fails the build with -Werror in every file that includes mp/util.h without using SocketError. Bitcoin Core made the same change to its own SocketError definition in bitcoin/bitcoin#35852. This change was written with Claude Opus 5.5 (1M context). --- include/mp/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mp/util.h b/include/mp/util.h index 30742014..adc7cfbb 100644 --- a/include/mp/util.h +++ b/include/mp/util.h @@ -293,7 +293,7 @@ using Stream = kj::Own; using ProcessId = int; using SocketId = int; -constexpr SocketId SocketError{-1}; +inline constexpr SocketId SocketError{-1}; //! Information about parent process passed to child process as a command-line //! argument. On unix this is the child socket fd number formatted as a string. From a8c64c7faa5511e77350c64a941f75fdcfa91b18 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Wed, 30 Sep 2026 20:31:04 -0400 Subject: [PATCH 2/4] ci: Enable -Wunused-const-variable in GCC jobs Bitcoin Core builds the libmultiprocess subtree with -Wunused-const-variable (bitcoin/bitcoin#36275). With GCC this warns about unused const variables defined in headers, so a header-level constexpr that is not inline breaks the Bitcoin Core build. Enable it in the GCC-based CI configs to catch this here first. Clang's -Wunused-const-variable does not warn about variables defined in headers, so it is not added to the clang configs. This change was written with Claude Opus 5.5 (1M context). --- ci/configs/default.bash | 2 +- ci/configs/gnu32.bash | 2 +- ci/configs/newdeps.bash | 2 +- ci/configs/olddeps.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/configs/default.bash b/ci/configs/default.bash index f36f4e49..acb38e15 100644 --- a/ci/configs/default.bash +++ b/ci/configs/default.bash @@ -1,5 +1,5 @@ CI_DESC="CI job using default libraries and tools, and running IWYU" CI_DIR=build-default -export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wextra-semi -Wmissing-noreturn -Wtrailing-whitespace" +export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wunused-const-variable -Wno-unused-parameter -Wextra-semi -Wmissing-noreturn -Wtrailing-whitespace" CMAKE_ARGS=(-DMP_ENABLE_IWYU=ON) BUILD_ARGS=(-k) diff --git a/ci/configs/gnu32.bash b/ci/configs/gnu32.bash index 04d78a24..3d63360f 100644 --- a/ci/configs/gnu32.bash +++ b/ci/configs/gnu32.bash @@ -6,6 +6,6 @@ NIX_ARGS=( --arg minimal true --arg crossPkgs 'import { crossSystem = { config = "i686-unknown-linux-gnu"; }; }' ) -export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter" +export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wunused-const-variable -Wno-unused-parameter" CMAKE_ARGS=(-G Ninja) BUILD_ARGS=(-k 0) diff --git a/ci/configs/newdeps.bash b/ci/configs/newdeps.bash index a86f9dee..c86a833d 100644 --- a/ci/configs/newdeps.bash +++ b/ci/configs/newdeps.bash @@ -1,6 +1,6 @@ CI_DESC="CI job using newest Cap'n Proto and cmake versions" CI_DIR=build-newdeps -export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-error=array-bounds" +export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wunused-const-variable -Wno-unused-parameter -Wno-error=array-bounds" CAPNP_CHECKOUT=master # This is the v1.x release branch NIX_ARGS=(--argstr capnprotoVersion "none" --argstr cmakeVersion "4.3.4") BUILD_ARGS=(-k) diff --git a/ci/configs/olddeps.bash b/ci/configs/olddeps.bash index 1d9ea6fc..81d084fc 100644 --- a/ci/configs/olddeps.bash +++ b/ci/configs/olddeps.bash @@ -2,7 +2,7 @@ CI_DESC="CI job using old Cap'n Proto and cmake versions" CI_DIR=build-olddeps # Pin olddeps to an older Nixpkgs channel, to be able to test an older GCC. CI_NIXPKGS_CHANNEL=nixos-25.05 -export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-error=array-bounds" +export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wunused-const-variable -Wno-unused-parameter -Wno-error=array-bounds" CAPNP_CHECKOUT=v0.9.2 # Use a checkout to compile it with the selected GCC NIX_ARGS=(--argstr capnprotoVersion "none" --argstr cmakeVersion "3.12.4" --argstr gccVersion "10") BUILD_ARGS=(-k) From debd42955ea76e88f6066335eab6fdce1bea8c49 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Thu, 1 Oct 2026 19:07:59 -0400 Subject: [PATCH 3/4] proxy-types: Avoid -Wundef error when KJ_NO_EXCEPTIONS is not defined Check that KJ_NO_EXCEPTIONS is defined before testing its value. Bitcoin Core builds the libmultiprocess subtree with -Wundef, so the plain `#if KJ_NO_EXCEPTIONS` check added in #364 fails the build with -Werror whenever the macro is not defined, which is the normal case. This change was written with Claude Opus 5.5 (1M context). --- include/mp/proxy-types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mp/proxy-types.h b/include/mp/proxy-types.h index 0c00b825..9822c121 100644 --- a/include/mp/proxy-types.h +++ b/include/mp/proxy-types.h @@ -15,7 +15,7 @@ // KJ exception support is required, or exceptions thrown in serverInvoke below go uncaught // and crash the process instead of being returned to the client as errors. -#if KJ_NO_EXCEPTIONS +#if defined(KJ_NO_EXCEPTIONS) && KJ_NO_EXCEPTIONS #error "KJ_NO_EXCEPTIONS=1 is set but libmultiprocess requires support for exceptions. Please check build settings. On NetBSD you may also need to set -DKJ_NO_EXCEPTIONS=0 -DKJ_NO_RTTI=0 explicitly (https://github.com/capnproto/capnproto/pull/2756)" #endif From 3577d23f616ec6e8d601d14452a5793f9d386708 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Thu, 1 Oct 2026 19:08:25 -0400 Subject: [PATCH 4/4] ci: Enable -Wundef in default and llvm jobs Bitcoin Core builds the libmultiprocess subtree with -Wundef, so a preprocessor check on an undefined macro breaks the Bitcoin Core build. Enable it in one GCC and one clang config to catch this here first. This change was written with Claude Opus 5.5 (1M context). --- ci/configs/default.bash | 2 +- ci/configs/llvm.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/configs/default.bash b/ci/configs/default.bash index acb38e15..492992c6 100644 --- a/ci/configs/default.bash +++ b/ci/configs/default.bash @@ -1,5 +1,5 @@ CI_DESC="CI job using default libraries and tools, and running IWYU" CI_DIR=build-default -export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wunused-const-variable -Wno-unused-parameter -Wextra-semi -Wmissing-noreturn -Wtrailing-whitespace" +export CXXFLAGS="-Werror -Wall -Wextra -Wpedantic -Wundef -Wunused-const-variable -Wno-unused-parameter -Wextra-semi -Wmissing-noreturn -Wtrailing-whitespace" CMAKE_ARGS=(-DMP_ENABLE_IWYU=ON) BUILD_ARGS=(-k) diff --git a/ci/configs/llvm.bash b/ci/configs/llvm.bash index af3b9719..4257db83 100644 --- a/ci/configs/llvm.bash +++ b/ci/configs/llvm.bash @@ -2,7 +2,7 @@ CI_DESC="CI job using LLVM-based libraries and tools (clang, libc++, clang-tidy, CI_DIR=build-llvm NIX_ARGS=(--arg enableLibcxx true) export CXX=clang++ -export CXXFLAGS="-Werror -Wall -Wextra -Wextra-semi -Wpedantic -Wthread-safety -Wno-unused-parameter -Wno-c++23-lambda-attributes" +export CXXFLAGS="-Werror -Wall -Wextra -Wextra-semi -Wpedantic -Wundef -Wthread-safety -Wno-unused-parameter -Wno-c++23-lambda-attributes" CMAKE_ARGS=( -G Ninja -DMP_ENABLE_CLANG_TIDY=ON