From 1db9af2b9e13b37dfad6ce0ba61e3af9a79149e3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 25 Oct 2024 10:47:25 +0200 Subject: [PATCH] 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 --- CMake/CurlSymbolHiding.cmake | 1 + CMakeLists.txt | 7 +++++-- docs/INSTALL-CMAKE.md | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMake/CurlSymbolHiding.cmake b/CMake/CurlSymbolHiding.cmake index 7668bb8357..f507e45766 100644 --- a/CMake/CurlSymbolHiding.cmake +++ b/CMake/CurlSymbolHiding.cmake @@ -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() diff --git a/CMakeLists.txt b/CMakeLists.txt index 784c1dc7c2..dc700046d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md index 3aa3ab5e55..a74e1930ea 100644 --- a/docs/INSTALL-CMAKE.md +++ b/docs/INSTALL-CMAKE.md @@ -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` -- 2.47.3