Skip to content
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

build: Check usages of #if defined(...) #25302

Closed

Conversation

brokenprogrammer
Copy link
Contributor

I tried to go over #16419.

Based on #16344 I interpreted that the AC_DEFINE like the following:

AC_DEFINE(USE_EXTERNAL_ASM, 1, [Define this symbol if an external (non-inline) assembly implementation is used])

Results in value defines which also #16547 suggests.

If I've missunderstood anything or if there is more #if defined or #ifdef that should be #if then please let me know and I will update the pull request.

@brokenprogrammer
Copy link
Contributor Author

The linting failed because of FAIL: subtree directory was touched without subtree merge. I guess this is because I touched some external library code. Should I just revert the changes that affected secp256k1?

@laanwj
Copy link
Member

laanwj commented Jun 8, 2022

The linting failed because of FAIL: subtree directory was touched without subtree merge. I guess this is because I touched some external library code. Should I just revert the changes that affected secp256k1?

Yes, it's not possible to make changes to subtrees through a PR in this repository, it needs to go through the appropriate upstream.

@brokenprogrammer
Copy link
Contributor Author

The linting failed because of FAIL: subtree directory was touched without subtree merge. I guess this is because I touched some external library code. Should I just revert the changes that affected secp256k1?

Yes, it's not possible to make changes to subtrees through a PR in this repository, it needs to go through the appropriate upstream.

I see, thank you for the information. I have reverted the files for secp256k1.

@fanquake
Copy link
Member

fanquake commented Jun 8, 2022

I have reverted the files for secp256k1.

You need to remove the changes entirely, no reversion commits. You'll also need to write a proper / useful commit message for the actual change. I'd suggest reading through https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md.

@brokenprogrammer
Copy link
Contributor Author

I have reverted the files for secp256k1.

You need to remove the changes entirely, no reversion commits. You'll also need to write a proper / useful commit message for the actual change. I'd suggest reading through https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md.

Sorry about that, I've published a new change which I hope corrects my mistakes.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 8, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #27607 (init: verify blocks data existence only once for all the indexers by furszy)
  • #27598 (bench: Add SHA256 implementation specific benchmarks by hebasto)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@luke-jr
Copy link
Member

luke-jr commented Jun 18, 2022

AC_DEFINE only defines if it's actually called. Conditional calls to AC_DEFINE (such as those setting it to a constant 1, or not setting a value at all) need defined()/#ifdef AIUI

Looking through our defines, I don't see anything that requires changes. Edit: was looking at an old commit

@luke-jr
Copy link
Member

luke-jr commented Jun 18, 2022

Correction: LevelDB is using #if defined(HAVE_O_CLOEXEC), which we are defining to 0 on systems without it - this leads to a build failure, and should be fixed.

@brokenprogrammer
Copy link
Contributor Author

AC_DEFINE only defines if it's actually called. Conditional calls to AC_DEFINE (such as those setting it to a constant 1, or not setting a value at all) need defined()/#ifdef AIUI

Looking through our defines, I don't see anything that requires changes. Edit: was looking at an old commit

With that said I think I've missunderstood the task? Should I remove all my previous changes and perhaps only address what you mentioned with HAVE_O_CLOEXEC?

@fanquake
Copy link
Member

Should I remove all my previous changes and perhaps only address what you mentioned with HAVE_O_CLOEXEC?

No, that issue has now been resolved in master. However you can rebase / squash your changes here.

@fanquake
Copy link
Member

fanquake commented Oct 5, 2022

@brokenprogrammer interested in following?

@brokenprogrammer
Copy link
Contributor Author

@fanquake So the changes are fine and what is left is simply to merge latest master and squash the changes?

@fanquake
Copy link
Member

@brokenprogrammer sorry for not following up. Changes should always be squashed. I will get to reviewing this shortly.

#if defined(HAVE_CONSENSUS_LIB)
#if HAVE_CONSENSUS_LIB
Copy link
Member

@hebasto hebasto Feb 13, 2023

Choose a reason for hiding this comment

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

Conditional calls to AC_DEFINE (such as those setting it to a constant 1, or not setting a value at all) need defined()/#ifdef AIUI

Agree with @luke-jr.

In this particular case, it is conditional:

bitcoin/configure.ac

Lines 1707 to 1710 in 8126551

if test "$build_bitcoin_libs" = "yes"; then
AC_DEFINE([HAVE_CONSENSUS_LIB], [1], [Define this symbol if the consensus lib has been built])
AC_CONFIG_FILES([libbitcoinconsensus.pc:libbitcoinconsensus.pc.in])
fi

therefore, the current code (in the master branch) is fine.

@brokenprogrammer
Copy link
Contributor Author

@fanquake No worries, I've squashed and updated the commit message according to the contributing guidelines.

@hebasto
Copy link
Member

hebasto commented Feb 14, 2023

@brokenprogrammer

I've squashed and updated the commit message according to the contributing guidelines.

A #25302 (comment) still needs to be addressed.

@hebasto
Copy link
Member

hebasto commented Feb 16, 2023

Another bug found (introduced in #20358), which needs to be addressed.

UPD. False suggestion. Sorry.

@achow101 achow101 requested a review from hebasto April 25, 2023 16:21
@@ -604,7 +604,7 @@ std::string SHA256AutoDetect()
have_x86_shani = (ebx >> 29) & 1;
}

#if defined(ENABLE_X86_SHANI) && !defined(BUILD_BITCOIN_INTERNAL)
#if ENABLE_X86_SHANI && !defined(BUILD_BITCOIN_INTERNAL)
Copy link
Contributor

@TheCharlatan TheCharlatan Apr 30, 2023

Choose a reason for hiding this comment

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

I think this is only defined conditionally:

https://github.com/bitcoin/bitcoin/blob/master/configure.ac#L569-L581

Edit: Sorry, I think I made a mistake here.
And another edit: I think I confused myself here. Shouldn't any variable that is not defined in config.status with either a "0" or "1" be checked with #if defined(...)?

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@hebasto
Copy link
Member

hebasto commented May 18, 2023

I've re-reviewed this PR and none of the suggested changes seem required to me.

More details see in #16419 (comment).

@fanquake
Copy link
Member

Going to close for now. We can continue any discussion in #16419.

@fanquake fanquake closed this May 18, 2023
fanquake added a commit to bitcoin-core/gui that referenced this pull request May 22, 2023
…MQ is not available

fa5831b build: Do not define `ENABLE_ZMQ` when ZMQ is not available (Hennadii Stepanov)

Pull request description:

  A new behavior is consistent with the other optional dependencies.

  The source code contains `#if ENABLE_ZMQ` lines only:
  ```
  $ git grep ENABLE_ZMQ -- src/*.cpp
  src/init.cpp:#if ENABLE_ZMQ
  src/init.cpp:#if ENABLE_ZMQ
  src/init.cpp:#if ENABLE_ZMQ
  src/init.cpp:#if ENABLE_ZMQ
  src/init.cpp:#if ENABLE_ZMQ
  ```

  Change in description line -- "Define to 1..." -->  "Define this symbol.." -- is motivated by the fact that the actual value of the defined `ENABLE_ZMQ` macro does not matter at all.

  Related to:
  - bitcoin/bitcoin#16419
  - bitcoin/bitcoin#25302

ACKs for top commit:
  TheCharlatan:
    ACK fa5831b
  jarolrod:
    ACK fa5831b

Tree-SHA512: 5e72ff0d34c4b33205338daea0aae8d7aa0e48fd633e21af01af32b7ddb0532ef68dd3dd74deb2c1d2599691929617e8c09676bcbaaf7d669b88816f866f1db2
@bitcoin bitcoin locked and limited conversation to collaborators May 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants