Skip to content

Conversation

@real-or-random
Copy link
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.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

@hebasto
Copy link
Member

hebasto commented Jun 30, 2022

Should this diff be added as well

--- a/src/modules/recovery/tests_exhaustive_impl.h
+++ b/src/modules/recovery/tests_exhaustive_impl.h
@@ -7,7 +7,7 @@
 #ifndef SECP256K1_MODULE_RECOVERY_EXHAUSTIVE_TESTS_H
 #define SECP256K1_MODULE_RECOVERY_EXHAUSTIVE_TESTS_H
 
-#include "src/modules/recovery/main_impl.h"
+#include "main_impl.h"
 #include "../../../include/secp256k1_recovery.h"
 
 void test_exhaustive_recovery_sign(const secp256k1_context *ctx, const secp256k1_ge *group) {

?

@sipa
Copy link
Contributor

sipa commented Jun 30, 2022

@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?

@real-or-random
Copy link
Contributor Author

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 <>.

@real-or-random
Copy link
Contributor Author

Should this diff be added as well?

Done, thanks.

@sipa
Copy link
Contributor

sipa commented Jun 30, 2022

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 "".

@real-or-random
Copy link
Contributor Author

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?

@sipa
Copy link
Contributor

sipa commented Jun 30, 2022

ACK ac39773

@hebasto
Copy link
Member

hebasto commented Jul 1, 2022

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):

#include "../include/secp256k1_ecdh.h"
and
#include "../include/secp256k1_recovery.h"

Wondering why those headers are found using Autotools?

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

$ git grep include/secp256k1 -- src/modules/*.h
src/modules/ecdh/bench_impl.h:#include "../include/secp256k1_ecdh.h"
src/modules/ecdh/main_impl.h:#include "../../../include/secp256k1_ecdh.h"
src/modules/extrakeys/main_impl.h:#include "../../../include/secp256k1.h"
src/modules/extrakeys/main_impl.h:#include "../../../include/secp256k1_extrakeys.h"
src/modules/extrakeys/tests_exhaustive_impl.h:#include "../../../include/secp256k1_extrakeys.h"
src/modules/extrakeys/tests_impl.h:#include "../../../include/secp256k1_extrakeys.h"
src/modules/recovery/bench_impl.h:#include "../include/secp256k1_recovery.h"
src/modules/recovery/main_impl.h:#include "../../../include/secp256k1_recovery.h"
src/modules/recovery/tests_exhaustive_impl.h:#include "../../../include/secp256k1_recovery.h"
src/modules/schnorrsig/bench_impl.h:#include "../../../include/secp256k1_schnorrsig.h"
src/modules/schnorrsig/main_impl.h:#include "../../../include/secp256k1.h"
src/modules/schnorrsig/main_impl.h:#include "../../../include/secp256k1_schnorrsig.h"
src/modules/schnorrsig/tests_exhaustive_impl.h:#include "../../../include/secp256k1_schnorrsig.h"
src/modules/schnorrsig/tests_impl.h:#include "../../../include/secp256k1_schnorrsig.h"

@real-or-random
Copy link
Contributor Author

@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.

@hebasto
Copy link
Member

hebasto commented Jul 1, 2022

@real-or-random

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

@hebasto
Copy link
Member

hebasto commented Jul 1, 2022

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.

This simplifies building without a build system.

This is in line with bitcoin-core#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 bitcoin-core#929.

Co-authored-by: Hennadii Stepanov <[email protected]>
@real-or-random real-or-random force-pushed the 202206-include-fixes branch from ac39773 to 40a3473 Compare July 1, 2022 13:04
@real-or-random
Copy link
Contributor Author

@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: 😟 (-H is really useful flag...)

before fix: gcc -DENABLE_MODULE_ECDH -DENABLE_MODULE_RECOVERY -H -c src/bench.c (snippet)
. src/modules/ecdh/bench_impl.h
.. /usr/include/secp256k1_ecdh.h
... /usr/include/secp256k1.h
. src/modules/recovery/bench_impl.h
.. /usr/include/secp256k1_recovery.h
. src/modules/schnorrsig/bench_impl.h
.. src/modules/schnorrsig/../../../include/secp256k1_schnorrsig.h
... src/modules/schnorrsig/../../../include/secp256k1.h
... src/modules/schnorrsig/../../../include/secp256k1_extrakeys.h
after fix: gcc -DENABLE_MODULE_ECDH -DENABLE_MODULE_RECOVERY -H -c src/bench.c (snippet)
. src/modules/ecdh/bench_impl.h
.. src/modules/ecdh/../../../include/secp256k1_ecdh.h
... src/modules/ecdh/../../../include/secp256k1.h
. src/modules/recovery/bench_impl.h
.. src/modules/recovery/../../../include/secp256k1_recovery.h
... src/modules/recovery/../../../include/secp256k1.h
. src/modules/schnorrsig/bench_impl.h
.. src/modules/schnorrsig/../../../include/secp256k1_schnorrsig.h
... src/modules/schnorrsig/../../../include/secp256k1.h
... src/modules/schnorrsig/../../../include/secp256k1_extrakeys.h

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 40a3473

@real-or-random real-or-random merged commit af65d30 into bitcoin-core:master Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants