-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: Switch to libsecp256k1 upstream build system #192
Changes from all commits
f0aec78
c3134b0
469e1ad
65f15d1
cdd843a
70ec2d9
bfe7c4d
458d54c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Copyright (c) 2023 The Bitcoin Core developers | ||
# Copyright (c) 2023-present The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
# file COPYING or https://opensource.org/license/mit/. | ||
|
||
include(GNUInstallDirs) | ||
include(AddWindowsResources) | ||
|
@@ -38,6 +38,38 @@ if(WITH_MULTIPROCESS) | |
add_subdirectory(ipc) | ||
endif() | ||
|
||
#============================= | ||
# secp256k1 subtree | ||
#============================= | ||
message("") | ||
message("Configuring secp256k1 subtree...") | ||
set(SECP256K1_DISABLE_SHARED ON CACHE BOOL "" FORCE) | ||
set(SECP256K1_ENABLE_MODULE_ECDH OFF CACHE BOOL "" FORCE) | ||
set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE) | ||
set(SECP256K1_ECMULT_GEN_KB 86 CACHE STRING "" FORCE) | ||
set(SECP256K1_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE) | ||
set(SECP256K1_BUILD_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE) | ||
set(SECP256K1_BUILD_EXHAUSTIVE_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE) | ||
set(SECP256K1_BUILD_CTIME_TESTS OFF CACHE BOOL "" FORCE) | ||
set(SECP256K1_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we landed on that running the ctime tests would actually be valuable? If not, or if it's waiting on something else, it'd be good to have a comment here explaining why these tests are being skipped. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry if I misunderstood the previous discussion, but I thought that the idea was to mirror the master branch behaviour during migration to CMake. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ok, but the ctime tests are currently compiled, and runnable there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Fixed in #253. |
||
include(GetTargetInterface) | ||
# -fsanitize and related flags apply to both C++ and C, | ||
# so we can pass them down to libsecp256k1 as CFLAGS. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this also be passing down LDFLAGS? Or is that being done somwhere else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why? libsecp256k1 is a static library, and no linker is used to produce it, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
get_target_interface(core_sanitizer_cxx_flags "" sanitize_interface COMPILE_OPTIONS) | ||
set(SECP256K1_LATE_CFLAGS ${core_sanitizer_cxx_flags} CACHE STRING "" FORCE) | ||
unset(core_sanitizer_cxx_flags) | ||
# We want to build libsecp256k1 with the most tested RelWithDebInfo configuration. | ||
enable_language(C) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not sure this comment adds much value, and the CMake config is not really the most relevant thing? I'd say what matters more is the secp256k1 configuration, which currently, diverges from upstream, and isn't extensively tested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you suggest an improved comment or other approach? |
||
foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES) | ||
if(config STREQUAL "") | ||
continue() | ||
endif() | ||
string(TOUPPER "${config}" config) | ||
set(CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_RELWITHDEBINFO}") | ||
endforeach() | ||
add_subdirectory(secp256k1) | ||
set_target_properties(secp256k1 PROPERTIES EXPORT_COMPILE_COMMANDS OFF) | ||
string(APPEND CMAKE_C_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CFLAGS}") | ||
|
||
# Stable, backwards-compatible consensus functionality. | ||
add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed for secp256k1 specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not secp256k1-specific change. As a part of the "[FIXUP] cmake: Enable tests before adding subdirectories" commit this change adjusts the moment when
enable_testing()
being called. Previously, it was done implicitly viainclude(CTest)
command after processing thesrc
subdirectory. Now it done explicitly and before processing thesrc
subdirectory. Which activates anyadd_test
commands within thesrc
subdirectory including thesrc/secp256k1
subdirectory as well.