From 3d812d4728ef6bc96921d5f6790d6f7781a8ddcc Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Tue, 8 Jun 2021 01:03:15 +0200 Subject: [PATCH] Do *not* use pthread, because the Mingw-w64 implementation (libwinpthread) depends on GetTickCount64() function in KERNEL32.DLL, which is not available in Windows XP. Also patch cURL to *not* use InitializeCriticalSectionEx() function, for the same reason. --- build.sh | 9 ++++++++- patch/curl_mutex_init.diff | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 patch/curl_mutex_init.diff diff --git a/build.sh b/build.sh index c18c701..74c9a71 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,10 @@ #!/bin/bash +# _ _ ____ _ +# ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| + set -e readonly MY_MARCH=i386 @@ -90,7 +96,8 @@ pkg_curl="$(find "${DEPS_DIR}" -maxdepth 1 -name 'curl-*.tar.gz' | sort -rn | he rm -rf "${CURL_DIR}" && mkdir "${CURL_DIR}" tar -xvf ${pkg_curl} --strip-components=1 -C "${CURL_DIR}" pushd "${CURL_DIR}" -CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -I\"${DEPS_DIR}/include\"" LDFLAGS="-static -L\"${DEPS_DIR}/lib\"" LIBS="-latomic -lcrypt32" ./configure --disable-shared --enable-static --disable-ldap --with-zlib="${DEPS_DIR}" --with-zstd="${DEPS_DIR}" --with-brotli="${DEPS_DIR}" --with-openssl="${DEPS_DIR}" --with-ca-bundle="cacert.pem" +patch -p1 -b < "${BASE_DIR}/patch/curl_mutex_init.diff" +CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -I\"${DEPS_DIR}/include\"" LDFLAGS="-static -no-pthread -L\"${DEPS_DIR}/lib\"" LIBS="-latomic -lcrypt32" ./configure --disable-shared --disable-pthreads --enable-static --disable-ldap --with-zlib="${DEPS_DIR}" --with-zstd="${DEPS_DIR}" --with-brotli="${DEPS_DIR}" --with-openssl="${DEPS_DIR}" --with-ca-bundle="cacert.pem" make curl_LDFLAGS=-all-static cp -vf "${CURL_DIR}/src/curl.exe" "${BASE_DIR}/curl.exe" cp -vf "${DEPS_DIR}/cacert.pem" "${BASE_DIR}/cacert.pem" diff --git a/patch/curl_mutex_init.diff b/patch/curl_mutex_init.diff new file mode 100644 index 0000000..1c50842 --- /dev/null +++ b/patch/curl_mutex_init.diff @@ -0,0 +1,19 @@ +diff --git "a/D:\\_Sandbox\\curl\\curl-src\\lib\\curl_threads.h.old" "b/D:\\_Sandbox\\curl\\curl-src\\lib\\curl_threads.h" +index e10b7a1..22fdb49 100644 +--- "a/lib/curl_threads.h" ++++ "b/lib/curl_threads.h" +@@ -37,13 +37,7 @@ + # define curl_mutex_t CRITICAL_SECTION + # define curl_thread_t HANDLE + # define curl_thread_t_null (HANDLE)0 +-# if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \ +- (_WIN32_WINNT < _WIN32_WINNT_VISTA) || \ +- (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)) +-# define Curl_mutex_init(m) InitializeCriticalSection(m) +-# else +-# define Curl_mutex_init(m) InitializeCriticalSectionEx(m, 0, 1) +-# endif ++# define Curl_mutex_init(m) InitializeCriticalSection(m) + # define Curl_mutex_acquire(m) EnterCriticalSection(m) + # define Curl_mutex_release(m) LeaveCriticalSection(m) + # define Curl_mutex_destroy(m) DeleteCriticalSection(m)