-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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! |
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
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