Repository navigation
Conversation
This reverts commit 799bd84.
Let's drop the static CRT idea for a while, it's a mess: https://ci.appveyor.com/project/curlorg/curl/builds/54862718/job/f2nbu2lupscfskb1 Also existing logic is incorrect. Pbly the version gate is wrong (should be extended to all VS version *), plus it should not only be limited to static curl.exe, but also to static test binaries. If a static-CRT binary uses libcurl DLL, there are two active CRTs, which is causing several of the oddities seen since yesterday, when trying to run tests.
It cannot and does not work. Crashes, parallel buffering of curl_mprintf() and puts(), causing lines output in the wrong order -> Protocol/Feature -V lines sticking together -> Perl unable to parse the Features: line -> Perl warning about uninit $feat var. Also possibly the assert/debug crash on exit is also a result of this.
…ls on old MSVCs" This reverts commit f6265f2. This doesn't seem necessary, static CRT seems to work now with older MSVC. Jobs are still flaky, so this assesment may yet change.
CURL_STATIC_CRT=ONCURL_STATIC_CRT=ON
CURL_STATIC_CRT=ONCURL_STATIC_CRT=ON option
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues remain.
0 open findings
What changed in this PR
Restricts CURL_STATIC_CRT=ON to static-only CMake builds to avoid mixed CRT runtime issues.
Changes:
- Applies static CRT settings only when shared libraries are disabled.
- Updates CMake documentation and warning text.
| File | Summary |
|---|---|
docs/INSTALL-CMAKE.md |
Documents static library and executable requirements. |
CMakeLists.txt |
Restricts static CRT configuration to static builds. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
It should be possible to use a DLL with its own static CRT though typically if there's a static CRT it is set in the configuration you are aiming for. However I think that requiring this could possibly break builds (of course they could adjust) but I just don't know what use cases there are for this. Maybe there are some? I'd save this to the next feature window, or maybe ask on the mailing list if anyone is doing it the DLL+static CRT way and why. |
Yes, I suspect there may be possible valid cases when a static CRT makes Based on the little/no feedback, or requests, my suspicion is that there is very Waiting for the next feature window sounds overly long to me, it'd block the |
CURL_STATIC_CRT=ON optionCURL_STATIC_CRT=ON option
CURL_STATIC_CRT=ON optionCURL_STATIC_CRT=ON
|
I guess I'm missing something. What exactly does this block or fix? Isn't only the case when the user explicitly requests What I'm concerned about is if the user e.g. builds both static and shared versions of libcurl, without tests or the tool, and uses a static CRT in their application. Before this, they got versions working correctly, even if they had to know what they're doing for the DLL. Now, after updating libcurl, they get their manually set flag ignored, a CMake warning that's easy to miss, and later linker errors in their application that they need to track down. For such cases, I'd rather let the curl build fail than doing something different to what's explicitly requested by the user. |
When passing
I don't find this useful, sorry. Is this a common case, that suddently Frustrating! edit: What would be helpful is any actual proposal or idea that help |
|
I'm not saying I'm against this, or that strongly suggesting to users not to use this combination is a bad idea. What I'm trying to say is that I'd rather turn the warning into an error instead of doing the opposite of what the user explicitly requests. Either way, this is a breaking change for users running into this case as they will get a broken build - either immediately when building libcurl, or later when building their application. As a user, I always prefer the former. |
For testing purposes this option is enabled for all jobs in AppVeyor CI, We aim to warn only when it makes sense to avoid fatigue; for this |
When a curl binary is built with Visual Studio in debug mode, it uses the matching, debug-enabled CRT. The debug CRT by default pops up an interactive GUI dialog by default, also on CI machines, both on AppVeyor CI and GHA, on `assert()` and other low-level failures. This causes the CI job to appear hung, with nothing printed to the CI log, invisibly waiting for someone clicking on a GUI MessageBox. On a remote/headless CI machine this is unworkable. The job then quits on timeout, after blocking other queued tasks (for 1 hour on AppVeyor CI, 10-15 minutes in GHA/windows). To make such failures CI-friendly, fix by configuring this behavior in `curl.exe`, `servers.exe` and unit test binaries, to output all errors to stderr, and to `OutputDebugString()`, overiding the GUI popup. This can save a lot of hair-pulling. Example output, after this patch: ``` Assertion failed: r == 10, file C:\projects\curl\tests\libtest\first.c, line 272 abort() has been called ``` Note, the default debug CRT behavior depends on a number of things, e.g. on a Server Core (or similar) Windows edition, or when run under a debugger. Assuming the default behavior is the expected one in most cases, this patch only reconfigures it for builds made in the curl CI. If you want to enable it, set the `CURL_CI` env to non-empty at configure time, or build with the `-DCURL_DEBUG_MSVC_CRTDBG` C macro. This issue does not apply to mingw-w64 builds, as tested with both UCRT and MSVCRT. They output the assert text to the CI logs out-of-the-box. Refs: https://learn.microsoft.com/cpp/c-runtime-library/reference/crtsetreportfile https://learn.microsoft.com/cpp/c-runtime-library/reference/crtsetreportmode https://learn.microsoft.com/cpp/c-runtime-library/reference/set-error-mode Ref: #23336 Ref: edfa537 #16456 Ref: #14854 Cherry-picked from #23306 Closes #23400
- in jobs building tests, also run them. - to maintain CI cycle times, only run unit tests by default, and run all (supported) tests in just one job, carefully selected to be the one running them the fastest. Per job, it takes ~15 seconds to run ~80 unit tests. It takes 5 minutes to run all (~1600) tests. Total job time 5.5-6 minutes. If the full test run turns out to be annoying or grow slow, we disable or limit it to a subset of tests. - run tests with `-j10` parallelism. It results in the fastest runs, based on tests. - to avoid the MSBuild test breaker heuristics, and to improve performance, run tests by directly invoking `runtests.pl` (not via CMake -> MSBuild -> `runtests.pl`). It saves 10-40 seconds per full test run. - when running directly via `runtests.pl`, exclude test 1119 and 1167. It's not compatible with Visual Studio generator builds. - run the artifact upload in parallel with running tests. Running Windows tests in multiple environments makes it more likely they can run on local machines, too, also making them easier to debug. AppVeyor also supports remote access via RDP, which may help debugging notorious Windows issues live, with some luck of reproducing it in a run with RDP access explicitly enabled beforehand. Fixes/improvements via this PR, merged separately: dc99e12 #23467 processhelp.pm: improve task info in trace output (Windows) 70f3f85 #23471 test1488: drop unused C preprocessor logic af9d2dd #23336 cmake: fix preconditions for option `CURL_STATIC_CRT=ON` adf8b78 #23428 setopt: fix setting `CURLWS_NOAUTOPONG` with compilers lacking C99 bool type 780405b #23416 tests: add `--dump-module-paths` debug option (Windows) bc22977 #23400 msvc: replace debug CRT GUI popups with stderr output 87a1dc7 #23396 appveyor: minor improvements 67f3510 #23381 runtests: add `-S` option to show success logs e9af987 #23378 tests/server: fix crashing with VS2013 and earlier 8cdee8a #23377 lib557: exclude three floating point test cases for VS2013 and earlier 1aac64a #23375 test1119, 1167: disable MSYS2 argument conversion narrowly 49f003f #23337 unit1664: add workaround for VS2019 16.3 - VS2022 17.4 x64 miscompile b8f71d6 #23345 test428: skip when running on older MSYS2 versions 2f3f99d #23339 test1119, 1167: disable MSYS2 argument conversion 098d3a0 #23332 runtests: unset `CURL_MEMDEBUG` for curl requests made to the CI API d3e7caf #23335 GHA/windows: drop unused `-ac` runtests options 2874cc6 #23317 mqttd: work around bogus VS2019 32-bit compiler warning e8adc72 #23315 schannel: fix guard for old MSVC workaround Follow-up to 41198e0 #20390 Closes #23306
Limit this option to static-only curl builds.
Enabling the static CRT for other configurations may successfuly build
them, but executing them do run into nasty problems due to using two CRT
copies at the same time. Also note that the static CRT setting applies
to tests too, which revealed these issues.
Also:
this patch, such configuration is possible again.
variation (e.g. a libcurl.dll built against static CRT). You can
pass the necessary compiler/linker options via standard CMake options/envs.
I discovered these issues while enabling test runs on AppVeyor CI with
all supported MSVC version in various configurations, and
-DCURL_STATIC_CRT=ONset.Symptoms of double CRT:
curl -Voutput with newline missing between 'Protocols:' and'Features:' lines, then runtests unable to detect feature and emitting
a Perl warning for uninitialized
$featvariable. (due to paralleloutput buffering for
puts()andcurl_mprintf())This is visible in master builds, e.g.:
CM VS2019, Debug, x64, OpenSSL 3.0 + Schannel, Shared, !verbose, Build-tests:
Notice the missing newline before
Features:, and appearing aboveWARNING:instead.crashed in both the app and the libcurl.dll it loaded. (possibly)
Follow-up to 6140746 #16522
Follow-up to 049352d #16516
Follow-up to edfa537 #16456 #16394
Follow-up to 4fc6ebe #1621
Cherry-picked from #23306
building curl tool and tests. This could work, though my understanding
is that such dll needs to be used carefully to avoid hitting the issues
that affected curl tests for example.
(my understanding, is that building a static curl tool with static CRT,
and building a shared libcurl with static CRT, in the same build pass
is not possible. Or would need to split the shared/static pass into
two, based on this condition. But even then, tests would not build or
work correctly, unless maybe they are never built with static CRT. In
which case though, e.g. tunits isn't really mimicing the real curl tool.
Tricky.) -- edit: a libcurl.dll with a static CRT seems like an even more
niche use-case after sleeping on it. The patch below may allow this,
but it seems to be causing more headaches than it may solve. If you're
aware of a reasonably non-niche example, please leave a comment.