]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: tweaks around debug mode and hidden symbols
authorViktor Szakats <commit@vsz.me>
Fri, 25 Oct 2024 08:47:25 +0000 (10:47 +0200)
committerViktor Szakats <commit@vsz.me>
Sun, 27 Oct 2024 13:26:45 +0000 (14:26 +0100)
- emit warning for `ENABLE_DEBUG` builds.

- add words to clarify that `ENABLE_DEBUG` is meant for developing curl
  itself.

- add comment saying `CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON`
  CMake option may export extra, non-curl symbols.
  Ref: https://github.com/microsoft/vcpkg/issues/41761
  Unexplained exports seen also in curl CI:
  ```
  [ 742] _tcschr
  [ 743] _tcsncmp
  [ 744] _tcsncpy
  [ 745] _tcspbrk
  ```
  https://ci.appveyor.com/project/curlorg/curl/builds/50864041/job/lolledrg4h7hu6e4?fullLog=true#L2160
  CMake extracts these symbols from `.obj` files:
  https://gitlab.kitware.com/cmake/cmake/-/issues/22092#note_943718
  I have not found any new MSVC option that helps fixing this without
  decorating all functions in-source or maintaining a manual list of
  internal function names used for tests:
  https://learn.microsoft.com/cpp/build/reference/wholearchive-include-all-library-object-files

Closes #15414

CMake/CurlSymbolHiding.cmake
CMakeLists.txt
docs/INSTALL-CMAKE.md

index 7668bb83577da2625dc0c87c98bda7879d10d8db..f507e45766af7f0dd46d13a295826b2b553359f9 100644 (file)
@@ -60,6 +60,7 @@ if(CURL_HIDDEN_SYMBOLS)
   endif()
 else()
   if(MSVC)
+    # Note: This option is prone to export non-curl extra symbols.
     set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
   endif()
 endif()
index 784c1dc7c208a023d892466a74ae608e925bc103..dc700046d5fd66e774243ff19fcbef5615f4b687 100644 (file)
@@ -203,8 +203,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")  # Required for sendmmsg()
 endif()
 
-option(ENABLE_DEBUG "Enable curl debug features" OFF)
-option(ENABLE_CURLDEBUG "Enable TrackMemory feature" ${ENABLE_DEBUG})
+option(ENABLE_DEBUG "Enable curl debug features (for developing curl itself)" OFF)
+if(ENABLE_DEBUG)
+  message(WARNING "This curl build is Debug-enabled, do not use in production.")
+endif()
+option(ENABLE_CURLDEBUG "Enable TrackMemory debug feature" ${ENABLE_DEBUG})
 
 if(MSVC)
   set(ENABLE_CURLDEBUG OFF)  # FIXME: TrackMemory + MSVC fails test 558 and 1330. Tested with static build, Debug mode.
index 3aa3ab5e55911cf9378d6621bc4c432e819083cd..a74e1930eadd0e9066c7a1703c63f65578694595 100644 (file)
@@ -162,9 +162,9 @@ assumes that CMake generates `Makefile`:
 - `CURL_TARGET_WINDOWS_VERSION`:            Minimum target Windows version as hex string.
 - `CURL_TEST_BUNDLES`:                      Bundle `libtest` and `unittest` tests into single binaries. Default: `OFF`
 - `CURL_WERROR`:                            Turn compiler warnings into errors. Default: `OFF`
-- `ENABLE_CURLDEBUG`:                       Enable TrackMemory feature: Default: =`ENABLE_DEBUG`
+- `ENABLE_CURLDEBUG`:                       Enable TrackMemory debug feature: Default: =`ENABLE_DEBUG`
 - `ENABLE_CURL_MANUAL`:                     Build the man page for curl and enable its `-M`/`--manual` option. Default: `ON`
-- `ENABLE_DEBUG`:                           Enable curl debug features. Default: `OFF`
+- `ENABLE_DEBUG`:                           Enable curl debug features (for developing curl itself). Default: `OFF`
 - `IMPORT_LIB_SUFFIX`:                      Import library suffix. Default: `_imp`
 - `LIBCURL_OUTPUT_NAME`:                    Basename of the curl library. Default: `libcurl`
 - `PICKY_COMPILER`:                         Enable picky compiler options. Default: `ON`