cmake: tweaks around debug mode and hidden symbols

- 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
This commit is contained in:
Viktor Szakats 2024-10-25 10:47:25 +02:00
parent 0da1489eb9
commit 1db9af2b9e
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
3 changed files with 8 additions and 4 deletions

View 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()

View 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.

View 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`