cmake: fix unity with Windows Unicode + TrackMemory

Found the root cause of the startup crash in unity builds with Unicode
and TrackMemory enabled at the same time.

We must make sure that the `memdebug.h` header doesn't apply to
`lib/curl_multibyte.c` (as even noted in a comment there.) In unity
builds all headers apply to all sources, including `curl_multibyte.c`.
This probably resulted in an infinite loop on startup.

Exclude this source from unity compilation with TrackMemory enabled,
in both libcurl and curl tool. Enable unity mode for a debug Unicode
CI job to keep it tested. Also delete the earlier workaround that
fully disabled unity for affected builds.

Follow-up to d82b080f63 #12005
Follow-up to 3f8fc25720 #11095

Closes #11928
This commit is contained in:
Viktor Szakats 2023-10-03 02:27:05 +00:00
parent d82b080f63
commit f42a279ee3
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
4 changed files with 11 additions and 14 deletions

View file

@ -67,6 +67,12 @@ if(BUILD_STATIC_CURL)
set(CURLX_CFILES ${CURLTOOL_LIBCURL_CFILES})
endif()
if(ENABLE_CURLDEBUG)
# We must compile this source separately to avoid memdebug.h redefinitions
# applying to them.
set_source_files_properties(../lib/curl_multibyte.c PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
endif()
add_executable(
${EXE_NAME}
${CURL_CFILES} ${CURLX_CFILES} ${CURL_HFILES}