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

Support using mingw-std-threads in gtest_zlib #1573

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ccawley2011
Copy link
Contributor

Split out from PR #1499.

  • C++11 threads are only available in pthread-based MinGW-w64 toolchains, so mingw-std-threads is used instead. This should benefit Win32-based MinGW-w64 toolchains as well.
  • The benchmarks don't compile yet, but that requires updating the benchmark library to use mingw-std-threads. All other tests pass.

Ideally this should detect if C++11 threads are already supported in the STL and use that instead, but for now mingw-std-threads is used in all MinGW builds.

@ccawley2011 ccawley2011 mentioned this pull request Sep 13, 2023
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (4838f0e) 83.88% compared to head (032369d) 83.89%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1573   +/-   ##
========================================
  Coverage    83.88%   83.89%           
========================================
  Files          132      132           
  Lines        10843    10843           
  Branches      2801     2801           
========================================
+ Hits          9096     9097    +1     
  Misses        1048     1048           
+ Partials       699      698    -1     
Flag Coverage Δ
macos_clang 42.97% <ø> (ø)
macos_gcc 73.61% <ø> (ø)
ubuntu_clang 82.50% <ø> (ø)
ubuntu_clang_debug 82.14% <ø> (ø)
ubuntu_clang_inflate_allow_invalid_dist 82.15% <ø> (+0.22%) ⬆️
ubuntu_clang_inflate_strict 82.49% <ø> (+0.22%) ⬆️
ubuntu_clang_mmap 82.82% <ø> (ø)
ubuntu_clang_pigz 13.96% <ø> (ø)
ubuntu_clang_pigz_no_optim 11.51% <ø> (ø)
ubuntu_clang_pigz_no_threads 13.78% <ø> (ø)
ubuntu_clang_reduced_mem 82.90% <ø> (ø)
ubuntu_clang_toolchain_riscv ∅ <ø> (∅)
ubuntu_gcc 75.23% <ø> (-0.08%) ⬇️
ubuntu_gcc_aarch64 77.40% <ø> (ø)
ubuntu_gcc_aarch64_compat_no_opt 75.65% <ø> (+0.01%) ⬆️
ubuntu_gcc_aarch64_no_acle 76.16% <ø> (ø)
ubuntu_gcc_aarch64_no_neon 76.16% <ø> (ø)
ubuntu_gcc_armhf 77.47% <ø> (ø)
ubuntu_gcc_armhf_compat_no_opt 75.60% <ø> (ø)
ubuntu_gcc_armhf_no_acle 77.42% <ø> (ø)
ubuntu_gcc_armhf_no_neon 77.32% <ø> (ø)
ubuntu_gcc_armsf 74.65% <ø> (ø)
ubuntu_gcc_armsf_compat_no_opt 74.09% <ø> (ø)
ubuntu_gcc_benchmark 73.57% <ø> (ø)
ubuntu_gcc_compat_no_opt 76.84% <ø> (ø)
ubuntu_gcc_compat_sprefix 73.57% <ø> (-0.16%) ⬇️
ubuntu_gcc_m32 73.23% <ø> (ø)
ubuntu_gcc_mingw_i686 73.50% <ø> (ø)
ubuntu_gcc_mingw_x86_64 73.51% <ø> (ø)
ubuntu_gcc_mips 74.97% <ø> (ø)
ubuntu_gcc_mips64 74.98% <ø> (ø)
ubuntu_gcc_no_avx2 74.28% <ø> (-0.06%) ⬇️
ubuntu_gcc_no_ctz 74.65% <ø> (ø)
ubuntu_gcc_no_ctzll 74.64% <ø> (ø)
ubuntu_gcc_no_pclmulqdq 74.28% <ø> (ø)
ubuntu_gcc_no_sse2 74.54% <ø> (ø)
ubuntu_gcc_no_sse42 74.73% <ø> (ø)
ubuntu_gcc_o1 74.18% <ø> (ø)
ubuntu_gcc_osb ∅ <ø> (∅)
ubuntu_gcc_pigz 38.23% <ø> (ø)
ubuntu_gcc_pigz_aarch64 39.11% <ø> (+0.11%) ⬆️
ubuntu_gcc_ppc 73.92% <ø> (ø)
ubuntu_gcc_ppc64 74.36% <ø> (ø)
ubuntu_gcc_ppc64_power9 74.53% <ø> (ø)
ubuntu_gcc_ppc64le 74.43% <ø> (ø)
ubuntu_gcc_ppc64le_novsx 74.75% <ø> (ø)
ubuntu_gcc_ppc64le_power9 74.31% <ø> (ø)
ubuntu_gcc_ppc_no_power8 74.63% <ø> (ø)
ubuntu_gcc_s390x ?
ubuntu_gcc_s390x_dfltcc 71.92% <ø> (ø)
ubuntu_gcc_s390x_dfltcc_compat 73.98% <ø> (ø)
ubuntu_gcc_s390x_no_crc32 ?
ubuntu_gcc_sparc64 ?
ubuntu_gcc_sprefix 73.24% <ø> (ø)
win64_gcc 73.95% <ø> (ø)
win64_gcc_compat_no_opt 74.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
test/test_deflate_concurrency.cc 89.13% <ø> (ø)

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

endif()

target_sources(gtest_zlib PRIVATE test_deflate_concurrency.cc)
target_compile_definitions(gtest_zlib PRIVATE USE_MINGW_STDTHREAD _WIN32_WINNT=0x501)
Copy link
Member

Choose a reason for hiding this comment

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

Change USE_MINGW_STDTHREAD to HAVE_MINGW_STDTHREAD?

endif()

target_sources(gtest_zlib PRIVATE test_deflate_concurrency.cc)
target_compile_definitions(gtest_zlib PRIVATE USE_MINGW_STDTHREAD _WIN32_WINNT=0x501)
Copy link
Member

Choose a reason for hiding this comment

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

It might make better sense to add -D_WIN32_WINNT=0x501 in cmake/toolchain-mingw-i686.cmake and cmake/toolchain-mingw-x86_64.cmake instead?

@@ -245,13 +245,39 @@ if(WITH_GTEST)
target_link_libraries(gtest_zlib GTest::GTest)

find_package(Threads)
if(Threads_FOUND AND NOT BASEARCH_WASM32_FOUND)
# TODO: Should regular C++11 threads be used when MinGW-w64 is built with pthreads?
if(Threads_FOUND AND NOT BASEARCH_WASM32_FOUND AND NOT MINGW)
Copy link
Collaborator

Choose a reason for hiding this comment

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

cmake sets CMAKE_USE_PTHREADS_INIT if pthreads are available and developer can set CMAKE_THREAD_PREFER_PTHREAD before calling find_package(Threads) to prefer pthreads over any other thread implementation.

It's also possible to explicitly check if libpthread.a or libpthread.dll.a exists to see if MinGW is built with pthreads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants