autotools: add support for mingw UWP builds

To match cmake builds.

- GHA/windows: allow autotools UWP builds.
- detect UWP and add to `buildinfo.txt`.
  Consider it enabled if `CPPFLAGS` contains `-DWINSTORECOMPAT`.
- disable telnet with UWP.
- enable Unicode with UWP.
- do not use `wldap32` with UWP.
- do not enable `USE_WIN32_CRYPTO` with UWP.
- make sure to link to `ws2_32` in UWP builds.
  To fix `undefined reference to `in6addr_any'` when linking
  `tests/server` programs. More in the comment.

Closes #16020
This commit is contained in:
Viktor Szakats 2025-01-16 16:47:15 +01:00
parent fb881abd72
commit f7bb6c1f64
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
3 changed files with 58 additions and 33 deletions

View File

@ -169,17 +169,18 @@ jobs:
strategy: strategy:
matrix: matrix:
include: include:
- { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !1233', config: '--enable-debug --disable-threaded-resolver --disable-proxy', name: '!proxy' } - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !1233', config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-proxy', name: '!proxy' }
- { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --disable-threaded-resolver', name: 'default' } - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --with-openssl --disable-threaded-resolver', name: 'default' }
- { build: 'cmake' , sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '-DENABLE_DEBUG=ON -DENABLE_THREADED_RESOLVER=OFF', name: 'default' } - { build: 'cmake' , sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '-DENABLE_DEBUG=ON -DENABLE_THREADED_RESOLVER=OFF', name: 'default' }
- { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '', name: 'default R' } - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '--with-openssl', name: 'default R' }
- { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --disable-threaded-resolver --disable-curldebug --enable-static=no --without-zlib', name: 'default' } - { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-curldebug --enable-static=no --without-zlib', name: 'default' }
- { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: '' , config: '--enable-debug --enable-windows-unicode --enable-ares', name: 'c-ares U' } - { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --enable-windows-unicode --enable-ares', name: 'c-ares U' }
# FIXME: WebSockets test results ignored due to frequent failures on native Windows: # FIXME: WebSockets test results ignored due to frequent failures on native Windows:
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', type: 'Debug', name: 'schannel c-ares U' } - { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', type: 'Debug', name: 'schannel c-ares U' }
- { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_CURLDEBUG=ON', type: 'Release', name: 'schannel R TrackMemory' } - { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_CURLDEBUG=ON', type: 'Release', name: 'schannel R TrackMemory' }
- { build: 'cmake' , sys: 'clang64', env: 'clang-x86_64', tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_OPENSSL=ON -DENABLE_UNICODE=OFF', type: 'Release', name: 'openssl' } - { build: 'cmake' , sys: 'clang64', env: 'clang-x86_64', tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_OPENSSL=ON -DENABLE_UNICODE=OFF', type: 'Release', name: 'openssl' }
- { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON', type: 'Release', test: 'uwp', name: 'schannel' } - { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON', type: 'Release', test: 'uwp', name: 'schannel' }
# { build: 'autotools', sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '--without-debug --with-schannel --enable-shared', type: 'Release', test: 'uwp', name: 'schannel' }
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON', type: 'Debug', cflags: '-DCURL_SCHANNEL_DEV_DEBUG', name: 'schannel dev debug' } - { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON', type: 'Debug', cflags: '-DCURL_SCHANNEL_DEV_DEBUG', name: 'schannel dev debug' }
- { build: 'cmake' , sys: 'mingw32', env: 'i686' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Release', name: 'schannel R' } - { build: 'cmake' , sys: 'mingw32', env: 'i686' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Release', name: 'schannel R' }
fail-fast: false fail-fast: false
@ -228,33 +229,34 @@ jobs:
- name: 'configure' - name: 'configure'
timeout-minutes: 5 timeout-minutes: 5
run: | run: |
if [ '${{ matrix.test }}' = 'uwp' ]; then
CPPFLAGS='-DWINSTORECOMPAT -DWINAPI_FAMILY=WINAPI_FAMILY_APP'
if [[ '${{ matrix.env }}' != 'clang'* ]]; then
specs="$(realpath gcc-specs-uwp)"
gcc -dumpspecs | sed -e 's/-lmingwex/-lwindowsapp -lmingwex -lwindowsapp/' -e 's/-lmsvcrt/-lucrtapp/' > "${specs}"
CFLAGS="-specs=${specs}"
CFLAGS_CMAKE="-specs=$(cygpath -w "${specs}")"
fi
fi
if [ '${{ matrix.build }}' = 'cmake' ]; then if [ '${{ matrix.build }}' = 'cmake' ]; then
if [[ '${{ matrix.env }}' = 'clang'* ]]; then if [[ '${{ matrix.env }}' = 'clang'* ]]; then
options='-DCMAKE_C_COMPILER=clang' options='-DCMAKE_C_COMPILER=clang'
else else
options='-DCMAKE_C_COMPILER=gcc' options='-DCMAKE_C_COMPILER=gcc'
fi fi
if [ '${{ matrix.test }}' = 'uwp' ]; then [ '${{ matrix.test }}' = 'uwp' ] && options+=' -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0'
options+=' -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0'
cflags='-DWINSTORECOMPAT -DWINAPI_FAMILY=WINAPI_FAMILY_APP'
if [[ '${{ matrix.env }}' != 'clang'* ]]; then
specs="$(realpath gcc-specs-uwp)"
gcc -dumpspecs | sed -e 's/-lmingwex/-lwindowsapp -lmingwex -lwindowsapp/' -e 's/-lmsvcrt/-lucrtapp/' > "${specs}"
cflags+=" -specs=$(cygpath -w "${specs}")"
fi
fi
[ '${{ matrix.type }}' = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=' [ '${{ matrix.type }}' = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG='
[ '${{ matrix.type }}' = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=' [ '${{ matrix.type }}' = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE='
cmake -B bld -G Ninja ${options} \ cmake -B bld -G Ninja ${options} \
"-DCMAKE_C_FLAGS=${{ matrix.cflags }} ${cflags}" \ "-DCMAKE_C_FLAGS=${{ matrix.cflags }} ${CFLAGS_CMAKE} ${CPPFLAGS}" \
'-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \ '-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \
-DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \ -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
-DCURL_WERROR=ON \ -DCURL_WERROR=ON \
${{ matrix.config }} ${{ matrix.config }}
else else
export CFLAGS CPPFLAGS
mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \ mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
--prefix="${HOME}"/install \ --prefix="${HOME}"/install \
--with-openssl \
--with-libssh2 \ --with-libssh2 \
--disable-dependency-tracking \ --disable-dependency-tracking \
${{ matrix.config }} ${{ matrix.config }}

View File

@ -1413,7 +1413,7 @@ AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
AC_MSG_CHECKING([whether build target supports Win32 crypto API]) AC_MSG_CHECKING([whether build target supports Win32 crypto API])
curl_win32_crypto_api="no" curl_win32_crypto_api="no"
if test "$curl_cv_native_windows" = "yes"; then if test "$curl_cv_native_windows" = "yes" -a "$curl_cv_winuwp" != "yes"; then
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[ AC_LANG_PROGRAM([[
#undef inline #undef inline
@ -1536,6 +1536,9 @@ AC_DEFUN([CURL_PREPARE_BUILDINFO], [
curl_pflags="${curl_pflags} BSD";; curl_pflags="${curl_pflags} BSD";;
esac esac
fi fi
if test "$curl_cv_winuwp" = 'yes'; then
curl_pflags="${curl_pflags} UWP"
fi
if test "$curl_cv_cygwin" = 'yes'; then if test "$curl_cv_cygwin" = 'yes'; then
curl_pflags="${curl_pflags} CYGWIN" curl_pflags="${curl_pflags} CYGWIN"
fi fi

View File

@ -492,6 +492,12 @@ dnl **********************************************************************
CURL_CHECK_COMPILER CURL_CHECK_COMPILER
CURL_CHECK_NATIVE_WINDOWS CURL_CHECK_NATIVE_WINDOWS
curl_cv_winuwp='no'
case $CPPFLAGS in
*-DWINSTORECOMPAT*) curl_cv_winuwp='yes';;
esac
CURL_SET_COMPILER_BASIC_OPTS CURL_SET_COMPILER_BASIC_OPTS
CURL_SET_COMPILER_DEBUG_OPTS CURL_SET_COMPILER_DEBUG_OPTS
CURL_SET_COMPILER_OPTIMIZE_OPTS CURL_SET_COMPILER_OPTIMIZE_OPTS
@ -873,6 +879,11 @@ AS_HELP_STRING([--disable-telnet],[Disable TELNET support]),
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
) )
if test "$curl_cv_winuwp" = 'yes'; then
AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET])
CURL_DISABLE_TELNET=1
fi
AC_MSG_CHECKING([whether to support tftp]) AC_MSG_CHECKING([whether to support tftp])
AC_ARG_ENABLE(tftp, AC_ARG_ENABLE(tftp,
AS_HELP_STRING([--enable-tftp],[Enable TFTP support]) AS_HELP_STRING([--enable-tftp],[Enable TFTP support])
@ -1146,7 +1157,9 @@ if test "$HAVE_GETHOSTBYNAME" != "1"; then
]) ])
fi fi
if test "$HAVE_GETHOSTBYNAME" != "1"; then # In UWP mode gethostbyname gets detected via the core libs, but some
# code (in6addr_any) still need ws2_32, so let us detect and add it.
if test "$HAVE_GETHOSTBYNAME" != "1" -o "$curl_cv_winuwp" = "yes"; then
dnl This is for Winsock systems dnl This is for Winsock systems
if test "$curl_cv_native_windows" = "yes"; then if test "$curl_cv_native_windows" = "yes"; then
winsock_LIB="-lws2_32" winsock_LIB="-lws2_32"
@ -1590,7 +1603,7 @@ if test x$CURL_DISABLE_LDAP != x1; then
CURL_CHECK_HEADER_LDAP_SSL CURL_CHECK_HEADER_LDAP_SSL
if test -z "$LDAPLIBNAME"; then if test -z "$LDAPLIBNAME"; then
if test "$curl_cv_native_windows" = "yes"; then if test "$curl_cv_native_windows" = "yes" -a "$curl_cv_winuwp" != "yes"; then
dnl Windows uses a single and unique LDAP library name dnl Windows uses a single and unique LDAP library name
LDAPLIBNAME="wldap32" LDAPLIBNAME="wldap32"
LBERLIBNAME="no" LBERLIBNAME="no"
@ -2595,22 +2608,29 @@ dnl ----------------------------
want_winuni="no" want_winuni="no"
if test "$curl_cv_native_windows" = "yes"; then if test "$curl_cv_native_windows" = "yes"; then
AC_MSG_CHECKING([whether to enable Windows Unicode (Windows native builds only)]) if test "$curl_cv_winuwp" = 'yes'; then
AC_ARG_ENABLE(windows-unicode, want_winuni="yes"
else
AC_MSG_CHECKING([whether to enable Windows Unicode (Windows native builds only)])
AC_ARG_ENABLE(windows-unicode,
AS_HELP_STRING([--enable-windows-unicode],[Enable Windows Unicode]) AS_HELP_STRING([--enable-windows-unicode],[Enable Windows Unicode])
AS_HELP_STRING([--disable-windows-unicode],[Disable Windows Unicode (default)]), AS_HELP_STRING([--disable-windows-unicode],[Disable Windows Unicode (default)]),
[ case "$enableval" in [ case "$enableval" in
yes) yes)
CPPFLAGS="${CPPFLAGS} -DUNICODE -D_UNICODE" want_winuni="yes"
want_winuni="yes" AC_MSG_RESULT([yes])
AC_MSG_RESULT([yes]) ;;
;; *)
*) AC_MSG_RESULT([no])
AC_MSG_RESULT([no]) ;;
;; esac ],
esac ], AC_MSG_RESULT([no])
AC_MSG_RESULT([no]) )
) fi
if test "$want_winuni" = "yes"; then
CPPFLAGS="${CPPFLAGS} -DUNICODE -D_UNICODE"
fi
fi fi
AM_CONDITIONAL([USE_UNICODE], [test "$want_winuni" = "yes"]) AM_CONDITIONAL([USE_UNICODE], [test "$want_winuni" = "yes"])