Closed TheWorldIsNot closed 1 week ago
i suspect this is unique to windows.. the Snapshot function which this test is calling doesn't do anything with values. however, the PerfCounterValues should have been initialized correctly.
i don't have a windows machine to test this (and i'll note that our CI/CD does build and run correctly on windows). could it be something unique to mingw?
GCC's maybe-uninitialized
is just broken in recent GCC releases.
i suspect this is unique to windows.. the Snapshot function which this test is calling doesn't do anything with values. however, the PerfCounterValues should have been initialized correctly.
i don't have a windows machine to test this (and i'll note that our CI/CD does build and run correctly on windows). could it be something unique to mingw?
Thanks for the reply. I actually used to do a little experiment on my windows first, and will deploy to the CI/CD process next!
At the moment it looks like it will have to go straight to the latter process hahaha
GCC's
maybe-uninitialized
is just broken in recent GCC releases.
sad
I have not been able to reproduce this issue myself. Feel free to comment if you're taking a different set of steps to myself:
set PATH=c:\sandbox\devtools\mingw-x64\mingw64\bin;%PATH%
rm -rf build
cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=install -DBENCHMARK_ENABLE_GTEST_TESTS=FALSE
cmake --build build --config Release -j4 --target install --verbose
On the following host:
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.19045 N/A Build 19045
gcc (x86_64-win32-seh-rev0, Built by MinGW-Builds project) 14.1.0
g++ (x86_64-win32-seh-rev0, Built by MinGW-Builds project) 14.1.0
If you're running your commands differently to reveal the issue, please update here. Otherwise I'll propose to @dmah42 that this issue is closed.
-DBENCHMARK_ENABLE_GTEST_TESTS=FALSE is the key here.. the original error is in a gtest.
Noted, shall update my config and revert. Would also help if @TheWorldIsNot could please share their cmake configure command and not just the build command.
Updated to:
cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=install -DBENCHMARK_DOWNLOAD_DEPENDENCIES=TRUE
cmake --build build --config Release -j4 --target install --verbose
And builds and tests** without issues. @TheWorldIsNot please provide any other details I might have missed. N.B I'm building from v1.9.0 tag
** other than the known user_counters_tabular_test
stability issue.
Updated to:
cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=install -DBENCHMARK_DOWNLOAD_DEPENDENCIES=TRUE cmake --build build --config Release -j4 --target install --verbose
And builds and tests** without issues. @TheWorldIsNot please provide any other details I might have missed. N.B I'm building from v1.9.0 tag
** other than the known
user_counters_tabular_test
stability issue.
Thank you very much, it's running successfully.
-DBENCHMARK_ENABLE_GTEST_TESTS=FALSE is the key here.. the original error is in a gtest.
Yes, that’s key point, After setting it up this way, it worked successfully.
Describe the bug
(Initial problem) cannot build library
System
To reproduce
I trans it to windows edition as followed:
PS D:\codebase\mycodetest\thirdlib\benchmark> mingw32-make
Unfortunatly i got following output:
PS D:\codebase\mycodetest\thirdlib\benchmark> mingw32-make
[ 18%] Built target benchmark
[ 20%] Built target benchmark_main
[ 22%] Built target output_test_helper
[ 24%] Built target benchmark_test
[ 26%] Built target spec_arg_test
[ 28%] Built target spec_arg_verbosity_test
[ 29%] Built target benchmark_setup_teardown_test
[ 31%] Built target filter_test
[ 33%] Built target benchmark_min_time_flag_time_test
[ 34%] Built target benchmark_min_time_flag_iters_test
[ 36%] Built target options_test
[ 38%] Built target basic_test
[ 40%] Built target repetitions_test
[ 41%] Built target diagnostics_test
[ 42%] Built target skip_with_error_test
[ 44%] Built target donotoptimize_test
[ 46%] Built target fixture_test
[ 47%] Built target register_benchmark_test
[ 50%] Built target map_test
[ 51%] Built target multiple_ranges_test
[ 52%] Built target args_product_test
[ 54%] Built target link_main_test
[ 56%] Built target reporter_output_test
[ 57%] Built target templated_fixture_test
[ 59%] Built target user_counters_test
[ 61%] Built target perf_counters_test
[ 62%] Built target internal_threading_test
[ 64%] Built target report_aggregates_only_test
[ 66%] Built target display_aggregates_only_test
[ 68%] Built target user_counters_tabular_test
[ 70%] Built target user_counters_thousands_test
[ 72%] Built target memory_manager_test
[ 74%] Built target cxx03_test
[ 76%] Built target complexity_test
[ 78%] Built target gtest
[ 79%] Built target gmock
[ 81%] Built target gmock_main
[ 83%] Built target benchmark_gtest
[ 85%] Built target benchmark_name_gtest
[ 87%] Built target benchmark_random_interleaving_gtest
[ 89%] Built target commandlineflags_gtest
[ 91%] Built target statistics_gtest
[ 93%] Built target string_util_gtest
[ 94%] Building CXX object test/CMakeFiles/perf_counters_gtest.dir/perf_counters_gtest.cc.obj
In file included from D:/codebase/mycodetest/thirdlib/benchmark/googletest/googletest/include/gtest/gtest.h:71,
from D:/codebase/mycodetest/thirdlib/benchmark/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:51,
from D:/codebase/mycodetest/thirdlib/benchmark/googletest/googlemock/include/gmock/gmock-actions.h:146,
from D:/codebase/mycodetest/thirdlib/benchmark/googletest/googlemock/include/gmock/gmock.h:56,
from D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:5:
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc: In member function 'virtual void {anonymous}::PerfCountersTest_Read1Counter_Test::TestBody()':
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:93:22: error: '*(const std::array<long long unsigned int, 34>*)((char*)&values1 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' may be used uninitialized [-Werror=maybe-uninitialized] 93 | EXPECT_GT(values1[0], 0); | ~~~~~~~~~^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:91:21: note: '*(const std::array<long long unsigned int, 34>*)((char*)&values1 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' was declared here
91 | PerfCounterValues values1(1);
| ^~~~~~~
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:96:22: error: '*(const std::array<long long unsigned int, 34>*)((char*)&values2 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' may be used uninitialized [-Werror=maybe-uninitialized] 96 | EXPECT_GT(values2[0], 0); | ~~~~~~~~~^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:94:21: note: '*(const std::array<long long unsigned int, 34>*)((char*)&values2 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' was declared here
94 | PerfCounterValues values2(1);
| ^~~~~~~
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc: In member function 'virtual void {anonymous}::PerfCountersTest_Read2Counters_Test::TestBody()':
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:110:22: error: '*(const std::array<long long unsigned int, 34>*)((char*)&values1 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' may be used uninitialized [-Werror=maybe-uninitialized] 110 | EXPECT_GT(values1[0], 0); | ~~~~~~~~~^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:108:21: note: '*(const std::array<long long unsigned int, 34>*)((char*)&values1 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' was declared here
108 | PerfCounterValues values1(2);
| ^~~~~~~
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:111:22: error: '*(const std::array<long long unsigned int, 34>*)((char*)&values1 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[1]' may be used uninitialized [-Werror=maybe-uninitialized] 111 | EXPECT_GT(values1[1], 0); | ~~~~~~~~~^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:108:21: note: '*(const std::array<long long unsigned int, 34>*)((char*)&values1 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[1]' was declared here
108 | PerfCounterValues values1(2);
| ^~~~~~~
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:114:22: error: '*(const std::array<long long unsigned int, 34>*)((char*)&values2 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' may be used uninitialized [-Werror=maybe-uninitialized] 114 | EXPECT_GT(values2[0], 0); | ~~~~~~~~~^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:112:21: note: '*(const std::array<long long unsigned int, 34>*)((char*)&values2 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' was declared here
112 | PerfCounterValues values2(2);
| ^~~~~~~
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:115:22: error: '*(const std::array<long long unsigned int, 34>*)((char*)&values2 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[1]' may be used uninitialized [-Werror=maybe-uninitialized] 115 | EXPECT_GT(values2[1], 0); | ~~~~~~~~~^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:112:21: note: '*(const std::array<long long unsigned int, 34>*)((char*)&values2 + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[1]' was declared here
112 | PerfCounterValues values2(2);
| ^~~~~~~
In file included from D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:4:
In member function 'uint64_t benchmark::internal::PerfCounterValues::operator[](size_t) const',
inlined from 'virtual void {anonymous}::PerfCountersTest_MultiThreaded_Test::TestBody()' at D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:249:34:
D:/codebase/mycodetest/thirdlib/benchmark/src/perf_counters.h:58:61: error: '*(const std::array<long long unsigned int, 34>*)((char*)&after + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' may be used uninitialized [-Werror=maybe-uninitialized] 58 | uint64_t operator[](size_t pos) const { return values_[pos]; } | ^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc: In member function 'virtual void {anonymous}::PerfCountersTest_MultiThreaded_Test::TestBody()': D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:241:21: note: 'after' declared here 241 | PerfCounterValues after(2); | ^~~~~ In member function 'uint64_t benchmark::internal::PerfCounterValues::operator[](size_t) const', inlined from 'virtual void {anonymous}::PerfCountersTest_MultiThreaded_Test::TestBody()' at D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:249:46: D:/codebase/mycodetest/thirdlib/benchmark/src/perf_counters.h:58:61: error: '*(const std::array<long long unsigned int, 34>*)((char*)&before + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[0]' may be used uninitialized [-Werror=maybe-uninitialized]
58 | uint64_t operator[](size_t pos) const { return values_[pos]; } | ^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc: In member function 'virtual void {anonymous}::PerfCountersTest_MultiThreaded_Test::TestBody()': D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:240:21: note: 'before' declared here 240 | PerfCounterValues before(2); | ^~~~~~ In member function 'uint64_t benchmark::internal::PerfCounterValues::operator[](size_t) const', inlined from 'virtual void {anonymous}::PerfCountersTest_MultiThreaded_Test::TestBody()' at D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:250:34: D:/codebase/mycodetest/thirdlib/benchmark/src/perf_counters.h:58:61: error: '*(const std::array<long long unsigned int, 34>*)((char*)&after + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[1]' may be used uninitialized [-Werror=maybe-uninitialized] 58 | uint64_t operator[](size_t pos) const { return values_[pos]; }
| ^
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc: In member function 'virtual void {anonymous}::PerfCountersTest_MultiThreaded_Test::TestBody()':
D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:241:21: note: 'after' declared here
241 | PerfCounterValues after(2);
| ^~~~~ In member function 'uint64_t benchmark::internal::PerfCounterValues::operator[](size_t) const', inlined from 'virtual void {anonymous}::PerfCountersTest_MultiThreaded_Test::TestBody()' at D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:250:46: D:/codebase/mycodetest/thirdlib/benchmark/src/perf_counters.h:58:61: error: '*(const std::array<long long unsigned int, 34>*)((char*)&before + offsetof(benchmark::internal::PerfCounterValues, benchmark::internal::PerfCounterValues::values_)).std::array<long long unsigned int, 34>::_M_elems[1]' may be used uninitialized [-Werror=maybe-uninitialized] 58 | uint64_t operator[](size_t pos) const { return values_[pos]; } | ^ D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc: In member function 'virtual void {anonymous}::PerfCountersTest_MultiThreaded_Test::TestBody()': D:\codebase\mycodetest\thirdlib\benchmark\test\perf_counters_gtest.cc:240:21: note: 'before' declared here 240 | PerfCounterValues before(2); | ^~~~~~
cc1plus.exe: all warnings being treated as errors
mingw32-make[2]: *** [test\CMakeFiles\perf_counters_gtest.dir\build.make:76: test/CMakeFiles/perf_counters_gtest.dir/perf_counters_gtest.cc.obj] Error 1 mingw32-make[1]: *** [CMakeFiles\Makefile2:1440: test/CMakeFiles/perf_counters_gtest.dir/all] Error 2
mingw32-make: *** [Makefile:145: all] Error 2
Additional context
Before this step, following step right? I not sure about that.
PS D:\codebase\mycodetest\thirdlib\benchmark\build> cmake .. -G "MinGW Makefiles" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DCMAKE_BUILD_TYPE=Release
-- Google Benchmark version: v1.8.4-9-gc2146397, normalized to 1.8.4.9
-- Performing Test HAVE_STD_REGEX -- success
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test HAVE_PTHREAD_AFFINITY -- failed to compile
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- Looking for Google Test sources
-- Looking for Google Test sources in D:/codebase/mycodetest/thirdlib/benchmark/googletest
-- Found Google Test in D:/codebase/mycodetest/thirdlib/benchmark/googletest
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: D:/codebase/mycodetest/thirdlib/benchmark/third_party/googletest
[100%] Built target googletest
-- Configuring done (0.5s)
-- Generating done (0.8s)
-- Build files have been written to: D:/codebase/mycodetest/thirdlib/benchmark
I even had
to replace
benchmark\build\third_party\googletest
, but failed too, only one thing had changed maybe was goterr when 96%, but same problem " perf_counters_gtest.cc.obj "