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

backport: Merge bitcoin/bitcoin#23149: build: make --enable-werror just -Werror #6596

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

knst
Copy link
Collaborator

@knst knst commented Feb 24, 2025

What was done?

Backport bitcoin#23149 introduced more strict list of warnings that are considered as compilation error.
It caused several compilation errors, that has been addressed by this PR.

It has been split to own PR for easier testing / debugging from #6577

How Has This Been Tested?

It has been tested with clang 16.0.6 and gcc 13.2.0
No compilation errors.

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

fanquake and others added 2 commits February 24, 2025 13:27
38fd709 build: make --enable-werror just -Werror (fanquake)

Pull request description:

  No longer special case a set of warnings, to make up our own -Werror,
  just use -Werror outright. This shouldn't really have any effect on
  existing builders, who were already using `--enable-werror`, and is more
  inline with what they would expect `--enable-werror` to be, which is
  erroring on any/all warnings.

  We keep `-Wno-error=return-type` because we know that is broken when using
  mingw-w64. It should only be applied when cross-compiling for Windows.

  Similar to the change in bitcoin#20544, but with (hopefully) less work-arounds,
  and other bundled changes. A step towards some configure "cleanups".

ACKs for top commit:
  hebasto:
    ACK 38fd709 (also see bitcoin#23149 (comment)), tested:
  MarcoFalke:
    Concept ACK 38fd709

Tree-SHA512: 37f1857d9408442cab63e40f9280427b73e09cdf03146b19c1339d7e44abd78e93df7f270ca1da0e83b79343cd3ea915f7b9e4e347488b5bc5ceaaa7540e5926
@knst knst added this to the 23 milestone Feb 24, 2025
Copy link

coderabbitai bot commented Feb 24, 2025

Walkthrough

The changes consist of two main modifications. First, adjustments in the build configuration simplify the handling of compiler warning flags. The logic previously used for multiple specific -Werror checks is replaced by a direct assignment of the standard error flag. Moreover, the treatment of the -Werror=return-type flag has been revised to allow the warning rather than treating it as an error, and an additional check for a new warning (-Wreorder) has been introduced.

Second, several Qt source files have been updated to modify the lambda capture semantics in signal-slot connections. The lambda expressions, which previously captured all local variables by value using [=], now capture the object’s context with [this]. This change enables direct access to class member variables and methods within the lambda functions. No public or exported entity declarations were altered.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@UdjinM6
Copy link

UdjinM6 commented Feb 24, 2025

Looks like gcc11 can't handle this. Bumping to gcc12 c0719a8 fixes the issue https://github.com/UdjinM6/dash/actions/runs/13493387032. Not sure if we need to do some other backports first though. @kwvg pls chime in.

@knst
Copy link
Collaborator Author

knst commented Feb 24, 2025

Looks like gcc11 can't handle this. Bumping to gcc12

I'd prefer to keep gcc 11 in CI so we know that our code is buildable with that "minimum" supported version and still officially support gcc 11 awhile.

I'd prepare other fix soon

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/uint256.h (1)

55-57: Enhance the TODO comment to better document the rationale.

The TODO comment could be improved to:

  1. Reference the specific GCC-11 bug/issue if available
  2. Document when this workaround can be removed (e.g., "Can be removed once minimum GCC version is >= 12")
  3. Explain why the cast is safe in this context
-    // TODO: remove this gcc-11 workaround for memcmp
-    // gcc-11 can not recognise size of internal data in std::array even if width is not zero and show this warning:
-    // error: 'int __builtin_memcmp_eq(const void*, const void*, long unsigned int)' specified bound 32 exceeds source size 0 [-Werror=stringop-overread]
+    // TODO: Remove this GCC-11 workaround once minimum GCC version is >= 12
+    // GCC-11 cannot recognize the size of internal data in std::array, resulting in:
+    // error: 'int __builtin_memcmp_eq(const void*, const void*, long unsigned int)'
+    // specified bound 32 exceeds source size 0 [-Werror=stringop-overread]
+    // The cast to const void* is safe here as WIDTH is statically verified to match m_data's size
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8af10d7 and 8b8e73c.

📒 Files selected for processing (1)
  • src/uint256.h (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-w64-mingw32 / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
  • GitHub Check: arm-linux-gnueabihf / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_multiprocess / Build depends
🔇 Additional comments (1)
src/uint256.h (1)

55-58: LGTM! The workaround effectively addresses the GCC-11 warning.

The explicit casting of data pointers to const void* is a safe solution that maintains the original functionality while avoiding the compiler warning.

@thephez
Copy link
Collaborator

thephez commented Feb 24, 2025

Looks like gcc11 can't handle this. Bumping to gcc12

I'd prefer to keep gcc 11 in CI so we know that our code is buildable with that "minimum" supported version and still officially support gcc 11 awhile.

I'd prepare other fix soon

My 22.04 machine (gcc11) built 8b8e73c 👍

@kwvg
Copy link
Collaborator

kwvg commented Feb 24, 2025

@UdjinM6, diffing upstream and our uint256.h doesn't show, from a cursory glance, anything from our end that could cause this or missing backports that could resolve this issue. This seems to be a manifestation of Bug 99578, the fix for which seems to have made it to 11.3 (source) and our containers currently ship with 11.4 (source), which makes this extra confusing.

Weird that this workaround is needed since Bitcoin maintains that master is compliable on GCC 11.1 (source).

Edit: Bitcoin Core v28.1 successfully builds with GCC 11.4, seems like we're missing something in terms of build configuration.

Build parameters:
  • Commit built: 32efe85
  • Compiler: gcc version 11.4.0 (Ubuntu 11.4.0-9ubuntu1)
  • Depends build command: CC="gcc-11 -m64" CXX="g++-11 -m64" HOST=x86_64-pc-linux-gnu make -j10 -C depends
  • Configure command: CC="gcc-11 -m64" CXX="g++-11 -m64" ./configure --prefix=$(pwd)/depends/x86_64-pc-linux-gnu --enable-debug --enable-werror --disable-ccache

@UdjinM6
Copy link

UdjinM6 commented Feb 24, 2025

CI still fails even with the workaround applied btw...

@knst knst marked this pull request as draft February 25, 2025 04:27
This workaround let enable -Werror -Wall on our CI

    In member function ‘constexpr int base_blob<BITS>::Compare(const base_blob<BITS>&) const [with unsigned int BITS = 256]’,
        inlined from ‘constexpr bool operator!=(const base_blob<256>&, const base_blob<256>&)’ at ./uint256.h:58:96,
        inlined from ‘bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock&, gsl::not_null<const CBlockIndex*>, BlockValidationState&, const CCoinsViewCache&, CDeterministicMNList&, llmq::CQuorumSnapshotManager&, bool)’ at evo/deterministicmns.cpp:818:119:
    ./uint256.h:55:77: error: ‘int __builtin_memcmp_eq(const void*, const void*, long unsigned int)’ specified bound 32 exceeds source size 0 [-Werror=stringop-overread]
       55 |     constexpr int Compare(const base_blob& other) const { return std::memcmp(m_data.data(), other.m_data.data(), WIDTH); }
          |                                                                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1plus: all warnings being treated as errors
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.

5 participants