From: Viktor Szakats Date: Sun, 25 Aug 2024 11:16:49 +0000 (+0200) Subject: GHA/configure-vs-cmake: add Windows build, fix issues X-Git-Tag: curl-8_10_0~122 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aaacd02466f77d03b8fdc19e91a0a3ec72f4c38a;p=thirdparty%2Fcurl.git GHA/configure-vs-cmake: add Windows build, fix issues - configure: disable pthreads by default on Windows. - configure: disable detecting `fseeko()` on Windows. (It exists in mingw-w64 2.0.0 and newer, but it's permanently ignored in CMake, as this function is never necessary on Windows.) - extend existing exceptions with their Windows variants. - `lib/formdata.c`: prioritize `_fseeki64()` over `fseeko()`. To reduce the difference between Windows builds, which now all use `_fseeki64()`. - cmake: perm-enable `HAVE_DIRENT_H` and `HAVE_OPENDIR` for mingw-w64, to match configure. Follow-up to bfe54b0e88239da542493321e795cd71c14af9cc #13137 This in theory could make the dir listing feature work in mingw-w64 build, but in my tests (on WINE) it failed at the preceding `open()` call. - cmake: perm-enable `HAVE_STRINGS_H` and `HAVE_UTIME_H` for mingw-w64, to match configure. (They are wrappers and make no difference in the build.) Also: - configure: sync `USE_MANUAL` macro with cmake, by only setting it for `src`. Drop checker exception. - CI: use `--disable-dependency-tracking` in existing jobs. - CI: install packages before git checkout, in existing jobs. Closes #14678 --- diff --git a/.github/scripts/cmp-config.pl b/.github/scripts/cmp-config.pl index 49c8d06769..9046ad2961 100755 --- a/.github/scripts/cmp-config.pl +++ b/.github/scripts/cmp-config.pl @@ -37,10 +37,15 @@ my %remove = ( '#define _FILE_OFFSET_BITS 64' => 1, '#define CURL_EXTERN_SYMBOL' => 1, '#define CURL_SA_FAMILY_T sa_family_t' => 1, + '#define CURL_SA_FAMILY_T ADDRESS_FAMILY' => 1, + '#define HAVE_ADDRESS_FAMILY 1' => 1, '#define GETHOSTNAME_TYPE_ARG2 size_t' => 1, + '#define GETHOSTNAME_TYPE_ARG2 int' => 1, '#define HAVE_BROTLI 1' => 1, '#define HAVE_BROTLI_DECODE_H 1' => 1, '#define HAVE_DECL_GETPWUID_R 1' => 1, + '#define HAVE_DECL_GETPWUID_R 0' => 1, + '#define HAVE_DECL_GETPWUID_R_MISSING 1' => 1, '#define HAVE_DLFCN_H 1' => 1, '#define HAVE_GETHOSTBYNAME 1' => 1, '#define HAVE_INTTYPES_H 1' => 1, @@ -78,7 +83,6 @@ my %remove = ( '#define PACKAGE_URL ""' => 1, '#define PACKAGE_VERSION "-"' => 1, '#define SIZEOF_LONG_LONG 8' => 1, - '#define USE_MANUAL 1' => 1, '#define VERSION "-"' => 1, ); diff --git a/.github/workflows/configure-vs-cmake.yml b/.github/workflows/configure-vs-cmake.yml index d8580b973a..fefb138ec1 100644 --- a/.github/workflows/configure-vs-cmake.yml +++ b/.github/workflows/configure-vs-cmake.yml @@ -37,7 +37,7 @@ jobs: - name: run configure --with-openssl run: | autoreconf -fi - ./configure --with-openssl --without-libpsl + ./configure --disable-dependency-tracking --with-openssl --without-libpsl - name: run cmake run: | @@ -49,16 +49,16 @@ jobs: check-macos: runs-on: macos-latest steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - - name: install packages run: | while [[ $? == 0 ]]; do for i in 1 2 3; do brew update && brew install libtool autoconf automake && break 2 || { echo Error: wait to try again; sleep 10; } done; false Too many retries; done + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: run configure --with-openssl run: | autoreconf -fi - ./configure --with-openssl --without-libpsl + ./configure --disable-dependency-tracking --with-openssl --without-libpsl - name: run cmake run: | @@ -68,3 +68,28 @@ jobs: - name: compare generated curl_config.h files run: ./.github/scripts/cmp-config.pl lib/curl_config.h build/lib/curl_config.h + + check-windows: + runs-on: ubuntu-latest + env: + TRIPLET: 'x86_64-w64-mingw32' + steps: + - name: install packages + run: sudo apt-get --quiet 2 --option Dpkg::Use-Pty=0 install mingw-w64 + + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + + - name: run configure --with-schannel + run: | + autoreconf -fi + ./configure --disable-dependency-tracking --with-schannel --without-libpsl --host=${TRIPLET} \ + + - name: run cmake + run: | + cmake -B build -DCURL_USE_SCHANNEL=ON -DCURL_USE_LIBPSL=OFF \ + -DCMAKE_SYSTEM_NAME=Windows \ + -DCMAKE_C_COMPILER_TARGET=${TRIPLET} \ + -DCMAKE_C_COMPILER=${TRIPLET}-gcc + + - name: compare generated curl_config.h files + run: ./.github/scripts/cmp-config.pl lib/curl_config.h build/lib/curl_config.h diff --git a/CMake/Platforms/WindowsCache.cmake b/CMake/Platforms/WindowsCache.cmake index 2d6373de51..317f21c875 100644 --- a/CMake/Platforms/WindowsCache.cmake +++ b/CMake/Platforms/WindowsCache.cmake @@ -41,6 +41,10 @@ if(MINGW) set(HAVE_SYS_PARAM_H 1) set(HAVE_SYS_TIME_H 1) set(HAVE_GETTIMEOFDAY 1) + set(HAVE_STRINGS_H 1) # wrapper to string.h + set(HAVE_UTIME_H 1) # wrapper to sys/utime.h + set(HAVE_DIRENT_H 1) + set(HAVE_OPENDIR 1) else() set(HAVE_LIBGEN_H 0) set(HAVE_STRCASECMP 0) @@ -48,6 +52,10 @@ else() set(HAVE_SYS_PARAM_H 0) set(HAVE_SYS_TIME_H 0) set(HAVE_GETTIMEOFDAY 0) + set(HAVE_STRINGS_H 0) + set(HAVE_UTIME_H 0) + set(HAVE_DIRENT_H 0) + set(HAVE_OPENDIR 0) if(MSVC) set(HAVE_UNISTD_H 0) set(HAVE_LOCALE_H 1) @@ -121,7 +129,6 @@ set(HAVE_IOCTL_SIOCGIFADDR 0) set(HAVE_POLL_H 0) set(HAVE_POLL_FINE 0) set(HAVE_PWD_H 0) -set(HAVE_STRINGS_H 0) # mingw-w64 has it (wrapper to string.h) set(HAVE_SYS_EVENTFD_H 0) set(HAVE_SYS_FILIO_H 0) set(HAVE_SYS_WAIT_H 0) @@ -137,13 +144,9 @@ set(HAVE_SYS_UN_H 0) set(HAVE_SYS_UTIME_H 1) set(HAVE_TERMIOS_H 0) set(HAVE_TERMIO_H 0) -set(HAVE_UTIME_H 0) # mingw-w64 has it (wrapper to sys/utime.h) set(HAVE_LINUX_TCP_H 0) -set(HAVE_DIRENT_H 0) -set(HAVE_OPENDIR 0) - -set(HAVE_FSEEKO 0) +set(HAVE_FSEEKO 0) # mingw-w64 2.0.0 and newer has it set(HAVE__FSEEKI64 1) set(HAVE_SOCKET 1) set(HAVE_SELECT 1) diff --git a/configure.ac b/configure.ac index d6521b8b80..5874b40022 100644 --- a/configure.ac +++ b/configure.ac @@ -4003,7 +4003,6 @@ AC_CHECK_FUNCS([\ arc4random \ eventfd \ fnmatch \ - fseeko \ geteuid \ getpass_r \ getppid \ @@ -4024,14 +4023,18 @@ AC_CHECK_FUNCS([\ utimes \ ]) -dnl On Android, the only way to know if fseeko can be used is to see if it is -dnl declared or not (for this API level), as the symbol always exists in the -dnl lib. -AC_CHECK_DECL([fseeko], - [AC_DEFINE([HAVE_DECL_FSEEKO], [1], - [Define to 1 if you have the fseeko declaration])], - [], - [[#include ]]) +if test "$curl_cv_native_windows" != 'yes'; then + AC_CHECK_FUNCS([fseeko]) + + dnl On Android, the only way to know if fseeko can be used is to see if it is + dnl declared or not (for this API level), as the symbol always exists in the + dnl lib. + AC_CHECK_DECL([fseeko], + [AC_DEFINE([HAVE_DECL_FSEEKO], [1], + [Define to 1 if you have the fseeko declaration])], + [], + [[#include ]]) +fi CURL_CHECK_NONBLOCKING_SOCKET @@ -4053,7 +4056,6 @@ dnl If the manual variable still is set, then we go with providing a built-in dnl manual if test "$USE_MANUAL" = "1"; then - AC_DEFINE(USE_MANUAL, 1, [If you want to build curl with the built-in manual]) curl_manual_msg="enabled" fi @@ -4096,8 +4098,13 @@ AS_HELP_STRING([--disable-pthreads],[Disable POSIX threads]), want_pthreads=yes ;; esac ], [ - AC_MSG_RESULT(auto) - want_pthreads=auto + if test "$curl_cv_native_windows" = "yes"; then + AC_MSG_RESULT(no) + want_pthreads=no + else + AC_MSG_RESULT(auto) + want_pthreads=auto + fi ] ) diff --git a/lib/formdata.c b/lib/formdata.c index 7a282bdd3d..c260d442bd 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -790,10 +790,10 @@ static CURLcode setname(curl_mimepart *part, const char *name, size_t len) /* wrap call to fseeko so it matches the calling convention of callback */ static int fseeko_wrapper(void *stream, curl_off_t offset, int whence) { -#if defined(HAVE_FSEEKO) && defined(HAVE_DECL_FSEEKO) - return fseeko(stream, (off_t)offset, whence); -#elif defined(HAVE__FSEEKI64) +#if defined(HAVE__FSEEKI64) return _fseeki64(stream, (__int64)offset, whence); +#elif defined(HAVE_FSEEKO) && defined(HAVE_DECL_FSEEKO) + return fseeko(stream, (off_t)offset, whence); #else if(offset > LONG_MAX) return -1; diff --git a/src/Makefile.am b/src/Makefile.am index a68e5c5e87..76af4602fc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -113,6 +113,7 @@ CS_ = $(CS_0) if USE_MANUAL # Here are the stuff to create a built-in manual +AM_CPPFLAGS += -DUSE_MANUAL $(ASCIIPAGE): cd $(top_builddir)/docs && $(MAKE)