From 014e063a1037302f9d67d0eb03f1fcc6eb668f31 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 29 Apr 2023 23:09:10 +0100 Subject: [PATCH 1/4] cmake: Add `ProcessConfigurations.cmake` module --- CMakeLists.txt | 49 ++++-------------- cmake/ProcessConfigurations.cmake | 86 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 40 deletions(-) create mode 100644 cmake/ProcessConfigurations.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3107eb3bf1..422c505962 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,18 +161,17 @@ option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON) option(SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND}) option(SECP256K1_BUILD_EXAMPLES "Build examples." OFF) +include(ProcessConfigurations) +set_default_config(RelWithDebInfo) + # Redefine configuration flags. # We leave assertions on, because they are only used in the examples, and we want them always on there. if(MSVC) - string(REGEX REPLACE "/DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") - string(REGEX REPLACE "/DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") - string(REGEX REPLACE "/DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") + remove_flag_from_all_configs(/DNDEBUG) else() - string(REGEX REPLACE "-DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") - string(REGEX REPLACE "-DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") - string(REGEX REPLACE "-DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") + remove_flag_from_all_configs(-DNDEBUG) # Prefer -O2 optimization level. (-O3 is CMake's default for Release for many compilers.) - string(REGEX REPLACE "-O3[ \t\r\n]*" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + replace_flag_in_config(Release -O3 -O2) endif() # Define custom "Coverage" build type. @@ -195,23 +194,10 @@ mark_as_advanced( ) get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -set(default_build_type "RelWithDebInfo") if(is_multi_config) - set(CMAKE_CONFIGURATION_TYPES "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING - "Supported configuration types." - FORCE - ) + list(APPEND CMAKE_CONFIGURATION_TYPES Coverage) else() - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY - STRINGS "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage" - ) - if(NOT CMAKE_BUILD_TYPE) - message(STATUS "Setting build type to \"${default_build_type}\" as none was specified") - set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING - "Choose the type of build." - FORCE - ) - endif() + set_property(CACHE CMAKE_BUILD_TYPE APPEND PROPERTY STRINGS Coverage) endif() include(TryAppendCFlags) @@ -312,24 +298,7 @@ message("CFLAGS ................................ ${CMAKE_C_FLAGS}") get_directory_property(compile_options COMPILE_OPTIONS) string(REPLACE ";" " " compile_options "${compile_options}") message("Compile options ....................... " ${compile_options}) -if(NOT is_multi_config) - message("Build type:") - message(" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE}") - string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) - message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type}}") - message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type}}") - message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type}}") -else() - message("Supported configurations .............. ${CMAKE_CONFIGURATION_TYPES}") - message("RelWithDebInfo configuration:") - message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELWITHDEBINFO}") - message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") - message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}") - message("Debug configuration:") - message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_DEBUG}") - message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}") - message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}") -endif() +print_config_flags() message("\n") if(SECP256K1_EXPERIMENTAL) message( diff --git a/cmake/ProcessConfigurations.cmake b/cmake/ProcessConfigurations.cmake new file mode 100644 index 0000000000..57f75ec71b --- /dev/null +++ b/cmake/ProcessConfigurations.cmake @@ -0,0 +1,86 @@ +function(get_all_configs output) + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + set(all_configs ${CMAKE_CONFIGURATION_TYPES}) + else() + get_property(all_configs CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS) + if(NOT all_configs) + # See https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#default-and-custom-configurations + set(all_configs Debug Release RelWithDebInfo MinSizeRel) + endif() + endif() + set(${output} "${all_configs}" PARENT_SCOPE) +endfunction() + +# When used with multi-configuration generators, this function rearranges +# the CMAKE_CONFIGURATION_TYPES list, ensuring that the default configuration type +# appears first while maintaining the order of the remaining configuration types. +function(set_default_config config) + get_all_configs(all_configs) + if(NOT ${config} IN_LIST all_configs) + message(FATAL_ERROR "The default config is \"${config}\", but must be one of ${all_configs}.") + endif() + + list(REMOVE_ITEM all_configs ${config}) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15) + list(PREPEND all_configs ${config}) + else() + set(all_configs ${config} ${all_configs}) + endif() + + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + get_property(help_string CACHE CMAKE_CONFIGURATION_TYPES PROPERTY HELPSTRING) + set(CMAKE_CONFIGURATION_TYPES "${all_configs}" CACHE STRING "${help_string}" FORCE) + else() + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY + STRINGS "${all_configs}" + ) + if(NOT CMAKE_BUILD_TYPE) + message(STATUS "Setting build type to \"${config}\" as none was specified") + get_property(help_string CACHE CMAKE_BUILD_TYPE PROPERTY HELPSTRING) + set(CMAKE_BUILD_TYPE "${config}" CACHE STRING "${help_string}" FORCE) + endif() + endif() +endfunction() + +function(remove_flag_from_all_configs flag) + get_all_configs(all_configs) + foreach(config IN LISTS all_configs) + string(TOUPPER "${config}" config_uppercase) + set(flags "${CMAKE_C_FLAGS_${config_uppercase}}") + separate_arguments(flags) + list(FILTER flags EXCLUDE REGEX "${flag}") + list(JOIN flags " " new_flags) + set(CMAKE_C_FLAGS_${config_uppercase} "${new_flags}" PARENT_SCOPE) + endforeach() +endfunction() + +function(replace_flag_in_config config old_flag new_flag) + string(TOUPPER "${config}" config_uppercase) + string(REGEX REPLACE "(^| )${old_flag}( |$)" "\\1${new_flag}\\2" new_flags "${CMAKE_C_FLAGS_${config_uppercase}}") + set(CMAKE_C_FLAGS_${config_uppercase} "${new_flags}" PARENT_SCOPE) +endfunction() + +function(print_config_flags) + macro(print_flags config) + string(TOUPPER "${config}" config_uppercase) + message(" - CFLAGS ............................. ${CMAKE_C_FLAGS_${config_uppercase}}") + message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${config_uppercase}}") + message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${config_uppercase}}") + endmacro() + + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + list(JOIN CMAKE_CONFIGURATION_TYPES " " configs) + message("Supported configuration types ......... ${configs}") + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) + message("'${config}' configuration type:") + print_flags(${config}) + endforeach() + else() + message("Build type:") + message(" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE}") + print_flags(${CMAKE_BUILD_TYPE}) + endif() +endfunction() From 4b3bd6654051173ef3093ee5f8d47e5c333858bb Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 29 Apr 2023 23:09:25 +0100 Subject: [PATCH 2/4] cmake: Use `SECP256K1_COVERAGE` instead of `CMAKE_BUILD_TYPE=Coverage` This change fixes coverage-enabled builds for multi-configuration generators, e.g., "Ninja Multi-Config". --- CMakeLists.txt | 48 +++++++++++++++++----------------------------- src/CMakeLists.txt | 4 ++-- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 422c505962..cacb997827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,9 +156,20 @@ if(SECP256K1_VALGRIND) endif() option(SECP256K1_BUILD_BENCHMARK "Build benchmarks." ON) + +include(CMakeDependentOption) +cmake_dependent_option(SECP256K1_COVERAGE "Enable coverage analysis support." OFF "NOT MSVC" OFF) +include(TryAppendCFlags) +if(SECP256K1_COVERAGE) + add_compile_definitions(COVERAGE) + try_append_c_flags(-O0 --coverage) + add_link_options(--coverage) +endif() + option(SECP256K1_BUILD_TESTS "Build tests." ON) option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON) option(SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND}) + option(SECP256K1_BUILD_EXAMPLES "Build examples." OFF) include(ProcessConfigurations) @@ -170,37 +181,14 @@ if(MSVC) remove_flag_from_all_configs(/DNDEBUG) else() remove_flag_from_all_configs(-DNDEBUG) - # Prefer -O2 optimization level. (-O3 is CMake's default for Release for many compilers.) - replace_flag_in_config(Release -O3 -O2) -endif() - -# Define custom "Coverage" build type. -set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O0 -DCOVERAGE=1 --coverage" CACHE STRING - "Flags used by the C compiler during \"Coverage\" builds." - FORCE -) -set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} --coverage" CACHE STRING - "Flags used for linking binaries during \"Coverage\" builds." - FORCE -) -set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} --coverage" CACHE STRING - "Flags used by the shared libraries linker during \"Coverage\" builds." - FORCE -) -mark_as_advanced( - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE -) - -get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(is_multi_config) - list(APPEND CMAKE_CONFIGURATION_TYPES Coverage) -else() - set_property(CACHE CMAKE_BUILD_TYPE APPEND PROPERTY STRINGS Coverage) + if(SECP256K1_COVERAGE) + remove_flag_from_all_configs(-O[s0-9]) + else() + # Prefer -O2 optimization level. (-O3 is CMake's default for Release for many compilers.) + replace_flag_in_config(Release -O3 -O2) + endif() endif() -include(TryAppendCFlags) if(MSVC) # Keep the following commands ordered lexicographically. try_append_c_flags(/W3) # Production quality warning level. @@ -275,7 +263,7 @@ message("Optional binaries:") message(" benchmark ........................... ${SECP256K1_BUILD_BENCHMARK}") message(" noverify_tests ...................... ${SECP256K1_BUILD_TESTS}") set(tests_status "${SECP256K1_BUILD_TESTS}") -if(CMAKE_BUILD_TYPE STREQUAL "Coverage") +if(SECP256K1_COVERAGE) set(tests_status OFF) endif() message(" tests ............................... ${tests_status}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0bba19982a..08015eb0d5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,7 +88,7 @@ if(SECP256K1_BUILD_TESTS) add_executable(noverify_tests tests.c) target_link_libraries(noverify_tests secp256k1_precomputed secp256k1_asm) add_test(NAME noverify_tests COMMAND noverify_tests) - if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage") + if(NOT SECP256K1_COVERAGE) add_executable(tests tests.c) target_compile_definitions(tests PRIVATE VERIFY) target_link_libraries(tests secp256k1_precomputed secp256k1_asm) @@ -100,7 +100,7 @@ if(SECP256K1_BUILD_EXHAUSTIVE_TESTS) # Note: do not include secp256k1_precomputed in exhaustive_tests (it uses runtime-generated tables). add_executable(exhaustive_tests tests_exhaustive.c) target_link_libraries(exhaustive_tests secp256k1_asm) - target_compile_definitions(exhaustive_tests PRIVATE $<$>:VERIFY>) + target_compile_definitions(exhaustive_tests PRIVATE $<$>:VERIFY>) add_test(NAME exhaustive_tests COMMAND exhaustive_tests) endif() From 94dd0c0b99a9255378f07d95a57dd55d68ffb22e Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 29 Apr 2023 23:09:36 +0100 Subject: [PATCH 3/4] autotools, docs: Adjust help string for `--enable-coverage` option --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 82cf95132d..ef954f92da 100644 --- a/configure.ac +++ b/configure.ac @@ -151,7 +151,7 @@ AC_ARG_ENABLE(benchmark, [SECP_SET_DEFAULT([enable_benchmark], [yes], [yes])]) AC_ARG_ENABLE(coverage, - AS_HELP_STRING([--enable-coverage],[enable compiler flags to support kcov coverage analysis [default=no]]), [], + AS_HELP_STRING([--enable-coverage],[enable coverage analysis support [default=no]]), [], [SECP_SET_DEFAULT([enable_coverage], [no], [no])]) AC_ARG_ENABLE(tests, From 8eee93dabebbd3671a6046abca0c4af9d9c8772b Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 4 Jul 2023 21:54:21 +0100 Subject: [PATCH 4/4] Add `doc/build-options.md` --- README.md | 4 +- doc/build-options.md | 194 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 doc/build-options.md diff --git a/README.md b/README.md index 19dabe8505..e0fb7d74c9 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Building with Autotools $ make check # run the test suite $ sudo make install # optional -To compile optional modules (such as Schnorr signatures), you need to run `./configure` with additional flags (such as `--enable-module-schnorrsig`). Run `./configure --help` to see the full list of available flags. +To configure the build system, run the `./configure` script with additional [options](/doc/build-options.md). Building with CMake (experimental) ---------------------------------- @@ -84,7 +84,7 @@ To maintain a pristine source tree, CMake encourages to perform an out-of-source $ make check # run the test suite $ sudo make install # optional -To compile optional modules (such as Schnorr signatures), you need to run `cmake` with additional flags (such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON`). Run `cmake .. -LH` to see the full list of available flags. +To generate a non-default build system, run the `cmake` command with additional [options](/doc/build-options.md). ### Cross compiling diff --git a/doc/build-options.md b/doc/build-options.md new file mode 100644 index 0000000000..e8f66e45e2 --- /dev/null +++ b/doc/build-options.md @@ -0,0 +1,194 @@ +# Build Options + +This document describes available options when building with: +- GNU Autotools (hereafter "Autotools") +- CMake +- C toolchain only, for instance, GNU C compiler and GNU Binutils (hereafter "Manual") + +Autotools options must be provided to the `./configure` script. + +CMake options must be provided to the `cmake` when generating a buildsystem. + +In manual builds, options are just compiler flags. + +## Library Type + +By default, when using Autotools, both the shared and static libsecp256k1 libraries are built. +However, when using CMake, only one type of the library is built (see [PR1230](https://github.com/bitcoin-core/secp256k1/pull/1230)). + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-shared=yes` | `yes`, `no` | +| Autotools | `--enable-static=yes` | `yes`, `no` | +| CMake | `-DBUILD_SHARED_LIBS=ON` | `ON`, `OFF` | +| CMake | `-DSECP256K1_DISABLE_SHARED=OFF` | `ON`, `OFF` | + +## Optional Modules + +### ECDH Module + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-module-ecdh=yes` | `yes`, `no` | +| CMake | `-DSECP256K1_ENABLE_MODULE_ECDH=ON` | `ON`, `OFF` | +| Manual | n/a | `-DENABLE_MODULE_ECDH=1` | + +### ECDSA Pubkey Recovery Module + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-module-recovery=no` | `yes`, `no` | +| CMake | `-DSECP256K1_ENABLE_MODULE_RECOVERY=OFF` | `ON`, `OFF` | +| Manual | n/a | `-DENABLE_MODULE_RECOVERY=1` | + +### Extrakeys Module + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-module-extrakeys=yes` | `yes`, `no` | +| CMake | `-DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON` | `ON`, `OFF` | +| Manual | n/a | `-DENABLE_MODULE_EXTRAKEYS=1` | + +### Schnorrsig Module + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-module-extrakeys=yes` | `yes`, `no` | +| CMake | `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON` | `ON`, `OFF` | +| Manual | n/a | `-DENABLE_MODULE_SCHNORRSIG=1` | + +### ElligatorSwift Module + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-module-ellswift=yes` | `yes`, `no` | +| CMake | `-DSECP256K1_ENABLE_MODULE_ELLSWIFT=ON` | `ON`, `OFF` | +| Manual | n/a | `-DENABLE_MODULE_ELLSWIFT=1` | + +## Precomputed Table Parameters + +### Window Size + +Window size for ecmult precomputation for verification, specified as integer in range [2..24]. +Larger values result in possibly better performance at the cost of an exponentially larger precomputed table. +The table will store 2^(SIZE-1) * 64 bytes of data but can be larger in memory due to platform-specific padding and alignment. +A window size larger than 15 will require you delete the prebuilt `precomputed_ecmult.c` file so that it can be rebuilt. +For very large window sizes, use `make -j 1` to reduce memory use during compilation. +`auto`/`AUTO` is a reasonable setting for desktop machines (currently 15). + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--with-ecmult-window=auto` | `auto`, [`2`..`24`] | +| CMake | `-DSECP256K1_ECMULT_WINDOW_SIZE=AUTO` | `AUTO`, [`2`..`24`] | +| Manual | `-DECMULT_WINDOW_SIZE=15` | [`2`..`24`] | + +### Precision Bits + +Precision bits to tune the precomputed table size for signing. +The size of the table is 32kB for 2 bits, 64kB for 4 bits, 512kB for 8 bits of precision. +A larger table size usually results in possible faster signing. +`auto`/`AUTO` is a reasonable setting for desktop machines (currently 4). + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--with-ecmult-gen-precision=auto` | `auto`, `2`, `4`, `8` | +| CMake | `-DSECP256K1_ECMULT_GEN_PREC_BITS=AUTO` | `AUTO`, `2`, `4`, `8` | +| Manual | `-DECMULT_GEN_PREC_BITS=4` | `2`, `4`, `8` | + +## Optional Features + +### Assembly Optimization + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--with-asm=auto` | `auto`, `no`, `x86_64`, `arm32` | +| CMake | `-DSECP256K1_ASM=AUTO` | `AUTO`, `OFF`, `x86_64`, `arm32` | +| Manual | n/a | `-DUSE_ASM_X86_64=1`, `-DUSE_EXTERNAL_ASM=1` | + +`arm32` assembly optimization is an [experimental](#experimental-options) option. + +### External Default Callback Functions + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-external-default-callbacks=no` | `yes`, `no` | +| CMake | `-DSECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS=OFF` | `ON`, `OFF` | +| Manual | n/a | `-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1` | + +For more details, see docs in [`secp256k1.h`](/include/secp256k1.h). + +### Wide Multiplication Implementation + +This is a _test-only_ override of the "widemul" setting. +Legal values are: +- `int64` (for `[u]int64_t`) +- `int128` (for `[unsigned] __int128`) +- `int128_struct` (for `int128` implemented as a structure) +- `auto`/`AUTO` (for autodetection by the C code) + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--with-test-override-wide-multiply=auto` | `auto`, `int64`, `int128`, `int128_struct` | +| CMake | `-DSECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY=AUTO` | `AUTO`, `int64`, `int128`, `int128_struct` | +| Manual | n/a | `-DUSE_FORCE_WIDEMUL_INT64=1`, `-DUSE_FORCE_WIDEMUL_INT128=1`, `-DUSE_FORCE_WIDEMUL_INT128_STRUCT=1` | + +## Experimental Options + +To use experimental options, they must be allowed explicitly. + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-experimental=no` | `yes`, `no` | +| CMake | `-DSECP256K1_EXPERIMENTAL=OFF` | `ON`, `OFF` | + +## Optional Binaries + +### Benchmarks + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-benchmark=yes` | `yes`, `no` | +| CMake | `-DSECP256K1_BUILD_BENCHMARK=ON` | `ON`, `OFF` | + +For more details, see docs in [README](/README.md#benchmark). + +### Tests + +#### Tests with and without `VERIFY` mode + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-tests=yes` | `yes`, `no` | +| CMake | `-DSECP256K1_BUILD_TESTS=ON` | `ON`, `OFF` | + +#### Exhaustive Tests + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-exhaustive-tests=yes` | `yes`, `no` | +| CMake | `-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=ON` | `ON`, `OFF` | + +#### Constant-time Tests + +To build this tool, a memory-checking interface is required: [Valgrind](#build-with-valgrind) or MSan. + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-ctime-tests=yes` if Valgrind enabled | `yes`, `no` | +| CMake | `-DSECP256K1_BUILD_CTIME_TESTS=ON` if Valgrind enabled | `ON`, `OFF` | + +##### Build with Valgrind + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--with-valgrind=auto` | `auto`, `yes`, `no` | +| CMake | `-DSECP256K1_VALGRIND=AUTO` | `AUTO`, `ON`, `OFF` | + +#### Coverage Analysis Support + +| | Option with the default value | Available option values | +|---|-------------------------------|-------------------------| +| Autotools | `--enable-coverage=no` | `yes`, `no` | +| CMake | `-DSECP256K1_COVERAGE=OFF` | `ON`, `OFF` | + +For more details, see docs in [README](/README.md#test-coverage).