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

cmake: speed up threads setup for Windows #12202

Closed

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Oct 26, 2023

Win32 threads are always available. We enabled them unconditionally
(with ENABLE_THREADED_RESOLVER). CMake built-in thread detection
logic has this condition hard-coded for Windows as well (since at least
2007).

Instead of doing all the work of detecting pthread combinations on
Windows, then discarding those results, skip these efforts and assume
built-in thread support when building for Windows.

This saves 1-3 slow CMake configuration steps.

Closes #12202


The side effect is that on some targets phtread is no longer linked
automatically to curl even when curl itself did not require or use it.
This was seen to happen with mingw-w64 on x86 and arm64 targets
(but not with x64), causing the .map file referencing pthread lib, but
without any actual use. If a curl dependency requires pthread and the
dependency's CMake logic doesn't add it automatically, it needs to be
added manually to make it link in all cases, e.g. for BoringSSL with
mingw-w64, where it was already required for x64, but possibly worked
by accident for x86 and arm64.

Ref: curl/curl-for-win@74dd967#diff-98a81cf13297dad2803e548fe3ad9245cd8a732054f6ed89bff7360deaa3dff2R168-R170

Win32 threads are always available. We enabled them unconditionally
(with `ENABLE_THREADED_RESOLVER`). CMake built-in thread detection
logic has this condition hard-coded for Windows as well (since at least
2007).

Instead of doing all the work of detecting pthread combinations on
Windows, then discarding those results, skip these efforts and assume
built-in thread support when building for Windows.

This save 2-3 slow detection steps on CMake configuration.

Closes #xxxxx
@vszakats vszakats added cmake Windows Windows-specific labels Oct 26, 2023
@github-actions github-actions bot added the build label Oct 26, 2023
@vszakats vszakats closed this in 191e695 Oct 27, 2023
@vszakats vszakats deleted the cmake-faster-win32-threads-init branch October 27, 2023 00:39
vszakats added a commit to curl/curl-for-win that referenced this pull request Oct 27, 2023
Stop pre-filling values that are no longer used by the next curl
release.

Ref:
curl/curl#12200 `HAVE_ZSTD_CREATEDSTREAM`
curl/curl#12202 `THREADS_HAVE_PTHREAD_ARG` `CMAKE_HAVE_LIBC_PTHREAD` `CMAKE_HAVE_PTHREADS_CREATE` `CMAKE_HAVE_PTHREAD_CREATE`
curl/curl#12210 `DHAVE_VARIADIC_MACROS_C99` `HAVE_VARIADIC_MACROS_GCC`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants