Skip to content

Commit b17ef87

Browse files
committed
windows: bump minimum to Vista (from XP)
After this patch curl requires targeting Vista or newer, and a toolchain with Vista support. Supported MSVC compilers (VS2010+) all support Vista: - VS2012+ target Win8 (or later) by default. - VS2010 targets Win7 by default. Supported mingw-w64 versions (v3+) all support Vista: - mingw-w64 v9+ target Win10 by default. - mingw-w64 v8 and older target Server 2003 (~XP) by default. After this patch it may be necessary to override the default Windows target version to Vista (or newer) via: autotools: `CPPFLAGS=-D_WIN32_WINNT=0x0600` cmake: `-DCURL_TARGET_WINDOWS_VERSION=0x0600` - mingw-w64 v6+ allow changing the default at toolchain build-time. Notes: - For non-MSVC, non-mingw-w64 toolchains, `if_nametoindex` needs to be allowlisted in `curl_setup.h`, if they do support it. Fixes #17985 (discussion) Closes #18009
1 parent 6c8956c commit b17ef87

27 files changed

Lines changed: 136 additions & 611 deletions

.github/workflows/windows.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ jobs:
199199
- { build: 'cmake' , sys: 'msys' , env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DENABLE_THREADED_RESOLVER=OFF', install: 'openssl-devel libssh2-devel', name: 'default' }
200200
- { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '' , config: '--with-openssl', install: 'openssl-devel libssh2-devel', name: 'default R' }
201201
# MinGW
202-
- { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-curldebug --enable-static --without-zlib CPPFLAGS=-D_WIN32_WINNT=0x0501', install: 'mingw-w64-x86_64-openssl mingw-w64-x86_64-libssh2', name: 'default XP' }
202+
- { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-curldebug --enable-static --without-zlib', install: 'mingw-w64-x86_64-openssl mingw-w64-x86_64-libssh2', name: 'default' }
203203
- { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --enable-windows-unicode --enable-ares --with-openssl-quic --enable-static --disable-shared', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-openssl mingw-w64-x86_64-nghttp3 mingw-w64-x86_64-libssh2', name: 'c-ares U' }
204204
- { build: 'cmake' , sys: 'mingw64' , env: 'x86_64' , tflags: '--min=1650', config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-libssh2', type: 'Debug', name: 'schannel c-ares U' }
205205
# MinGW torture
@@ -443,7 +443,7 @@ jobs:
443443
env: 'x86_64'
444444
ver: '7.3.0'
445445
url: 'https://downloads.sourceforge.net/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-win32/seh/x86_64-7.3.0-release-win32-seh-rt_v5-rev0.7z'
446-
config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DCURL_USE_MBEDTLS=ON'
446+
config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DCURL_USE_MBEDTLS=ON -DCURL_TARGET_WINDOWS_VERSION=0x0600'
447447
install: mingw-w64-x86_64-mbedtls
448448
type: 'Release'
449449
tflags: 'skiprun'
@@ -453,7 +453,7 @@ jobs:
453453
env: 'i686'
454454
ver: '6.4.0'
455455
url: 'https://downloads.sourceforge.net/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/6.4.0/threads-win32/dwarf/i686-6.4.0-release-win32-dwarf-rt_v5-rev0.7z'
456-
config: '-DENABLE_DEBUG=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=OFF -DCMAKE_UNITY_BUILD=OFF'
456+
config: '-DENABLE_DEBUG=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=OFF -DCMAKE_UNITY_BUILD=OFF -DCURL_TARGET_WINDOWS_VERSION=0x0600'
457457
type: 'Debug'
458458
tflags: 'skiprun'
459459
- name: 'schannel !examples' # mingw-w64 3.0
@@ -462,7 +462,7 @@ jobs:
462462
env: 'x86_64'
463463
ver: '4.8.1'
464464
url: 'https://downloads.sourceforge.net/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.8.1/threads-win32/seh/x86_64-4.8.1-release-win32-seh-rt_v3-rev2.7z'
465-
config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON'
465+
config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DCURL_TARGET_WINDOWS_VERSION=0x0600'
466466
type: 'Debug'
467467
tflags: 'skipall'
468468
chkprefill: '' # Set it once to silence actionlint

CMakeLists.txt

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,21 +1427,9 @@ if(WIN32)
14271427
list(APPEND CURL_INCLUDES "winsock2.h")
14281428
list(APPEND CURL_INCLUDES "ws2tcpip.h")
14291429

1430-
if(HAVE_WIN32_WINNT AND HAVE_WIN32_WINNT LESS 0x0501)
1431-
# Windows XP is required for freeaddrinfo, getaddrinfo
1432-
message(FATAL_ERROR "Building for Windows XP or newer is required.")
1433-
endif()
1434-
1435-
# Pre-fill detection results based on target OS version
1436-
if(_CURL_PREFILL)
1437-
if(NOT HAVE_WIN32_WINNT OR HAVE_WIN32_WINNT LESS 0x0600 OR # older than Windows Vista
1438-
WINDOWS_STORE)
1439-
set(HAVE_IF_NAMETOINDEX 0)
1440-
unset(HAVE_IF_NAMETOINDEX CACHE)
1441-
elseif(MSVC OR MINGW)
1442-
set(HAVE_IF_NAMETOINDEX 1)
1443-
unset(HAVE_IF_NAMETOINDEX CACHE)
1444-
endif()
1430+
if(HAVE_WIN32_WINNT AND HAVE_WIN32_WINNT LESS 0x0600)
1431+
# Windows Vista is required for freeaddrinfo, getaddrinfo, if_nametoindex
1432+
message(FATAL_ERROR "Building for Windows Vista or newer is required.")
14451433
endif()
14461434
endif()
14471435

@@ -1599,10 +1587,7 @@ check_function_exists("getrlimit" HAVE_GETRLIMIT)
15991587
check_function_exists("setlocale" HAVE_SETLOCALE)
16001588
check_function_exists("setrlimit" HAVE_SETRLIMIT)
16011589

1602-
if(WIN32)
1603-
# include wincrypt.h as a workaround for mingw-w64 __MINGW64_VERSION_MAJOR <= 5 header bug */
1604-
check_symbol_exists("if_nametoindex" "winsock2.h;wincrypt.h;iphlpapi.h" HAVE_IF_NAMETOINDEX) # Windows Vista+ non-UWP */
1605-
else()
1590+
if(NOT WIN32)
16061591
check_function_exists("if_nametoindex" HAVE_IF_NAMETOINDEX) # net/if.h
16071592
check_function_exists("realpath" HAVE_REALPATH)
16081593
check_function_exists("sched_yield" HAVE_SCHED_YIELD)
@@ -2004,9 +1989,7 @@ curl_add_if("HTTPS-proxy" NOT CURL_DISABLE_PROXY AND _ssl_enabled AND (USE_OPE
20041989
OR USE_SCHANNEL OR USE_RUSTLS OR USE_MBEDTLS OR
20051990
(USE_WOLFSSL AND HAVE_WOLFSSL_BIO_NEW)))
20061991
curl_add_if("Unicode" ENABLE_UNICODE)
2007-
curl_add_if("threadsafe" HAVE_ATOMIC OR
2008-
(USE_THREADS_POSIX AND HAVE_PTHREAD_H) OR
2009-
(WIN32 AND HAVE_WIN32_WINNT GREATER_EQUAL 0x0600))
1992+
curl_add_if("threadsafe" HAVE_ATOMIC OR (USE_THREADS_POSIX AND HAVE_PTHREAD_H) OR WIN32)
20101993
curl_add_if("Debug" ENABLE_DEBUG)
20111994
curl_add_if("TrackMemory" ENABLE_CURLDEBUG)
20121995
curl_add_if("ECH" _ssl_enabled AND HAVE_ECH)

appveyor.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ if [ "${BUILD_SYSTEM}" = 'CMake' ]; then
6666
[ "${_chkprefill}" = '_chkprefill' ] && options+=' -D_CURL_PREFILL=OFF'
6767
[[ "${TARGET}" = *'ARM64'* ]] && SKIP_RUN='ARM64 architecture'
6868
[ -n "${TOOLSET:-}" ] && options+=" -T ${TOOLSET}"
69-
[ -n "${WINTARGET:-}" ] && options+=" -DCURL_TARGET_WINDOWS_VERSION=${WINTARGET}"
7069
[ "${OPENSSL}" = 'ON' ] && options+=" -DOPENSSL_ROOT_DIR=${openssl_root_win}"
7170
[ -n "${CURLDEBUG:-}" ] && options+=" -DENABLE_CURLDEBUG=${CURLDEBUG}"
7271
if [ "${APPVEYOR_BUILD_WORKER_IMAGE}" = 'Visual Studio 2013' ]; then

appveyor.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ environment:
6161
SCHANNEL: 'ON'
6262
DEBUG: 'OFF'
6363
CURLDEBUG: 'ON'
64-
- job_name: 'CM VS2010, Debug, x64, Schannel, Shared, Build-tests & examples, XP'
64+
- job_name: 'CM VS2010, Debug, x64, Schannel, Shared, Build-tests & examples'
6565
APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2013'
6666
PRJ_GEN: 'Visual Studio 10 2010'
6767
TARGET: '-A x64'
68-
WINTARGET: 0x0501 # Windows XP
6968
PRJ_CFG: Debug
7069
SCHANNEL: 'ON'
7170
SHARED: 'ON'

configure.ac

Lines changed: 26 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,22 @@ if test "$curl_cv_native_windows" = "yes"; then
579579
case "$CPPFLAGS" in
580580
*-DWINSTORECOMPAT*) curl_cv_winuwp='yes';;
581581
esac
582+
583+
AC_MSG_CHECKING([if building for Windows Vista or newer])
584+
AC_COMPILE_IFELSE([
585+
AC_LANG_PROGRAM([[
586+
#include <windows.h>
587+
]],[[
588+
#if (_WIN32_WINNT < 0x600)
589+
#error
590+
#endif
591+
]])
592+
],[
593+
AC_MSG_RESULT([yes])
594+
],[
595+
AC_MSG_RESULT([no])
596+
AC_MSG_ERROR([Building for Windows Vista or newer is required.])
597+
])
582598
fi
583599

584600
CURL_SET_COMPILER_BASIC_OPTS
@@ -2812,7 +2828,7 @@ if test "$curl_cv_native_windows" = "yes"; then
28122828
AC_MSG_CHECKING([whether to enable Windows native IDN (Windows native builds only)])
28132829
OPT_WINIDN="default"
28142830
AC_ARG_WITH(winidn,
2815-
AS_HELP_STRING([--with-winidn=PATH],[enable Windows native IDN])
2831+
AS_HELP_STRING([--with-winidn],[enable Windows native IDN])
28162832
AS_HELP_STRING([--without-winidn], [disable Windows native IDN]),
28172833
OPT_WINIDN=$withval)
28182834
case "$OPT_WINIDN" in
@@ -2821,75 +2837,18 @@ AS_HELP_STRING([--without-winidn], [disable Windows native IDN]),
28212837
want_winidn="no"
28222838
AC_MSG_RESULT([no])
28232839
;;
2824-
yes)
2825-
dnl --with-winidn option used without path
2826-
want_winidn="yes"
2827-
want_winidn_path="default"
2828-
AC_MSG_RESULT([yes])
2829-
;;
28302840
*)
2831-
dnl --with-winidn option used with path
2841+
dnl --with-winidn option
28322842
want_winidn="yes"
2833-
want_winidn_path="$withval"
2834-
AC_MSG_RESULT([yes ($withval)])
2843+
AC_MSG_RESULT([yes])
28352844
;;
28362845
esac
28372846

28382847
if test "$want_winidn" = "yes"; then
2839-
dnl WinIDN library support has been requested
2840-
clean_CPPFLAGS="$CPPFLAGS"
2841-
clean_LDFLAGS="$LDFLAGS"
2842-
clean_LDFLAGSPC="$LDFLAGSPC"
2843-
clean_LIBS="$LIBS"
2844-
WINIDN_LIBS="-lnormaliz"
2845-
WINIDN_CPPFLAGS=""
2846-
#
2847-
if test "$want_winidn_path" != "default"; then
2848-
dnl path has been specified
2849-
dnl pkg-config not available or provides no info
2850-
WINIDN_LDFLAGS="-L$want_winidn_path/lib$libsuff"
2851-
WINIDN_CPPFLAGS="-I$want_winidn_path/include"
2852-
fi
2853-
#
2854-
CPPFLAGS="$CPPFLAGS $WINIDN_CPPFLAGS"
2855-
LDFLAGS="$LDFLAGS $WINIDN_LDFLAGS"
2856-
LDFLAGSPC="$LDFLAGSPC $WINIDN_LDFLAGS"
2857-
LIBS="$WINIDN_LIBS $LIBS"
2858-
#
2859-
AC_MSG_CHECKING([if IdnToUnicode can be linked])
2860-
AC_LINK_IFELSE([
2861-
AC_LANG_PROGRAM([[
2862-
#include <windows.h>
2863-
]],[[
2864-
#if (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x600) && \
2865-
(!defined(WINVER) || WINVER < 0x600)
2866-
WINBASEAPI int WINAPI IdnToUnicode(DWORD dwFlags,
2867-
const WCHAR *lpASCIICharStr,
2868-
int cchASCIIChar,
2869-
WCHAR *lpUnicodeCharStr,
2870-
int cchUnicodeChar);
2871-
#endif
2872-
IdnToUnicode(0, NULL, 0, NULL, 0);
2873-
]])
2874-
],[
2875-
AC_MSG_RESULT([yes])
2876-
tst_links_winidn="yes"
2877-
],[
2878-
AC_MSG_RESULT([no])
2879-
tst_links_winidn="no"
2880-
])
2881-
#
2882-
if test "$tst_links_winidn" = "yes"; then
2883-
AC_DEFINE(USE_WIN32_IDN, 1, [Define to 1 if you have the `normaliz' (WinIDN) library (-lnormaliz).])
2884-
IDN_ENABLED=1
2885-
curl_idn_msg="enabled (Windows-native)"
2886-
else
2887-
AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
2888-
CPPFLAGS="$clean_CPPFLAGS"
2889-
LDFLAGS="$clean_LDFLAGS"
2890-
LDFLAGSPC="$clean_LDFLAGSPC"
2891-
LIBS="$clean_LIBS"
2892-
fi
2848+
LIBS="-lnormaliz $LIBS"
2849+
AC_DEFINE(USE_WIN32_IDN, 1, [Define to 1 if you have the `normaliz' (WinIDN) library (-lnormaliz).])
2850+
IDN_ENABLED=1
2851+
curl_idn_msg="enabled (Windows-native)"
28932852
fi
28942853
fi
28952854

@@ -4250,26 +4209,7 @@ AC_CHECK_FUNCS([\
42504209
utimes \
42514210
])
42524211

4253-
if test "$curl_cv_native_windows" = "yes"; then
4254-
AC_MSG_CHECKING([for if_nametoindex on Windows])
4255-
AC_LINK_IFELSE([
4256-
AC_LANG_PROGRAM([[
4257-
#ifndef WIN32_LEAN_AND_MEAN
4258-
#define WIN32_LEAN_AND_MEAN
4259-
#endif
4260-
#include <winsock2.h>
4261-
#include <wincrypt.h> /* workaround for mingw-w64 __MINGW64_VERSION_MAJOR <= 5 header bug */
4262-
#include <iphlpapi.h>
4263-
]],[[
4264-
if_nametoindex("");
4265-
]])
4266-
],[
4267-
AC_MSG_RESULT([yes])
4268-
AC_DEFINE(HAVE_IF_NAMETOINDEX, 1, [if you have the 'if_nametoindex' function])
4269-
],[
4270-
AC_MSG_RESULT([no])
4271-
])
4272-
else
4212+
if test "$curl_cv_native_windows" != "yes"; then
42734213
AC_CHECK_FUNCS([\
42744214
if_nametoindex \
42754215
realpath \
@@ -5369,19 +5309,8 @@ if test "$tst_atomic" = "yes"; then
53695309
SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe"
53705310
elif test "$USE_THREADS_POSIX" = "1" && test "$ac_cv_header_pthread_h" = "yes"; then
53715311
SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe"
5372-
else
5373-
AC_COMPILE_IFELSE([
5374-
AC_LANG_PROGRAM([[
5375-
#include <windows.h>
5376-
]],[[
5377-
#if (_WIN32_WINNT < 0x600)
5378-
#error
5379-
#endif
5380-
]])
5381-
],[
5382-
SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe"
5383-
],[
5384-
])
5312+
elif test "$curl_cv_native_windows" = "yes"; then
5313+
SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe"
53855314
fi
53865315

53875316
if test "$want_winuni" = "yes"; then

docs/DEPRECATE.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ email the
1212
as soon as possible and explain to us why this is a problem for you and
1313
how your use case cannot be satisfied properly using a workaround.
1414

15-
## Windows XP
16-
17-
In January 2026, curl drops support for Windows XP and Server 2003. Their
18-
"mainstream support" ended in 2014, with final updates on May 14, 2019.
19-
20-
Making the new minimum target Windows version Vista / Server 2008.
21-
2215
## c-ares 1.16.0
2316

2417
In March 2026, we drop support for all c-ares versions before 1.16.0.
@@ -77,3 +70,4 @@ CMake 3.18 was released on 2020-07-15.
7770
- Windows CE (removed in 8.18.0)
7871
- Support for Visual Studio 2008 (removed in 8.18.0)
7972
- OpenSSL 1.1.1 and older (removed in 8.18.0)
73+
- Support for Windows XP (removed in 8.19.0)

docs/INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ library check.
196196

197197
# Windows
198198

199-
Building for Windows XP is required as a minimum.
199+
Building for Windows Vista/Server 2008 is required as a minimum.
200200

201201
You can build curl with:
202202

docs/INTERNALS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ We aim to support these or later versions.
3636
- nghttp2 1.15.0 (2016-09-25)
3737
- OpenLDAP 2.0 (2000-08-01)
3838
- OpenSSL 3.0.0 (2021-09-07)
39-
- Windows XP 5.1 (2001-08-24 - 2009-04-14)
39+
- Windows Vista 6.0 (2006-11-08 - 2012-04-10)
4040
- wolfSSL 3.4.6 (2017-09-22)
4141
- zlib 1.2.5.2 (2011-12-11)
4242
- zstd 1.0 (2016-08-31)

docs/examples/block_ip.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ int main(void)
3838
}
3939
#else
4040

41-
#ifdef _WIN32
42-
#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
43-
#undef _WIN32_WINNT
44-
#define _WIN32_WINNT 0x0600 /* Requires Windows Vista */
45-
#endif
41+
#ifdef _WIN32 /* Requires Windows Vista+ */
4642
#include <winsock2.h>
4743
#include <ws2tcpip.h>
4844
#include <windows.h>

lib/cf-socket.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -440,37 +440,6 @@ int Curl_socket_close(struct Curl_easy *data, struct connectdata *conn,
440440
return socket_close(data, conn, FALSE, sock);
441441
}
442442

443-
#ifdef USE_WINSOCK
444-
/* When you run a program that uses the Windows Sockets API, you may
445-
experience slow performance when you copy data to a TCP server.
446-
447-
https://learn.microsoft.com/troubleshoot/windows-server/networking/slow-performance-copy-data-tcp-server-sockets-api
448-
449-
Work-around: Make the Socket Send Buffer Size Larger Than the Program Send
450-
Buffer Size
451-
452-
The problem described in this knowledge-base is applied only to pre-Vista
453-
Windows. Following function trying to detect OS version and skips
454-
SO_SNDBUF adjustment for Windows Vista and above.
455-
*/
456-
457-
void Curl_sndbuf_init(curl_socket_t sockfd)
458-
{
459-
int val = CURL_MAX_WRITE_SIZE + 32;
460-
int curval = 0;
461-
int curlen = sizeof(curval);
462-
463-
if(Curl_isVistaOrGreater)
464-
return;
465-
466-
if(getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *)&curval, &curlen) == 0)
467-
if(curval > val)
468-
return;
469-
470-
setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (const char *)&val, sizeof(val));
471-
}
472-
#endif /* USE_WINSOCK */
473-
474443
/*
475444
* Curl_parse_interface()
476445
*
@@ -1133,8 +1102,6 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf,
11331102

11341103
nosigpipe(cf, data, ctx->sock);
11351104

1136-
Curl_sndbuf_init(ctx->sock);
1137-
11381105
if(is_tcp && data->set.tcp_keepalive)
11391106
tcpkeepalive(cf, data, ctx->sock);
11401107

0 commit comments

Comments
 (0)