This is a prerequisite for #31507.
- The first commit fixes a bug in the C++ atomic library check:
$ git rev-parse HEAD
01b51c0f1fa8af242fc37891d666c3d940045d80
$ cmake -B build -DAPPEND_CXXFLAGS="-Wall -Werror" 2>&1 | grep -A 8 STD_ATOMIC
-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC
-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC - Failed
-- Performing Test STD_ATOMIC_NEEDS_LINK_TO_LIBATOMIC
-- Performing Test STD_ATOMIC_NEEDS_LINK_TO_LIBATOMIC - Failed
CMake Error at cmake/module/TestAppendRequiredLibraries.cmake:91 (message):
Cannot figure out how to use std::atomic.
Call Stack (most recent call first):
cmake/introspection.cmake:23 (test_append_atomic_library)
CMakeLists.txt:453 (include)
-- Configuring incomplete, errors occurred!
- The second commit fixes a bug in the ARMv8 SHA-NI check:
$ git rev-parse HEAD
cd3353c6892e3c85bf6dc52b0e6bd98c493532b3
$ cmake -B build -DAPPEND_CXXFLAGS="-Wall -Werror" 2>&1 | grep HAVE_ARM_SHANI
-- Performing Test HAVE_ARM_SHANI
-- Performing Test HAVE_ARM_SHANI - Failed
$ grep -A25 'HAVE_ARM_SHANI' build/CMakeFiles/CMakeConfigureLog.yaml
- "Performing Test HAVE_ARM_SHANI"
directories:
source: "/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE"
binary: "/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE"
cmakeVariables:
CMAKE_CXX_COMPILE_OBJECT: "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE> -Wall -Werror"
CMAKE_CXX_FLAGS: ""
CMAKE_CXX_FLAGS_RELWITHDEBINFO: "-O2 -g"
CMAKE_CXX_LINK_EXECUTABLE: "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> "
CMAKE_CXX_LINK_NO_PIE_SUPPORTED: "1"
CMAKE_EXE_LINKER_FLAGS: ""
CMAKE_MODULE_PATH: "/home/hebasto/dev/bitcoin/cmake/module"
CMAKE_POSITION_INDEPENDENT_CODE: "ON"
buildResult:
variable: "HAVE_ARM_SHANI"
cached: true
stdout: |
Change Dir: '/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE'
Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_b4026/fast
/usr/bin/gmake -f CMakeFiles/cmTC_b4026.dir/build.make CMakeFiles/cmTC_b4026.dir/build
gmake[1]: Entering directory '/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE'
Building CXX object CMakeFiles/cmTC_b4026.dir/src.cxx.o
/usr/bin/c++ -DHAVE_ARM_SHANI -march=armv8-a+crypto -O2 -g -std=c++20 -fPIE -o CMakeFiles/cmTC_b4026.dir/src.cxx.o -c /home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE/src.cxx -Wall -Werror
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE/src.cxx: In function ‘int main()’:
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE/src.cxx:7:21: error: ‘a’ is used uninitialized [-Werror=uninitialized]
7 | vsha256h2q_u32(a, b, c);
| ~~~~~~~~~~~~~~^~~~~~~~~
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE/src.cxx:6:18: note: ‘a’ was declared here
6 | uint32x4_t a, b, c;
| ^
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE/src.cxx:7:21: error: ‘b’ is used uninitialized [-Werror=uninitialized]
7 | vsha256h2q_u32(a, b, c);
| ~~~~~~~~~~~~~~^~~~~~~~~
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE/src.cxx:6:21: note: ‘b’ was declared here
6 | uint32x4_t a, b, c;
| ^
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE/src.cxx:7:21: error: ‘c’ is used uninitialized [-Werror=uninitialized]
7 | vsha256h2q_u32(a, b, c);
| ~~~~~~~~~~~~~~^~~~~~~~~
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE/src.cxx:6:24: note: ‘c’ was declared here
6 | uint32x4_t a, b, c;
| ^
cc1plus: all warnings being treated as errors
gmake[1]: *** [CMakeFiles/cmTC_b4026.dir/build.make:78: CMakeFiles/cmTC_b4026.dir/src.cxx.o] Error 1
gmake[1]: Leaving directory '/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-35fxFE'
gmake: *** [Makefile:127: cmTC_b4026/fast] Error 2
exitCode: 2
- Fixed bugs in the SSE4.2 check:
$ cmake -B build -DAPPEND_CXXFLAGS="-Wconversion -Werror" 2>&1 | grep HAVE_SSE42
-- Performing Test HAVE_SSE42
-- Performing Test HAVE_SSE42 - Failed
$ grep -A14 'HAVE_SSE42' build/CMakeFiles/CMakeConfigureLog.yaml
- "Performing Test HAVE_SSE42"
directories:
source: "/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI"
binary: "/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI"
cmakeVariables:
CMAKE_CXX_COMPILE_OBJECT: "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE> -Wconversion -Werror"
CMAKE_CXX_FLAGS: ""
CMAKE_CXX_FLAGS_RELWITHDEBINFO: "-O2 -g"
CMAKE_CXX_LINK_EXECUTABLE: "<CMAKE_CXX_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> "
CMAKE_CXX_LINK_NO_PIE_SUPPORTED: "1"
CMAKE_CXX_LINK_PIE_SUPPORTED: "1"
CMAKE_CXX_STDLIB_MODULES_JSON: ""
CMAKE_EXE_LINKER_FLAGS: ""
CMAKE_MODULE_PATH: "/home/hebasto/dev/bitcoin/cmake/module"
CMAKE_POSITION_INDEPENDENT_CODE: "ON"
--
variable: "HAVE_SSE42"
cached: true
stdout: |
Change Dir: '/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI'
Run Build Command(s): /usr/bin/ninja-build -v cmTC_88170
[1/2] /usr/lib64/ccache/c++ -DHAVE_SSE42 -msse4.2 -O2 -g -std=c++20 -fPIE -o CMakeFiles/cmTC_88170.dir/src.cxx.o -c /home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI/src.cxx -Wconversion -Werror
FAILED: [code=1] CMakeFiles/cmTC_88170.dir/src.cxx.o
/usr/lib64/ccache/c++ -DHAVE_SSE42 -msse4.2 -O2 -g -std=c++20 -fPIE -o CMakeFiles/cmTC_88170.dir/src.cxx.o -c /home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI/src.cxx -Wconversion -Werror
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI/src.cxx: In function ‘int main()’:
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI/src.cxx:11:22: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘unsigned int’ may change value [-Werror=conversion]
11 | l = _mm_crc32_u8(l, 0);
| ^
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI/src.cxx:12:23: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘unsigned int’ may change value [-Werror=conversion]
12 | l = _mm_crc32_u32(l, 0);
| ^
/home/hebasto/dev/bitcoin/build/CMakeFiles/CMakeScratch/TryCompile-fn8wHI/src.cxx:14:12: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘int’ may change value [-Werror=conversion]
14 | return l;
| ^
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.
exitCode: 1
Similarly, the CLMUL check in minisketch was made warning-free.
The sanitizer and fuzzer checks was made warning-free.
We expect that neither the compiler flags nor the test source triggers any warnings, such as
-Wunknown-argument. Therefore, appendworking_compiler_werror_flag, as done intry_append_cxx_flags().-msse4is merely a synonym for-msse4.2in 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.
Replace -msse4 with -msse4.1 to resolve both issues.
The absence of SSE4.2 usage can be verified by building with -DAPPEND_CXXFLAGS=-mno-sse4.2.