cmake: Add option to recreate precomputed files #1791

pull hebasto wants to merge 3 commits into bitcoin-core:master from hebasto:251220-cmake-precomputed changing 9 files +57 −22
  1. hebasto commented at 8:02 pm on December 20, 2025: member

    Using the CMake-based build system enables smoother integration with parent projects by providing both CMake package configuration files and the traditional libsecp256k1.pc.

    However, packagers on some systems, such as Gentoo and Guix, insist on recreating the precomputed files, which is not currently supported by the CMake-based build system.

    This PR addresses the issue by introducing a new build option, SECP256K1_BUILD_PRECOMPUTED, which is disabled by default.

  2. hebasto force-pushed on Dec 20, 2025
  3. hebasto force-pushed on Dec 20, 2025
  4. kevkevinpal commented at 0:15 am on December 24, 2025: contributor

    are we able to do this via ./configure?

    or is this meant to be only done for CMake?

  5. hebasto commented at 1:43 am on December 24, 2025: member

    are we able to do this via ./configure?

    Yes. Run make clean-precomp && make precomp.

  6. real-or-random added the label feature on Jan 6, 2026
  7. real-or-random added the label build on Jan 6, 2026
  8. in src/CMakeLists.txt:70 in 5373c6aa6f
    69+      ${CMAKE_CURRENT_BINARY_DIR}/precomputed_ecmult_gen.c
    70+    COMMAND secp256k1_precompute_ecmult
    71+    COMMAND secp256k1_precompute_ecmult_gen
    72+    DEPENDS secp256k1_precompute_ecmult secp256k1_precompute_ecmult_gen
    73+    WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
    74+  )
    


    real-or-random commented at 8:33 am on January 6, 2026:
    Shouldn’t these conceptually be two separate commands?

    hebasto commented at 6:13 pm on January 6, 2026:
    Thanks! Reworked.
  9. in src/CMakeLists.txt:55 in 5373c6aa6f
    54+  add_executable(secp256k1_precompute_ecmult EXCLUDE_FROM_ALL precompute_ecmult.c)
    55+  target_compile_definitions(secp256k1_precompute_ecmult PRIVATE VERIFY)
    56+  if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
    57+    # Disable warning C4334 "'operator': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)".
    58+    target_compile_options(secp256k1_precompute_ecmult PRIVATE /wd4334)
    59+  endif()
    


    real-or-random commented at 8:35 am on January 6, 2026:
    In which line does this warning appear? Could we fix it in the code instead?

    hebasto commented at 6:13 pm on January 6, 2026:

    In which line does this warning appear?

    https://github.com/bitcoin-core/secp256k1/blob/2d9137ce9d7e576bfada2859292ecaa0887a6b8c/src/ecmult.h#L41

    Could we fix it in the code instead?

    Certainly. Fixed in 19529e70680a5edaa0210b74420693d8e689c7ac.


    real-or-random commented at 10:44 am on January 7, 2026:
    I think conceptually the result of ECMULT_TABLE_SIZE should be a size_t because it is an array size. What do you think of this refactor instead? https://github.com/bitcoin-core/secp256k1/pull/1794

    hebasto commented at 12:53 pm on January 7, 2026:
    Rebased on the top of the first commit from #1794.
  10. real-or-random commented at 8:35 am on January 6, 2026: contributor
    Concept ACK
  11. hebasto force-pushed on Jan 6, 2026
  12. hebasto commented at 6:14 pm on January 6, 2026: member

    @real-or-random

    Thank you for the review! Your feedback has been addressed.

  13. ecmult: Use size_t for array indices into tables bb1d199de5
  14. cmake: Add option to recreate precomputed files b7e71c5bce
  15. ci: Add `-DSECP256K1_BUILD_PRECOMPUTED=ON` to CMake jobs fdfda7bdf4
  16. hebasto force-pushed on Jan 7, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-07 22:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me