windows: reduce/stop loading DLLs at runtime#17413
windows: reduce/stop loading DLLs at runtime#17413vszakats wants to merge 15 commits intocurl:masterfrom
Conversation
dbc8ebe to
28c0786
Compare
|
Also, do we need to dynamically load any of these libraries anymore, I have a Windows XP VM and I see them there, and some of them look really old I don't know how anyone would not have them at this point, the only thing that might be an issue is Windows CE which is being deprecated so I think maybe we can link to these libraries Lines 81 to 93 in 1c31498 |
As per a quick local search WinCE doesn't have Another thing to check is if these DLLs do actually export the functions |
|
MS docs say that
|
|
The lib3026 load library calls were added in 856b133 #9412 It pre-loads the DLLs to avoid Windows loading them on each One call is gone in this PR by making the SSPI call non-dynamic. To avoid the other one, an option is to make it a non-dynamic call when building for Vista or upper, |
7a0b7e4 to
00c5c5b
Compare
|
On a thorough re-read of #9412, the issue experienced (and mitigated via DLL pre-load) Attempt to address in #17414. |
Curl_load_library from lib, drop local implementation00c5c5b to
1b4058c
Compare
- appveyor: make a job target Windows XP. - examples/block_ip: force this specific example to target Vista to make it compile when building curl for Windows XP. Fixing: ``` docs\examples\block_ip.c(157): warning C4013: 'inet_pton' undefined; assuming extern returning int docs\examples\block_ip.c(272): warning C4013: 'inet_ntop' undefined; assuming extern returning int ``` Ref: https://ci.appveyor.com/project/curlorg/curl/builds/52102142/job/2ajdluhc20r4gmmw#L530 Cherry-picked from #17413 Closes #17415
`security` is missing its implib before mingw-w64 6.0 also MSDN documents the lib as secur32. https://github.com/curl/curl/actions/runs/15173570065/job/42669218814?pr=17413 https://learn.microsoft.com/en-us/windows/win32/api/sspi/nf-sspi-initsecurityinterfacea
When targeting Vista or newer.
c8f8af6 to
8325dc6
Compare
|
@jay: Transformed this PR based on your suggestion to avoid loading DLLs dynamically |
This reverts commit 3d44751. Due to slow performance. run tests step is reaching almost 10 minutes, compared to normal 2.5 to 3 minutes.
- replace dynamic `InitSecurityInterface()` call with early binding and link `secur32` system DLL. The library and function are available in all supported curl Windows targets, meaning WinXP or newer. Add small hack for mingw32ce to make it build. - detect and use `if_nametoindex()` on Windows when available. Link `iphlpapi` system DLL. Requires targeting Vista or newer. Replacing the dynamic call and the pre-load optimization for lib3026. Suggested-by: Jay Satiro Closes curl#17413
Instead of CURL_WINDOWS_SSPI. When running CMake on Windows with no additional parameters (ie default build configuration), the generated project files do not include the `secur32.lib` library in the linker settings. This is because the relevant check was looking at `CURL_WINDOWS_SSPI` instead of `USE_WINDOWS_SSPI`. `USE_WINDOWS_SSPI` is enabled when building with SChannel (the default on Windows), or if `CURL_WINDOWS_SSPI` is specified on the command line. Follow-up to 0d71b18 #17413 Closes #17728
Static libcurl on Windows, built for Vista and up requires the iphlpapi system DLL since this curl commit: curl/curl@0d71b18 curl/curl#17413 Reported-by: Jacob Mealey Bug: curl/trurl#395 (comment)
…h cmake
- autotools: fix auto-detection on the Windows platform.
It was mis-detected when targeting Windows XP/2003 64-bit.
It was permanently undetected when building for Windows 32-bit.
```
lib/url.c: In function 'zonefrom_url':
lib/url.c:1802:18: error: implicit declaration of function 'if_nametoindex' [-Wimplicit-function-declaration]
1802 | scopeidx = if_nametoindex(zoneid);
| ^~~~~~~~~~~~~~
lib/url.c:1802:18: error: nested extern declaration of 'if_nametoindex' [-Werror=nested-externs]
```
Ref: https://github.com/curl/curl/actions/runs/16405598782/job/46351023138?pr=17982#step:10:29
Reported-by: LoRd_MuldeR
Fixes #17979
Without this patch the workaround for the 8.15.0 release is:
`export ac_cv_func_if_nametoindex=0` for Windows XP/2003 64-bit.
Background: Checking for the `if_nametoindex()` function via
`AC_CHECK_FUNCS()` (autotools) or `check_function_exists()` (cmake) do
not work on Windows, for two reasons:
- the function may be disabled at compile-time in Windows headers
when targeting old Windows versions (XP or WS2003 in curl context)
via `_WIN32_WINNT`. But it's always present in the system implib
`iphlpapi` where these checks are looking.
- for 32-bit Windows the function signature in the implib requires
a 4-byte argument, while these checks always use no arguments,
making them always fail.
- cmake: call `if_nametoindex` dynamically with mingw-w64 v1.0.
This mingw-w64 version lacks prototype and implib entry for it.
- cmake: add auto-detection for Windows and use as a fallback for
non-pre-fill cases.
- cmake: disable pre-fill with `_CURL_PREFILL=OFF`. (for testing)
- cmake: disable pre-fill for untested compilers. (i.e. non-MSVC,
non-mingw64)
- GHA/windows: make an autotools job build for Windows XP.
Follow-up to 0d71b18 #17413
Closes #17982
Seen with a non-unity, mingw-w64 CI job targeting a Vista+ Windows
version while working on a PR. This combination is not normally
tested in CI.
Fixing:
```
In file included from D:/my-cache/mingw32/i686-w64-mingw32/include/iprtrmib.h:9:0,
from D:/my-cache/mingw32/i686-w64-mingw32/include/iphlpapi.h:17,
from D:/a/curl/curl/lib/url.c:63:
D:/my-cache/mingw32/i686-w64-mingw32/include/mprapi.h:865:3: error: unknown type name 'CERT_NAME_BLOB'
CERT_NAME_BLOB *certificateNames;
^~~~~~~~~~~~~~
D:/my-cache/mingw32/i686-w64-mingw32/include/mprapi.h:887:3: error: unknown type name 'CRYPT_HASH_BLOB'
CRYPT_HASH_BLOB certBlob;
^~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/16497057672/job/46645264552?pr=18012#step:10:140
Follow-up to 0d71b18 curl#17413
Ref: curl#18009
Seen with a non-unity, mingw-w64 CI job targeting a Vista+ Windows
version while working on a PR. This combination is not normally
tested in CI.
Fixing:
```
In file included from D:/my-cache/mingw32/i686-w64-mingw32/include/iprtrmib.h:9:0,
from D:/my-cache/mingw32/i686-w64-mingw32/include/iphlpapi.h:17,
from D:/a/curl/curl/lib/url.c:63:
D:/my-cache/mingw32/i686-w64-mingw32/include/mprapi.h:865:3: error: unknown type name 'CERT_NAME_BLOB'
CERT_NAME_BLOB *certificateNames;
^~~~~~~~~~~~~~
D:/my-cache/mingw32/i686-w64-mingw32/include/mprapi.h:887:3: error: unknown type name 'CRYPT_HASH_BLOB'
CRYPT_HASH_BLOB certBlob;
^~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/16497057672/job/46645264552?pr=18012#step:10:140
Follow-up to 0d71b18 curl#17413
Ref: curl#18009
Required for mingw-w64 5.x (and older) builds targeting a Windows 7+.
mingw-w64 6+ fixed `mprapi.h` (included indirectly via `iphlpapi.h`)
to include `wincrypt.h` for the missing types.
MSVC is not affected because SDK 7.1a (the oldest MS SDK curl supports),
`mprapi.h` does include `wincrypt.h`.
Make sure to include `wincrypt.h` before including `iphlpapi.h` as
a workaround. `wincrypt.h` is used unconditionally even though it's
not available in UWP. This is safe in this context, because we use
`iphlpapi.h` for `if_nametoindex`, which is not supported and used
in UWP builds.
This fixes auto-detection that missed detecting `if_nametoindex` in
the affected combination, and this build error in non-unity builds:
```
In file included from D:/my-cache/mingw32/i686-w64-mingw32/include/iprtrmib.h:9:0,
from D:/my-cache/mingw32/i686-w64-mingw32/include/iphlpapi.h:17,
from D:/a/curl/curl/lib/url.c:63:
D:/my-cache/mingw32/i686-w64-mingw32/include/mprapi.h:865:3: error: unknown type name 'CERT_NAME_BLOB'
CERT_NAME_BLOB *certificateNames;
^~~~~~~~~~~~~~
D:/my-cache/mingw32/i686-w64-mingw32/include/mprapi.h:887:3: error: unknown type name 'CRYPT_HASH_BLOB'
CRYPT_HASH_BLOB certBlob;
^~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/16497057672/job/46645264552?pr=18012#step:10:140
This combination is not normally tested in CI. It was caught in
the `dl-mingw, CM 6.4.0-i686 schannel !unity Win7` job while working
on another PR.
Follow-up to 0d71b18 #17413
Ref: #18009
Closes #18012
replace dynamic
InitSecurityInterface()call with early binding andlink
secur32system DLL.The library and function are available in all supported curl Windows
targets, meaning WinXP or newer. Add small hack for mingw32ce to
make it build.
detect and use
if_nametoindex()on Windows when available. Linkiphlpapisystem DLL. Requires targeting Vista or newer.Replacing the dynamic call and the pre-load optimization for lib3026.
Suggested-by: Jay Satiro
rebase on GHA/windows: run tests in a WinXP build #17426 once merged.