-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
changed include statements without prefix 'include/' #925
Conversation
Alternatively, the internal usage could use correct relative paths, changing include/ to ../include/. This is a smaller diff, and doesn't require any include settings in the build system to build the library: E.g.
I believe classically "" includes didn't perform any search, so paths had to be explicit... though all modern compilers do search with it. As far as that Cmake build goes-- it looks broken. the top level directory is (currently) supposed to be in the includes path. I went to go find the cmake input to see if it was making more serious errors (e.g. failing to include SECP256K1_BUILD) but I couldn't find it. |
The deeper nested includes would end up needing more i agree there’s multiple ways to skin this cat, so let’s get something done? i can make the changes be a relative path if you will it so. |
I noticed this include problem when looking into #923, and I agree we should aim for a solution that does not need |
I have just made the changes to be a relative path as mentioned. The changes to the The changes do fix the cmake build i was working on so thats a plus. |
The changes look fine. Let's see if the CI build works. If yes, can you squash this into a single commit? |
Yep, I'll squash once the build passes. |
486c2a8
to
9d5ac8c
Compare
It should probably also change tests.c: #include "../contrib/lax_der_parsing.c"
#include "../contrib/lax_der_privatekey_parsing.c" Though this isn't enough to compile tests.c with no -I lines to the compiler. The issue is that the modules in contrib correctly use <secp256k1.h> as its 'end user code' -- but then that doesn't work as expected here. Still, I think moving the issue back to there is more correct, and at least fewer -I are needed. |
9d5ac8c
to
c12d719
Compare
This is another good catch. Though the action isn't clear to me. You're saying we should change this to be a relative path as well |
Yes, it should be changed to ../contrib. |
We could do something like this in the contrib files:
|
c12d719
to
188637c
Compare
Care to expand? I was able to properly build outside of the repo the executable |
Maybe you have I think what should happen is that when trying to compile without
then gcc, when it encouters |
@real-or-random Seems fine to me, ever so slightly kludgy but argument free compiles are nice and the test harness is kind of inherently weird because its a test. |
src/modules/ecdh/main_impl.h
Outdated
@@ -7,7 +7,7 @@ | |||
#ifndef SECP256K1_MODULE_ECDH_MAIN_H | |||
#define SECP256K1_MODULE_ECDH_MAIN_H | |||
|
|||
#include "include/secp256k1_ecdh.h" | |||
#include "../include/secp256k1_ecdh.h" | |||
#include "ecmult_const_impl.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
../../ecmult_const_impl.h
src/modules/schnorrsig/main_impl.h
Outdated
#include "include/secp256k1.h" | ||
#include "include/secp256k1_schnorrsig.h" | ||
#include "../include/secp256k1.h" | ||
#include "../include/secp256k1_schnorrsig.h" | ||
#include "hash.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
../../hash.h
src/modules/ecdh/main_impl.h
Outdated
@@ -7,7 +7,7 @@ | |||
#ifndef SECP256K1_MODULE_ECDH_MAIN_H | |||
#define SECP256K1_MODULE_ECDH_MAIN_H | |||
|
|||
#include "include/secp256k1_ecdh.h" | |||
#include "../include/secp256k1_ecdh.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
../../../include/
should work without errors. After applying my above review comments and the include work around mentioned by real-or-random (it's needed in four places in contrib, everywhere <secp256k1.h> is used) it does for me. |
This needs rebase now that #928 has been merged.
That was also my thinking. Tt's not exactly elegant but it does the job in the end... |
Great! This just needs code like /* #include secp256k1.h only when it hasn't been included yet.
This enables this file to be #included directly in other project
files (such as tests.c) without the need to set an explicit -I flag,
which would be necessary to locate secp256k1.h. */
#ifndef SECP256K1_H
#include <secp256k1.h>
#endif around the uses of
will work. |
Argh, this needs rebase again (and CI failures just appeared because #936 was merged during CI was running...). Sorry that this needs so many ping pongs. |
This works, I'll tackle it tomorrow morning assuming this is the way to move forward. Sometimes i don't understand how the search paths are distinguished for these compilers, seems I don't read English too good when looking at their docs! |
ACK on the update so far, looking forward to the rest. I'll review as soon as it's up. Thanks! |
…e/" dir added relative paths to header files imported from src directory added include guards for contrib/ files when referring to secp256k1.h
This should be good to go now. For better context: In This cleans up the unnecessary wordy include duplication and satisfies the definitions by being included in the header which is required for the source file to run. As mentioned previously: $ gcc -o ./tests ./src/tests.c -DECMULT_GEN_PREC_BITS=4 -DECMULT_WINDOW_SIZE=15 -DENABLE_MODULE_SCHNORRSIG -DENABLE_MODULE_EXTRAKEYS -DENABLE_MODULE_RECOVERY -DENABLE_MODULE_ECDH && $ clang -o ./tests ./src/tests.c -DECMULT_GEN_PREC_BITS=4 -DECMULT_WINDOW_SIZE=15 -DENABLE_MODULE_SCHNORRSIG -DENABLE_MODULE_EXTRAKEYS -DENABLE_MODULE_RECOVERY -DENABLE_MODULE_ECDH Run just fine now. I even ran the "include what you use" tooling and it gives good-to-go. |
The test suite needs to be run again, seems like theres an underlying issue there. |
his failure is really spurious. If you look at the logs, all the tests pass, just Cirrus is confused about about result. (I reported it at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3c90bdd code looks good and even the tests compile fine now without -I
args
ACK 3c90bdd |
Posthumous utACK 3c90bdd |
They were added in bitcoin-core#925 and deserve a comment.
22a9ea1 contrib: Explain explicit header guards (Tim Ruffing) Pull request description: They were added in #925 and deserve a comment. ACKs for top commit: gmaxwell: ACK 22a9ea1 sipa: ACK 22a9ea1 Tree-SHA512: 832e28d71857d52912dae7e6c0e08a3183bb788996bb2470616c6fbbac6ba601cc74bb51a4c908aec7df9ae4f4cbf2cbb1b451cefde1b5a7359dc93299840278
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.
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 <32963518+hebasto@users.noreply.github.com>
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 <32963518+hebasto@users.noreply.github.com>
… arguments 40a3473 build: Fix #include "..." paths to get rid of further -I arguments (Tim Ruffing) Pull request description: 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. ACKs for top commit: hebasto: ACK 40a3473 Tree-SHA512: 6f4d825ea3cf86b13f294e2ec19fafc29660fa99450e6b579157d7a6e9bdb3404d761edf89c1135fa89b984d6431a527beeb97031dc90f2fae9761528f4d06d1
They were added in bitcoin-core#925 and deserve a comment.
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 <32963518+hebasto@users.noreply.github.com>
Referencing #924 , this PR splits the two issues brought on to a smaller to digest change. What this does is removes the prefix "include/" when referencing the local library header files.
e.g:
from:
to:
Rationale besides styling and consistency across other files in the repo, it makes it easier for outside builds to properly locate the headers.
A live example seen here when attempting to build this library within bitcoin repo: