-
Notifications
You must be signed in to change notification settings - Fork 37.7k
build: Check usages of #if defined(...) #16547
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
Conversation
Some notes while exploring: @alko89 Would you be able to use https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/master/build-for-compare.py to show that no differences arise in the binary after this change? |
@dongcarl I have executed the script you provided with this and previous commit, then compared them with:
and get an empty output. |
@fanquake Is this how |
@dongcarl Yes. I've also run it against this PR (7f3c669), and it's previous commit (e55444a), and didn't see any difference in the binaries: sha256sum /tmp/compare/*.stripped
7eb28b0d46d4fc833b6f6b026f8d4ecd20f733f096ded4c0d0f8bada3e6a7944 /tmp/compare/bitcoin-qt.7f3c669ccf4d97e7aa52722b8549bd474791eb33.stripped
7eb28b0d46d4fc833b6f6b026f8d4ecd20f733f096ded4c0d0f8bada3e6a7944 /tmp/compare/bitcoin-qt.e55444a2a8a2b4a378e6d42b7bf73d13492a5716.stripped
8e5d3e83e125a387170ace209d9fe851ec022e9a5ffb529c92bb0e49a4019569 /tmp/compare/bitcoind.7f3c669ccf4d97e7aa52722b8549bd474791eb33.stripped
8e5d3e83e125a387170ace209d9fe851ec022e9a5ffb529c92bb0e49a4019569 /tmp/compare/bitcoind.e55444a2a8a2b4a378e6d42b7bf73d13492a5716.stripped You obviously also use diffoscope /tmp/compare/bitcoind.7f3c669ccf4d97e7aa52722b8549bd474791eb33.stripped \
/tmp/compare/bitcoind.e55444a2a8a2b4a378e6d42b7bf73d13492a5716.stripped |
Concept ACK Thanks for tackling this! |
@@ -4,7 +4,7 @@ | |||
|
|||
#include <bench/bench.h> | |||
#include <key.h> | |||
#if defined(HAVE_CONSENSUS_LIB) | |||
#if HAVE_CONSENSUS_LIB |
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.
This is not defined when ./configure --with-libs=no
. So it will default to 0
or something?
Yup! See the BUFFSIZE example here: http://gcc.gnu.org/onlinedocs/gcc-3.0.1/cpp_4.html#SEC39
…On Tue, Aug 6, 2019 at 10:56 AM, MarcoFalke ***@***.***> wrote:
@MarcoFalke commented on this pull request.
---------------------------------------------------------------
In [src/bench/verify_script.cpp](#16547 (comment)):
> @@ -4,7 +4,7 @@
#include <bench/bench.h>
#include <key.h>
-#if defined(HAVE_CONSENSUS_LIB)
+#if HAVE_CONSENSUS_LIB
This is not defined when ./configure --with-libs=no. So it will default to 0 or something?
—
You are receiving this because you were mentioned.
Reply to this email directly, [view it on GitHub](#16547?email_source=notifications&email_token=AA2JEKXVWD7LCMDFHIMNYF3QDGGIHA5CNFSM4IJMUETKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCAWU5XI#pullrequestreview-271404765), or [mute the thread](https://github.com/notifications/unsubscribe-auth/AA2JEKRA5THBXF2HWIGW4DTQDGGIHANCNFSM4IJMUETA).
|
ACK 7f3c669 (also checked that gcc and clang produce the same bitcoind before and after Show signature and timestampSignature:
Timestamp of file with hash |
What about stuff like this:
|
Not sure what you're asking, but |
Yeah, if this is changed, it should be done once and for all. |
I have bean reading about if defines in the gcc doc @dongcarl provided. In if chapter it is also stated that undefined macros are interpreted as having the value of 0. I guess in that case most of https://gcc.gnu.org/onlinedocs/gcc-3.0.1/cpp_4.html#SEC38 Also the -Wundef option causes gcc to trigger warnings if it encounters an identifier which is not a macro in an I will replace all |
I will need more time investigating this. What about OS and architecture specific macros like As for OS specific macros I'm testing on Linux and would need someone to check how these macros are defined on other platforms. |
Can confirm that Macros that are problematic with |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
Could this be a scripted diff? |
@alko89 Is this now ready for review? |
you can close this PR for now. I'll create a new one when I'm done. |
PR for #16419.
I have gone through
bitcoin_config.h
constants and removed defined where not needed.The rationale was to remove the ones where the constant is defined in both
config/bitcoin_config.h
andbuild_msvc/bitcoin_conf.h
and is declared as 1 or 0. If the constant is commented out or not declared at all in any of those config files, I left the check as#if defined(...)
, otherwise I changed the definition to#if ...
If there are any other cases where
#if defined
is not needed, let me know and I'll update the PR.