cmake: Fix regression in `secp256k1.cmake`
What changed, and why it matters
This is a small CMake build-system fix. A command that tells the build system to use the C programming language was moved from inside a function to the top of the file. The old placement could cause CMake configuration to fail or behave incorrectly when building the secp256k1 cryptographic library, but it does not change how the Bitcoin software itself runs or processes transactions.
No security action required beyond normal review and merge. This is a build-system correctness fix. Ensure CI covers the affected CMake configuration paths.
Security signals we found
No direct security vulnerability in the runtime code
Build-system regression that could prevent successful compilation of the secp256k1 cryptographic library
Failure to build secp256k1 could indirectly affect availability of a Bitcoin Core build
No evidence of malicious intent or exploitability in the diff
Evidence from the diff
The commit moves enable_language(C) from inside the add_secp256k1() function to file scope in cmake/secp256k1.cmake. CMake’s documentation states that enable_language() must be called in file scope, not inside a function. The previous placement was a regression that could break CMake configuration for the secp256k1 subtree, especially in multi-config generators or when the function was invoked in certain contexts.
Changed components
cmake/secp256k1.cmakelibsecp256k1 build configurationInspect captured patch +2 / −1
diff --git a/cmake/secp256k1.cmake b/cmake/secp256k1.cmake
index 15f1aacb..5302f516 100644
--- a/cmake/secp256k1.cmake
+++ b/cmake/secp256k1.cmake
@@ -2,6 +2,8 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
+enable_language(C)
+
function(add_secp256k1 subdir)
message("")
message("Configuring secp256k1 subtree...")
@@ -30,7 +32,6 @@ function(add_secp256k1 subdir)
string(STRIP "${SECP256K1_APPEND_LDFLAGS} ${APPEND_LDFLAGS}" SECP256K1_APPEND_LDFLAGS)
set(SECP256K1_APPEND_LDFLAGS ${SECP256K1_APPEND_LDFLAGS} CACHE STRING "" FORCE)
# We want to build libsecp256k1 with the most tested RelWithDebInfo configuration.
- enable_language(C)
foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES)
if(config STREQUAL "")
continue()
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.