From: Viktor Szakats Date: Thu, 13 Mar 2025 22:53:40 +0000 (+0100) Subject: autotools: fix `dllmain.c` in unity builds X-Git-Tag: curl-8_13_0~139 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c799f608f2a063b25af28042d76a1a841e30a0df;p=thirdparty%2Fcurl.git autotools: fix `dllmain.c` in unity builds Sync it with cmake to: - exclude it from all builds except Windows and Cygwin. - exclude it from unity builds for Cygwin to avoid the included `windows.h` header interfere with the rest of the code. Also: - fix to trim ending spaces from `CSOURCES` for the `tidy` target. The solution requires a non-POSIX `-E` `sed` option. Supported by BSD and GNU implementations. Follow-up to 37523c91bc418fc734ee54f329677dc7123eb465 #16480 Follow-up to 60c3d0446546332e1645541f2dc2c072cd019fe9 #14815 Follow-up to 7860f575fe9e527ced66b31ec076914bbadd64a4 #12408 Closes #16712 --- diff --git a/configure.ac b/configure.ac index 8dc4e12f34..c8558c15cb 100644 --- a/configure.ac +++ b/configure.ac @@ -609,6 +609,7 @@ 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 7200b0925d..32e4943d08 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -31,9 +31,6 @@ configure_file("curl_config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h" curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") -# DllMain is added later for DLL builds only. -list(REMOVE_ITEM CSOURCES "dllmain.c") - list(APPEND HHEADERS "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h") # The rest of the build diff --git a/lib/Makefile.am b/lib/Makefile.am index 3cba38fafb..7edbb9303c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -68,6 +68,14 @@ AM_CFLAGS = # Makefile.inc provides the CSOURCES and HHEADERS defines include Makefile.inc +if DOING_NATIVE_WINDOWS +CSOURCES += dllmain.c +else +if DOING_CYGWIN +CSOURCES += dllmain.c +endif +endif + if USE_UNITY # Keep these separate to avoid duplicate definitions when linking libtests # in static mode. @@ -77,6 +85,11 @@ if DEBUGBUILD # applying to them. curl_EXCLUDE += memdebug.c curl_multibyte.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 @@ -162,7 +175,7 @@ endif TIDY := clang-tidy tidy: - (_csources=`echo ' $(CSOURCES)' | sed -e 's/ +/ /g' -e 's| | $(srcdir)/|g'`; \ + (_csources=`echo ' $(CSOURCES)' | sed -E -e 's/ +$$//' -e 's/ +/ /g' -e 's| | $(srcdir)/|g'`; \ $(TIDY) $$_csources $(TIDYFLAGS) $(CURL_CLANG_TIDYFLAGS) -- $(AM_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H) optiontable: diff --git a/lib/Makefile.inc b/lib/Makefile.inc index cd11cad18f..a8e4da1cf9 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -146,7 +146,6 @@ LIB_CFILES = \ cw-out.c \ cw-pause.c \ dict.c \ - dllmain.c \ doh.c \ dynbuf.c \ dynhds.c \