build: Fix #include “…” paths to get rid of further -I arguments #1116

pull real-or-random wants to merge 1 commits into bitcoin-core:master from real-or-random:202206-include-fixes changing 7 files +10 −10
  1. real-or-random commented at 3:26 pm on June 30, 2022: contributor

    This simplifies building without a build system.

    This is in line with #925; the paths fixed here were either forgotten there or only introduced later. This commit also makes the Makefile stricter so that further “wrong” #include paths will lead to build errors even in autotools builds.

    This belongs to #929.

  2. real-or-random cross-referenced this on Jun 30, 2022 from issue build: Add CMake-based build system by hebasto
  3. in src/tests_exhaustive.c:345 in d63719fb10 outdated
    341@@ -342,15 +342,15 @@ void test_exhaustive_sign(const secp256k1_context *ctx, const secp256k1_ge *grou
    342 }
    343 
    344 #ifdef ENABLE_MODULE_RECOVERY
    345-#include "src/modules/recovery/tests_exhaustive_impl.h"
    346+#include "modules/recovery/tests_exhaustive_impl.h"
    


    hebasto commented at 3:38 pm on June 30, 2022:
    Was about suggesting the same while working on #1113 :)
  4. hebasto commented at 3:38 pm on June 30, 2022: member
    Concept ACK.
  5. hebasto commented at 4:52 pm on June 30, 2022: member

    Should this diff be added as well

     0--- a/src/modules/recovery/tests_exhaustive_impl.h
     1+++ b/src/modules/recovery/tests_exhaustive_impl.h
     2@@ -7,7 +7,7 @@
     3 #ifndef SECP256K1_MODULE_RECOVERY_EXHAUSTIVE_TESTS_H
     4 #define SECP256K1_MODULE_RECOVERY_EXHAUSTIVE_TESTS_H
     5 
     6-#include "src/modules/recovery/main_impl.h"
     7+#include "main_impl.h"
     8 #include "../../../include/secp256k1_recovery.h"
     9 
    10 void test_exhaustive_recovery_sign(const secp256k1_context *ctx, const secp256k1_ge *group) {
    

    ?

  6. sipa commented at 5:59 pm on June 30, 2022: contributor
    @real-or-random Bitcoin Core uses #include <...> style exclusively, even for the project’s own files, because they’re never relative w.r.t. the source file path. Is that something which would be useful for us too?
  7. real-or-random commented at 6:25 pm on June 30, 2022: contributor

    In order to simplify building without build system (#929), we tried to get rid of as many mandatory compiler args as possible. #925 tried to get rid of -I but missed a few cases. This is fixed by this PR.

    Changing everything to <> would be a switch of paradigms. I think in the end there’s no definitive answer (see https://stackoverflow.com/a/72065059 for a nice discussion of pros and cons) but I think simple manual builds is a useful goal for us (e.g. for embedded users), so I think we should stick to our ""-only convention unless we have a good reason to change to <>.

  8. real-or-random force-pushed on Jun 30, 2022
  9. real-or-random commented at 6:30 pm on June 30, 2022: contributor

    Should this diff be added as well?

    Done, thanks.

  10. sipa commented at 6:31 pm on June 30, 2022: contributor

    but I think simple manual builds is a useful goal for us (e.g. for embedded users), so I think we should stick to our ""-only convention unless we have a good reason to change to <>.

    Good point; minimizing complexity for people building without build system support is a good reason to stick with “”.

  11. real-or-random commented at 8:35 pm on June 30, 2022: contributor

    but I think simple manual builds is a useful goal for us (e.g. for embedded users), so I think we should stick to our ""-only convention unless we have a good reason to change to <>.

    Good point; minimizing complexity for people building without build system support is a good reason to stick with “”.

    Wanna ACK then?

  12. sipa commented at 9:10 pm on June 30, 2022: contributor
    ACK ac39773ba97f2afd0d84a2b3954e3cdc0a7594f7
  13. hebasto commented at 9:29 am on July 1, 2022: member

    Removing of -I$(top_srcdir)/include here made me believe that include_directories(${PROJECT_SOURCE_DIR}/include) can be dropped in #1113 as well.

    But that is not the case. Two headers cannot be found (when combining this PR and #1113): https://github.com/bitcoin-core/secp256k1/blob/43756da819a235d813e7ecd53eae6df073b53247/src/modules/ecdh/bench_impl.h#L10 and https://github.com/bitcoin-core/secp256k1/blob/43756da819a235d813e7ecd53eae6df073b53247/src/modules/recovery/bench_impl.h#L10

    Wondering why those headers are found using Autotools?

    FWIW, all other #includes in the modules directory use correct paths:

     0$ git grep include/secp256k1 -- src/modules/*.h
     1src/modules/ecdh/bench_impl.h:#include "../include/secp256k1_ecdh.h"
     2src/modules/ecdh/main_impl.h:#include "../../../include/secp256k1_ecdh.h"
     3src/modules/extrakeys/main_impl.h:#include "../../../include/secp256k1.h"
     4src/modules/extrakeys/main_impl.h:#include "../../../include/secp256k1_extrakeys.h"
     5src/modules/extrakeys/tests_exhaustive_impl.h:#include "../../../include/secp256k1_extrakeys.h"
     6src/modules/extrakeys/tests_impl.h:#include "../../../include/secp256k1_extrakeys.h"
     7src/modules/recovery/bench_impl.h:#include "../include/secp256k1_recovery.h"
     8src/modules/recovery/main_impl.h:#include "../../../include/secp256k1_recovery.h"
     9src/modules/recovery/tests_exhaustive_impl.h:#include "../../../include/secp256k1_recovery.h"
    10src/modules/schnorrsig/bench_impl.h:#include "../../../include/secp256k1_schnorrsig.h"
    11src/modules/schnorrsig/main_impl.h:#include "../../../include/secp256k1.h"
    12src/modules/schnorrsig/main_impl.h:#include "../../../include/secp256k1_schnorrsig.h"
    13src/modules/schnorrsig/tests_exhaustive_impl.h:#include "../../../include/secp256k1_schnorrsig.h"
    14src/modules/schnorrsig/tests_impl.h:#include "../../../include/secp256k1_schnorrsig.h"
    
  14. real-or-random commented at 10:30 am on July 1, 2022: contributor
    @hebasto That’s an “interesting” observation. Apparently autotools always add -I. -I./src in our case, see https://stackoverflow.com/questions/5641480/automake-overwriting-default-includes… The suggestion of overriding it doesn’t work for me. I’ll see if there’s another way of getting rid of that.
  15. hebasto commented at 10:39 am on July 1, 2022: member

    @real-or-random

    As the goal of this PR is to “Fix #include “…” paths”, could those two paths be fixed as well?

  16. hebasto commented at 10:41 am on July 1, 2022: member

    That’s an “interesting” observation. Apparently autotools always add -I. -I./src in our case, see https://stackoverflow.com/questions/5641480/automake-overwriting-default-includes… The suggestion of overriding it doesn’t work for me. I’ll see if there’s another way of getting rid of that.

    Another reason to rid of the config header.

  17. build: Fix #include "..." paths to get rid of further -I arguments
    This simplifies building without a build system.
    
    This is in line with #925; the paths fixed here were either forgotten
    there or only introduced later. This commit also makes the Makefile
    stricter so that further "wrong" #include paths will lead to build
    errors even in autotools builds.
    
    This belongs to #929.
    
    Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
    40a3473a9d
  18. real-or-random force-pushed on Jul 1, 2022
  19. real-or-random commented at 1:13 pm on July 1, 2022: contributor

    @hebasto Okay I added these additional fixes, I hope that was everything now.

    The issue is that we can’t really enforce that policy using autotools. One can add nostdinc to the Automake options, and this indeed removes the -I. -I./src but this breaks out-of-tree ( yes, this is supported by autotools, called “VPATH” builds) and more impoatantly make distcheck, which relies on VPATH builds… The reasons those breaks build is the config header.

    Another reason to rid of the config header.

    Yep. If we do this, then we could enforce the policy… We could also just add a “manual” build to CI. This is already on the task list in #929. But this can be done in a separate PR.

    Funnily, the build worked for me locally when setting stdinc but without fixing secp256k1/src/modules/(ecdh|recovery)/bench_impl.h. This confused me a lot… Guess why? My system installation libsecp256k1: :worried: (-H is really useful flag…)

    0. src/modules/ecdh/bench_impl.h
    1.. /usr/include/secp256k1_ecdh.h
    2... /usr/include/secp256k1.h
    3. src/modules/recovery/bench_impl.h
    4.. /usr/include/secp256k1_recovery.h
    5. src/modules/schnorrsig/bench_impl.h
    6.. src/modules/schnorrsig/../../../include/secp256k1_schnorrsig.h
    7... src/modules/schnorrsig/../../../include/secp256k1.h
    8... src/modules/schnorrsig/../../../include/secp256k1_extrakeys.h
    
    0. src/modules/ecdh/bench_impl.h
    1.. src/modules/ecdh/../../../include/secp256k1_ecdh.h
    2... src/modules/ecdh/../../../include/secp256k1.h
    3. src/modules/recovery/bench_impl.h
    4.. src/modules/recovery/../../../include/secp256k1_recovery.h
    5... src/modules/recovery/../../../include/secp256k1.h
    6. src/modules/schnorrsig/bench_impl.h
    7.. src/modules/schnorrsig/../../../include/secp256k1_schnorrsig.h
    8... src/modules/schnorrsig/../../../include/secp256k1.h
    9... src/modules/schnorrsig/../../../include/secp256k1_extrakeys.h
    
  20. hebasto approved
  21. hebasto commented at 1:51 pm on July 1, 2022: member
    ACK 40a3473a9d44dc409412e94f70ad0f09bd9da3ac
  22. real-or-random merged this on Jul 1, 2022
  23. real-or-random closed this on Jul 1, 2022

  24. dhruv referenced this in commit 2dfd7005d9 on Jul 19, 2022
  25. dhruv referenced this in commit 21e2acb595 on Jul 20, 2022
  26. dhruv referenced this in commit f70e7d8108 on Jul 20, 2022
  27. dhruv referenced this in commit 49704ff497 on Jul 20, 2022
  28. dhruv referenced this in commit a1ac8e1b7f on Jul 20, 2022
  29. hebasto referenced this in commit 07695f6c2d on Jul 21, 2022
  30. dhruv referenced this in commit e5166959a4 on Jul 21, 2022
  31. dhruv referenced this in commit 726cbfe06c on Jul 21, 2022
  32. dhruv referenced this in commit c354ccd3e6 on Jul 21, 2022
  33. dhruv referenced this in commit 296cb3807d on Jul 21, 2022
  34. dhruv referenced this in commit a7efff1c21 on Jul 22, 2022
  35. dhruv referenced this in commit 5667aa958a on Aug 12, 2022
  36. dhruv referenced this in commit 06823cfe29 on Aug 24, 2022
  37. dhruv referenced this in commit 6eca30d4bd on Sep 2, 2022
  38. dhruv referenced this in commit c3ed192dda on Sep 2, 2022
  39. dhruv referenced this in commit 89ebab0601 on Oct 1, 2022
  40. dhruv referenced this in commit d6bcb105c3 on Oct 20, 2022
  41. dhruv referenced this in commit c27eb1e66a on Oct 20, 2022
  42. dhruv referenced this in commit a2e91d2816 on Oct 20, 2022
  43. dhruv referenced this in commit 0b21533c10 on Oct 21, 2022
  44. dhruv referenced this in commit 01dddb4cf6 on Oct 21, 2022
  45. dhruv referenced this in commit a0bb5b6946 on Nov 17, 2022
  46. dhruv referenced this in commit 2e4c03dd67 on Nov 17, 2022
  47. dhruv referenced this in commit 388c9b1b55 on Nov 21, 2022
  48. dhruv referenced this in commit 244eb87643 on Dec 7, 2022
  49. dhruv referenced this in commit 92cddabc43 on Dec 8, 2022
  50. sipa referenced this in commit 9d47e7b71b on Dec 13, 2022
  51. dhruv referenced this in commit 55ffd47cc6 on Dec 14, 2022
  52. dhruv referenced this in commit 967c65b158 on Dec 14, 2022
  53. dhruv referenced this in commit 78b5ddf28b on Jan 11, 2023
  54. dhruv referenced this in commit 215394a1d5 on Jan 11, 2023
  55. div72 referenced this in commit 945b094575 on Mar 14, 2023
  56. str4d referenced this in commit 0df7b459f6 on Apr 21, 2023
  57. vmta referenced this in commit e1120c94a1 on Jun 4, 2023
  58. vmta referenced this in commit 8f03457eed on Jul 1, 2023
  59. jonasnick cross-referenced this on Jul 17, 2023 from issue Upstream PRs 1056, 1104, 1105, 1084, 1114, 1115, 1116, 1120, 1122, 1121, 1128, 1131, 1144, 1150, 1146 by jonasnick

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: 2024-12-22 11:15 UTC

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