build: Clean up handling of module dependencies #1482

pull real-or-random wants to merge 2 commits into bitcoin-core:master from real-or-random:202401-cmake-mod-deps changing 2 files +38 −24
  1. real-or-random commented at 1:56 pm on January 16, 2024: contributor

    This is a cleanup which makes it easier to add further modules with dependencies, e.g., in #1452. The diff looks larger than it is because I also reordered the modules and made the order consistent between CMake and autotools.

    (We noticed that the current logic could be improved in https://github.com/BlockstreamResearch/secp256k1-zkp/pull/275.)

  2. real-or-random added the label build on Jan 16, 2024
  3. real-or-random added the label refactor/smell on Jan 16, 2024
  4. real-or-random cross-referenced this on Jan 16, 2024 from issue add cmake gears to enable ECDSA sign-to-contract - rangeproof - surjectionproof - whitelist - generator modules by lightyear15
  5. in configure.ac:390 in eb52535bb8 outdated
    391-  SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ECDH=1"
    392-fi
    393-
    394-if test x"$enable_module_recovery" = x"yes"; then
    395-  SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_RECOVERY=1"
    396+# Processing must be done in a reverse topological sorting of the dependency graph.
    


    jonasnick commented at 3:50 pm on January 16, 2024:

    micronit: Since “reverse” is a matter of defining the direction of the edge, maybe

    0# Processing must be done in a topological sorting of the dependency graph (dependent module first).
    
  6. in configure.ac:392 in eb52535bb8 outdated
    386@@ -387,29 +387,31 @@ SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
    387 ### Handle module options
    388 ###
    389 
    390-if test x"$enable_module_ecdh" = x"yes"; then
    391-  SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ECDH=1"
    392-fi
    


    jonasnick commented at 3:50 pm on January 16, 2024:
    Why change the order in configure.ac?

    real-or-random commented at 9:31 pm on January 16, 2024:
    To have the same order as in CMake, I think this makes maintenance easier. It’s the reverse order of the listing in the user-visible output. Let me add this rationale to the commit message. Or do you think I should not do this change?

    jonasnick commented at 9:34 am on January 17, 2024:
    No I think it’s fine.
  7. jonasnick commented at 3:51 pm on January 16, 2024: contributor

    ACK eb52535bb87b36839095fc1034882bf9a5e65aa7

    summoning @hebasto :)

  8. hebasto commented at 4:17 pm on January 16, 2024: member

    May I ask a bit more explanation for the second commit please?

     0$ cmake -B build -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=OFF
     1-- The C compiler identification is GNU 11.4.0
     2-- Detecting C compiler ABI info
     3-- Detecting C compiler ABI info - done
     4-- Check for working C compiler: /usr/bin/cc - skipped
     5-- Detecting C compile features
     6-- Detecting C compile features - done
     7CMake Error at CMakeLists.txt:71 (message):
     8  schnorrsig module requires explicitly disabled extrakeys module.
     9
    10
    11-- Configuring incomplete, errors occurred!
    12See also "/home/hebasto/git/secp256k1/secp256k1/build/CMakeFiles/CMakeOutput.log".
    

    The error message seems contradicts to -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=OFF.

    Or did I miss something?

  9. jonasnick commented at 6:23 pm on January 16, 2024: contributor

    @hebasto Not sure if I understand your note about the error message. I think it is correct. But I did parse it incorrectly the first time.

    schnorrsig module requires explicitly disabled extrakeys module.

    means that the schnorrsig module requires the extrakeys module. It does not mean that the schnorrsig module requires the extrakeys module to be explicitly disabled.

  10. hebasto commented at 6:48 pm on January 16, 2024: member

    @hebasto Not sure if I understand your note about the error message. I think it is correct. But I did parse it incorrectly the first time.

    schnorrsig module requires explicitly disabled extrakeys module.

    means that the schnorrsig module requires the extrakeys module. It does not mean that the schnorrsig module requires the extrakeys module to be explicitly disabled.

    So, why is the “disabled” word here?


    The user can build the schnorrsig module either providing -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON explicitly or relying on the default behavior when the SECP256K1_ENABLE_MODULE_EXTRAKEYS is set to ON by the CMake script, right?

  11. jonasnick commented at 7:17 pm on January 16, 2024: contributor

    The user can build the schnorrsig module either providing -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON explicitly or relying on the default behavior when the SECP256K1_ENABLE_MODULE_EXTRAKEYS is set to ON by the CMake script, right?

    No, turning on the extrakeys module should not turn on the schnorrsig module. The schnorrsig module requires the extrakeys module, not the other way around.

  12. hebasto commented at 7:25 pm on January 16, 2024: member

    The user can build the schnorrsig module either providing -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON explicitly or relying on the default behavior when the SECP256K1_ENABLE_MODULE_EXTRAKEYS is set to ON by the CMake script, right?

    No, turning on the extrakeys module should not turn on the schnorrsig module. The schnorrsig module requires the extrakeys module, not the other way around.

    Sorry for bad wording from my side. I mean, the schnorrsig module is enabled by default, and no extra actions, like providing -DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON, are needed, no?

  13. jonasnick commented at 7:48 pm on January 16, 2024: contributor
    On master if you provide --disable-module-extrakeys to ./configure or -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=OFF to cmake, it is simply ignored (because schnorrsig turns it on again). So it makes sense to throw an error instead of ignoring the explicit module disabling.
  14. hebasto commented at 7:55 pm on January 16, 2024: member

    On master if you provide --disable-module-extrakeys to ./configure or -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=OFF to cmake, it is simply ignored (because schnorrsig turns it on again). So it makes sense to throw an error instead of ignoring the explicit module disabling.

    Agree.

  15. build: Clean up handling of module dependencies
    This also makes the order in which module options are processed
    consistent between CMake and autotools (the reverse order of the listing
    printed to stdout).
    89ec583ccf
  16. build: Error if required module explicitly off e6822678ea
  17. real-or-random force-pushed on Jan 16, 2024
  18. real-or-random commented at 9:59 pm on January 16, 2024: contributor
    I made the error message more verbose, because it was apparently difficult to parse based on your feedback. (Thanks for being my user study.)
  19. jonasnick approved
  20. jonasnick commented at 9:35 am on January 17, 2024: contributor
    ACK e6822678ea05c431b4f43be9dfbde54e0f7f645b
  21. hebasto approved
  22. hebasto commented at 11:00 am on January 17, 2024: member
    ACK e6822678ea05c431b4f43be9dfbde54e0f7f645b.
  23. real-or-random merged this on Jan 17, 2024
  24. real-or-random closed this on Jan 17, 2024


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: 2025-01-20 02:15 UTC

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