From: Jeremy Drake Date: Tue, 3 Jun 2025 17:35:46 +0000 (-0700) Subject: dllmain: exclude from Cygwin builds X-Git-Tag: curl-8_14_1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a30481760f1f7bfb7928d0b22d49a5ae263386f;p=thirdparty%2Fcurl.git dllmain: exclude from Cygwin builds On Cygwin, it is unsafe to call POSIX functions from DllMain, which OPENSSL_thread_stop does. Additionally, it should be unnecessary as OpenSSL uses pthread_key_create to register a thread destructor to do thread cleanup in a POSIX way. Reported-by: Yuyi Wang Ref: https://cygwin.com/pipermail/cygwin/2025-June/258235.html Fixes #17262 Closes https://github.com/curl/curl/pull/17528 --- diff --git a/configure.ac b/configure.ac index 9529dc95ff..9a5dd60f6c 100644 --- a/configure.ac +++ b/configure.ac @@ -637,7 +637,6 @@ curl_cv_cygwin='no' case $host_os in cygwin*|msys*) curl_cv_cygwin='yes';; esac -AM_CONDITIONAL(DOING_CYGWIN, test "x$curl_cv_cygwin" = xyes) AM_CONDITIONAL([HAVE_WINDRES], [test "$curl_cv_native_windows" = "yes" && test -n "${RC}"]) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 12840952b3..9ab9e01857 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -179,15 +179,8 @@ if(BUILD_SHARED_LIBS) list(APPEND libcurl_export ${LIB_SHARED}) add_library(${LIB_SHARED} SHARED ${LIB_SOURCE}) add_library(${PROJECT_NAME}::${LIB_SHARED} ALIAS ${LIB_SHARED}) - if(WIN32 OR CYGWIN) - if(CYGWIN) - # For Cygwin always compile dllmain.c as a separate unit since it - # includes windows.h, which should not be included in other units. - set_source_files_properties("dllmain.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) - endif() - set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "dllmain.c") - endif() if(WIN32) + set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "dllmain.c") set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "libcurl.rc") if(CURL_HIDES_PRIVATE_SYMBOLS) set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "${PROJECT_SOURCE_DIR}/lib/libcurl.def") diff --git a/lib/Makefile.am b/lib/Makefile.am index 8dac236606..463b72ed8e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -74,10 +74,6 @@ include Makefile.inc if DOING_NATIVE_WINDOWS CSOURCES += dllmain.c -else -if DOING_CYGWIN -CSOURCES += dllmain.c -endif endif if USE_UNITY @@ -89,11 +85,6 @@ if CURLDEBUG # applying to it. curl_EXCLUDE += memdebug.c endif -# For Cygwin always compile dllmain.c as a separate unit since it -# includes windows.h, which should not be included in other units. -if DOING_CYGWIN -curl_EXCLUDE += dllmain.c -endif libcurl_unity.c: $(top_srcdir)/scripts/mk-unity.pl $(CSOURCES) @PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CSOURCES) --exclude $(curl_EXCLUDE) > libcurl_unity.c diff --git a/lib/dllmain.c b/lib/dllmain.c index 41e97b37eb..33076e0571 100644 --- a/lib/dllmain.c +++ b/lib/dllmain.c @@ -28,22 +28,13 @@ #include #endif -/* The fourth-to-last include */ -#ifdef __CYGWIN__ -#define WIN32_LEAN_AND_MEAN -#include -#ifdef _WIN32 -#undef _WIN32 -#endif -#endif - /* The last 3 #include files should be in this order */ #include "curl_printf.h" #include "curl_memory.h" #include "memdebug.h" -/* DllMain() must only be defined for Windows and Cygwin DLL builds. */ -#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(CURL_STATICLIB) +/* DllMain() must only be defined for Windows DLL builds. */ +#if defined(_WIN32) && !defined(CURL_STATICLIB) #if defined(USE_OPENSSL) && \ !defined(OPENSSL_IS_AWSLC) && \