-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
lib/easy_lock.h: include synchapi.h on Windows #8997
Conversation
|
If the target version is >= 0x600 (Vista) then SRWLOCK_INIT should be defined. If it's not defined with that target version there's either a problem with our includes or the user's. I wouldn't ifdef SRWLOCK_INIT as well because it could silently build without thread safety rather than build error which is better. |
One of the appveyor builds fails on that line where it isn't defined. I have no clue why... |
I've had trouble reproducing these msys2 build environments. In this case I get more errors and I also get the missing SRWLOCK_INIT error. If I include windows.h in easy_lock.h then there's no missing SRWLOCK_INIT error but I don't understand what it is about this specific build that causes this problem and not other builds. For reference this is the build config: Lines 158 to 171 in 9651198
This is how I attempted to simulate it on my computer:
The other errors seem to be caused by werror:
I don't know why I get those errors and the CI doesn't. |
I just revisited this and I still don't know what's causing it. Interesting though HAVE_WINDOWS_H isn't defined which is probably something. edit: Unless... it's not supposed to be defined in msys? hm. Then why is Curl_win32_init called. |
Based on lines Old Mingw relies on an outdated set of Win32 headers (while mingw-w64 shares them with WINE and are fresh and more accurate). The latest old Mingw headers available for download miss In this case it's not realistic to replicate the missing header bits (they are too complicated) in curl sources, so disabling this feature seem to be the only option. |
And remember msys != mingw builds. msys is a linux emulation layer while mingw is cross-compilation for Windows. So if you compile for msys, then you are basically using emulated Linux APIs and not Windows APIs. Although msys-shell is still relevant if you compile using mingw in order to run autotools and our testsuite. Then Windows binaries (*.exe) are called from the Linux emulated shell environment. Similarily to how WSL can call Windows and Linux binaries intermixed with each other. |
@mback2k: Indeed. I could be wrong, but I surmised this is a Mingw build, otherwise (This contradicts UPDATE: Or perhaps |
You are correct, the build @jay is referring to is actually a MinGW one. The CMake generator specifies the shell, not the compiler it seems. |
Possibly original mingw is too old for the threaded support. It seems weird that we would use original mingw with msys2, since msys2 comes with the updated mingw-w64. I don't think including synchapi.h is necessary, curl_setup should have already included windows.h which would have included the macro if it was available. Just to see if it's possible I added a change that reverts the previous changes and defines SRWLOCK and SRWLOCK_INIT for original mingw. |
b54276f
to
fbbaee4
Compare
Unless I'm overlooking something, a possible new data point here: It seems we're fighting our own build settings. CMake will default to @jay's existing fix remains valid (it implements the missing env bits in curl's sources), but to avoid this class of issues, I think it'd be useful to fix |
take2 seems to have solved this so if @bagder doesn't mind I will squash it down (effectively removing his proposed changes) and it can go through CI again and be reviewed.
I don't know the reasons for this. IIRC original mingw has a really low default target like 0x400 or something. |
@jay: It happens in our own |
@jay my changes were useless so please get rid of them! |
CMake has a setting `ENABLE_INET_PTON` defaulting to `ON`, which does nothing else than fixing the Windows build target to Vista. This was done even when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. On other systems it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works equally well with or without Vista's inet_pton(). This patch drops the setting `ENABLE_INET_PTON`. inet_pton() is now used whenever building for Vista or newer, either when requested manually via `CURL_TARGET_WINDOWS_VERSION=0x600`, or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: curl#9027 (comment) Ref: curl#8997 (comment) Closes #xxxx
CMake has a setting `ENABLE_INET_PTON` defaulting to `ON`, which does nothing else than fixing the Windows build target to Vista. This was done even when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. On other systems it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works equally well with or without Vista's inet_pton(). This patch drops the setting `ENABLE_INET_PTON`. inet_pton() is now used whenever building for Vista or newer, either when requested manually via `CURL_TARGET_WINDOWS_VERSION=0x600`, or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: curl#9027 (comment) Ref: curl#8997 (comment) Closes #xxxx
- Select Windows XP target only if there was no user attempt to set it manually, either via `CURL_TARGET_WINDOWS_VERSION`, `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0xnnnn` or `-DCMAKE_C_FLAGS=/D_WIN32_WINNT=0xnnnn`. `CURL_TARGET_WINDOWS_VERSION` can now be deleted or deprecated, in favour of the universal way (above) to set the Windows target. - CMake has a setting `ENABLE_INET_PTON` defaulting to `ON`, which does nothing else than fixing the Windows build target to Vista. This was done even when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. On other systems it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works equally well with or without Vista's inet_pton(). This patch drops the setting `ENABLE_INET_PTON`. inet_pton() is now used whenever building for Vista or newer, either when requested manually via or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: curl#9027 (comment) Ref: curl#8997 (comment) Closes #xxxx
The goal of this patch is to avoid CMake forcing specific Windows versions and rely on toolchain defaults instead. - CMake had a setting `ENABLE_INET_PTON` defaulting to `ON`, which did nothing else than fixing the Windows build target to Vista. This was done even when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. On other systems it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works equally well with or without Vista's inet_pton(). This patch drops this setting. inet_pton() is now used whenever building for Vista or newer, either when requested manually via or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: curl#9027 (comment) Ref: curl#8997 (comment) - Deprecate `CURL_TARGET_WINDOWS_VERSION` in favour of the universal way of setting the Windows target version: `-D_WIN32_WINNT=0xnnnn`. This can be passed to CMake like this: `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0xnnnn` `CURL_TARGET_WINDOWS_VERSION` was introduced in early 2021, so it is also an option to delete it, if we have an agreement on that. - When the user did no select a Windows target version manually, stop explicitly targeting Windows XP, and instead use whatever the toolchain default is. This may pose an issue with old toolchains defaulting to pre-XP targets. In such case you must manually target Windows XP via: `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0x0501` Closes #xxxx
The goal of this patch is to avoid CMake forcing specific Windows versions and rely on toolchain defaults instead. This gives back control to the user. Curl is able to adapt to what's available. This also brings CMake closer to how autotools and `Makefile.m32` works in this regard. - CMake had a setting `ENABLE_INET_PTON` defaulting to `ON`, which did nothing else than fixing the Windows build target to Vista. This was done even when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. On other systems it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works equally well with or without Vista's inet_pton(). This patch drops this setting. inet_pton() is now used whenever building for Vista or newer, either when requested manually via or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: curl#9027 (comment) Ref: curl#8997 (comment) - Deprecate `CURL_TARGET_WINDOWS_VERSION` in favour of the universal way of setting the Windows target version: `-D_WIN32_WINNT=0xnnnn`. This can be passed to CMake like this: `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0xnnnn` `CURL_TARGET_WINDOWS_VERSION` was introduced in early 2021, so it is also an option to delete it, if we have an agreement on that. - When the user did no select a Windows target version manually, stop explicitly targeting Windows XP, and instead use whatever the toolchain default is. This may pose an issue with old toolchains defaulting to pre-XP targets. In such case you must manually target Windows XP via: `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0x0501` Closes #xxxx
The goal of this patch is to avoid CMake forcing specific Windows versions and rely on toolchain defaults instead. This gives back control to the user. Curl is able to adapt to what's available. This also brings CMake closer to how autotools and `Makefile.m32` behaves in this regard. - CMake had a setting `ENABLE_INET_PTON` defaulting to `ON`, which did nothing else than fixing the Windows build target to Vista. This was done even when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. On other systems it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works equally well with or without Vista's inet_pton(). This patch drops this setting. inet_pton() is now used whenever building for Vista or newer, either when requested manually via or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: curl#9027 (comment) Ref: curl#8997 (comment) - Deprecate `CURL_TARGET_WINDOWS_VERSION` in favour of the universal way of setting the Windows target version: `-D_WIN32_WINNT=0xnnnn`. This can be passed to CMake like this: `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0xnnnn` `CURL_TARGET_WINDOWS_VERSION` was introduced in early 2021, so it is also an option to delete it, if we have an agreement on that. - When the user did no select a Windows target version manually, stop explicitly targeting Windows XP, and instead use whatever the toolchain default is. This may pose an issue with old toolchains defaulting to pre-XP targets. In such case you must manually target Windows XP via: `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0x0501` Closes #xxxx
The goal of this patch is to avoid CMake forcing specific Windows versions and rely on toolchain defaults or manual selection instead. This gives back control to the user. This also brings CMake closer to how autotools and `Makefile.m32` behaves in this regard. - CMake had a setting `ENABLE_INET_PTON` defaulting to `ON`, which did nothing else than fixing the Windows build target to Vista. This also happened when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. In other environments it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works well with or without Vista's inet_pton(). This patch drops this setting. inet_pton() is now used whenever building for Vista or newer, either when requested manually or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: curl#9027 (comment) Ref: curl#8997 (comment) - When the user did no select a Windows target version manually, stop explicitly targeting Windows XP, and instead use the toolchain default. This may pose an issue with old toolchains defaulting to pre-XP targets. In such case you must manually target Windows XP via: `-DCURL_TARGET_WINDOWS_VERSION=0x0501` or `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0x0501` Closes #xxxx
- Define SRWLOCK symbols missing in some mingw environments. Closes #8997
fbbaee4
to
905ee02
Compare
- Define SRWLOCK symbols missing in some mingw environments. Closes #8997
905ee02
to
59b150a
Compare
The goal of this patch is to avoid CMake forcing specific Windows versions and rely on toolchain defaults or manual selection instead. This gives back control to the user. This also brings CMake closer to how autotools and `Makefile.m32` behaves in this regard. - CMake had a setting `ENABLE_INET_PTON` defaulting to `ON`, which did nothing else than fixing the Windows build target to Vista. This also happened when the toolchain did not have Vista support (e.g. original MinGW), breaking such builds. In other environments it did not make a user-facing difference, because libcurl has its own pton() implementation, so it works well with or without Vista's inet_pton(). This patch drops this setting. inet_pton() is now used whenever building for Vista or newer, either when requested manually or by default with modern toolchains (e.g. mingw-w64). Older envs will fall back to curl's pton(). Ref: #9027 (comment) Ref: #8997 (comment) - When the user did no select a Windows target version manually, stop explicitly targeting Windows XP, and instead use the toolchain default. This may pose an issue with old toolchains defaulting to pre-XP targets. In such case you must manually target Windows XP via: `-DCURL_TARGET_WINDOWS_VERSION=0x0501` or `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0x0501` Reviewed-by: Jay Satiro Reviewed-by: Marcel Raad Closes #9046
To make sure the SRWLOCK* macros are present
Follow-up to 23af112