]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
dllmain: exclude from Cygwin builds
authorJeremy Drake <github@jdrake.com>
Tue, 3 Jun 2025 17:35:46 +0000 (10:35 -0700)
committerJay Satiro <raysatiro@yahoo.com>
Tue, 3 Jun 2025 18:30:31 +0000 (14:30 -0400)
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

configure.ac
lib/CMakeLists.txt
lib/Makefile.am
lib/dllmain.c

index 9529dc95ff406f7a89b5ff7681b6db28db4c1dd9..9a5dd60f6cf27af0ea17e33f4020366896f1c3dc 100644 (file)
@@ -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}"])
index 12840952b38f3973ff39223e3150eae7dd6053b7..9ab9e01857a55fba17f390293a0ad7022d8f1262 100644 (file)
@@ -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")
index 8dac236606f5cff77f5a8931fec5e7f4c91b4ab4..463b72ed8e458c4dc1122f000e9635e4c3e1d93b 100644 (file)
@@ -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
 
index 41e97b37eb5e26e70c870517ea91df9aa6cf0c22..33076e057145019ba126e4e972bfdf61a4259319 100644 (file)
 #include <openssl/crypto.h>
 #endif
 
-/* The fourth-to-last include */
-#ifdef __CYGWIN__
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#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) && \