#36554 cmake: Reject warnings in `check_cxx_source_compiles_with_flags()`, use `-msse4.1` for SHA-NI

ReviewabilityReviewsAgreementSize
#36554 hebasto cmake: Reject warnings in `check_cxx_source_compiles_with_flags()`, use `-msse4.1` for SHA-NIReady1Strong20
  • Prevent build failures and falsely disabled CPU optimizations when compiling with strict warning flags
  • Ensure CMake feature detection succeeds across supported compilers including clang-cl
  • Ready to review
  • Verified by testing SHA-NI detection and multi-platform Guix builds against configuration logs (hodlinator)
  • Concept approval without stated reasons (fanquake)
  • 20 lines added or modified outside tests
  • 0 lines added or modified in tests
  • 14 lines removed in total
  • 6 files, 7 commits
Build and CI#6 of 56
P2 · bug fix
  • P2 after comparing with the other PRs here (assessed alone as P3): Raised to P2 and moved up from 37: stated prerequisite for the clang-cl switch (#31507) and fixes SHA-NI being silently disabled under -Werror, so it cannot sit far below the work it unblocks
  • P3 because it fixes configure-time false negatives when users or CI pass warning flags like -Werror
  • Prevents hardware acceleration features from being silently disabled during CMake introspection
  • Resolves clang-cl compiler rejection of SHA-NI flags
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Updates CMake's `check_cxx_source_compiles_with_flags()` to treat compiler warnings as errors, cleans up compiler warning triggers across several feature detection snippets, and changes the x86 SHA-NI flag from `-msse4` to `-msse4.1`.

Problem: When users or build environments pass warning flags such as `-Wall -Werror` via `APPEND_CXXFLAGS`, several CMake introspection snippets fail to compile due to unused variables, uninitialized reads, or implicit conversions, falsely disabling optimizations or failing configuration entirely. Additionally, `check_cxx_source_compiles_with_flags()` previously allowed warnings like `-Wunknown-argument` without failing, and the `clang-cl` compiler rejects `-msse4` even though x86 SHA-NI only requires SSE4.1.

Evidence of importance:

  • PR description demonstrates build configuration failure when passing `-DAPPEND_CXXFLAGS="-Wall -Werror"`: 'CMake Error at cmake/module/TestAppendRequiredLibraries.cmake:91 (message): Cannot figure out how to use std::atomic.'
  • PR description demonstrates ARMv8 SHA-NI detection failing under `-Werror=uninitialized` and SSE4.2 detection failing under `-Werror=conversion`
  • Commit message for 5bb7c5646a: '-msse4 is merely a synonym for -msse4.2 in both GCC and Clang, but it is not accepted by the clang-cl frontend. Furthermore, the x86 SHA-NI code uses only SSE4.1 intrinsics and no SSE4.2 ones.'

Scope: Touches only CMake build scripts and configure-time test compilation snippets.

Risk of a mistake: low (build). A flaw in feature test snippets could erroneously enable or disable CPU hardware acceleration features or fail CMake configuration.

Changed since the previous assessment: No substantial changes to the approach or scope since the previous review.

Reviewability

Ready

Nothing known that would invalidate a review now.

Waiting on (from the thread read):

  • nothing

Agreement

Strong

substantive support, no open objection (hodlinator, hodlinator)

Thread notes: Added fanquake's Concept ACK. hodlinator commented on CMake test result granularity and potential CI ideas, which was not a claim on the PR.

Objections, suggestions, and questions: none recorded.

Support:

  • hodlinator (member) (ACK, 2026-10-19) [tested]: tested that the HAVE_X86_SHANI test succeeded
  • hodlinator (member) (ACK, 2026-10-21) [tested]: tested Guix builds across multiple platforms and compared CMakeConfigureLog output against PR base
  • fanquake (member) (Concept ACK, 2026-10-30): (no reason given) [not substantive]

Participants:

  • hodlinator (member, support, 3 statements 2026-10-19 to 2026-10-30): tested Guix builds across multiple architectures, verified CMake configuration logs, and mused on CI testing
  • fanquake (member, support, 1 statements 2026-10-30 to 2026-10-30): Concept ACK

Dependencies

Enables:

Files

0 lines under test/bench/ci.

  • cmake/crc32c.cmake +5/-5
  • CMakeLists.txt +4/-2
  • cmake/introspection.cmake +4/-2
  • cmake/module/CheckSourceCompilesWithFlags.cmake +4/-2
  • cmake/minisketch.cmake +2/-2
  • cmake/module/TestAppendRequiredLibraries.cmake +1/-1

Card

The short text the ranking pass compares across PRs.

This pull request cleans up CMake feature detection snippets to eliminate compiler warnings and configures `check_cxx_source_compiles_with_flags()` to treat warnings as errors. It also switches the x86 SHA-NI compiler flag from `-msse4` to `-msse4.1`. This fixes configuration errors and disabled optimizations when building with strict warning flags like `-Werror`, and unblocks native Windows compilation using clang-cl as tracked in #31507.

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-31T01:17, confidence high, input hash 29fe5244d2b24967
thread read through 2026-10-30 (9 statements), head 5bb7c5646a
labels: Build system

Categories

Build and CI

P2 · bug fix (assessed alone as P3; Raised to P2 and moved up from 37: stated prerequisite for the clang-cl switch (#31507) and fixes SHA-NI being silently disabled under -Werror, so it cannot sit far below the work it unblocks)

Fixes CMake configure-time false negatives where passing compiler warning flags like `-Wall -Werror` failed feature detection and disabled optimizations. It also resolves a compiler incompatibility where `clang-cl` rejected `-msse4` for x86 SHA-NI detection.

Membership: Matches the 'Build system' label and directly modifies CMake build scripts and configure-time test compilation checks.

Factors: security/stability 0, bug 1, performance 0, user value 0, leverage 1