Files
Alexander J. Semenuk 5d5e35fb9b fix: Windows toolchain compatibility (curl 8.21 re-vendor, endless reconfigure loop) (#4355)
## Problem

Windows builds break with a current local toolchain (Scoop LLVM 22.1.8,
CMake 4.4.0, VS 2026), in two independent ways:

1. The build stops at curl's deliberate guard: `#error "no non-blocking
method was found/used/set"` in `third-party/curl/lib/nonblock.c`.
2. From the second configure onward, `cmake --build` re-runs CMake in an
endless loop (observed 42 consecutive reconfigure cycles in a single
build). Likely the same mechanism behind the "endlessly building" VS
2026 note in `docs/setup/dev/vs.md`.

## Root cause

1. `third-party/curl/CMake/CurlTests.c` passes `int *` to
`ioctlsocket()`, whose third parameter is `u_long *`. Clang 22 promotes
`-Wincompatible-pointer-types` to a hard error in C, so the
`HAVE_IOCTLSOCKET_FIONBIO` try_compile silently fails and
`curl_config.h` never defines it. Upstream CI does not see this because
the windows-2022 runner image ships an older LLVM. GCC 14 promotes the
same warning to a hard error, which is very likely the `CurlTests.c.obj`
failure reported from MSYS2 in open-goal/jak-project#3551. Upstream curl
hit the identical problem with GCC 14 and fixed the probe in curl 8.8.0
(curl/curl#13578).
2. The root CMakeLists copies the build tree's `compile_commands.json`
into `<src>/build/` for clangd using `configure_file()`, which registers
its input as a configure dependency. CMake rewrites
`compile_commands.json` late in every generation, after
`CTestTestfile.cmake` and `cmake_install.cmake` (outputs of the same
Ninja regen rule), so once the dependency is registered the rule is
deterministically dirty and every `ninja` invocation re-runs CMake. A
pristine first configure is safe (the file does not exist yet, so the
`if(EXISTS ...)` guard skips the copy), which is why the loop looks
machine- or IDE-specific.

## Fix

1. Per review, re-vendor `third-party/curl` at the `curl-8_21_0` tag
(previously `curl-8_3_0`), which carries the upstream probe fix plus two
years of upstream development; `vendor.yaml` updated to match.
Adjustments the version jump forced:
- curl 8.15 removed the native macOS Secure Transport backend
(`CURL_USE_SECTRANSP`), so macOS now builds curl against OpenSSL like
Linux. The two macOS workflows install Homebrew `openssl@3` and export
`OPENSSL_ROOT_DIR` (keg-only), and the macOS setup docs gained the same
two lines.
- `CURL_BROTLI` / `CURL_ZSTD` switched to AUTO-detection in curl 8.10;
pinned OFF to keep the previous no-compression behavior and avoid
silently linking whatever the CI images happen to have.
- curl's new top-level `BUILD_EXAMPLES` cache option (default ON) leaked
into discord-rpc's identically named option and broke configure at a
nonexistent `examples/send-presence` directory; pinned OFF ahead of the
third-party subdirectories.

The diff is dominated by the mechanical tag-tree swap under
`third-party/curl` (linguist-vendored, collapsed in review). The
hand-written changes are `CMakeLists.txt`, the two macOS workflows,
`docs/setup/system/macos.md`, and `vendor.yaml`.
2. Swap `configure_file()` for `file(COPY ...)`: the same clangd copy
with no configure dependency registered. (`file(COPY_FILE ...
ONLY_IF_DIFFERENT)` would be cleaner still but requires CMake 3.21,
above the declared `cmake_minimum_required(VERSION 3.10)`.)

## Test plan

- [x] Fresh `cmake --preset Release-windows-clang` (LLVM 22, no cache
seeding) completes and logs `Enabled SSL backends: Schannel`; the
FIONBIO probe passes without the previous `#error`
- [x] Full Windows Release build from scratch in the branch worktree
(all 1422 targets)
- [x] goalc-test suite: 1509 passed, 0 failed
- [x] Second consecutive configure with `compile_commands.json` present:
the regen rule in `build.ninja` has no `compile_commands.json` input;
`<src>/build/compile_commands.json` is still refreshed for clangd
- [x] Repeated `ninja` invocations after a full build no longer re-run
CMake
- [x] macOS Intel and ARM CI green (first exercise of the OpenSSL
backend switch)

---

I work off a self-hosted forge, so this GitHub account is quiet; the
configure logs and ninja dirty-node traces from the investigation are
available if anyone wants the raw data.

(AI-assisted)
2026-07-27 19:19:18 -04:00

5.5 KiB
Vendored
Generated

c, SPDX-License-Identifier, Title, Section, Source, See-also, Protocol, Added-in
c SPDX-License-Identifier Title Section Source See-also Protocol Added-in
Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. curl curl_global_trace 3 libcurl
curl_global_init (3)
libcurl (3)
All
8.3.0

NAME

curl_global_trace - log configuration

SYNOPSIS

#include <curl/curl.h>

CURLcode curl_global_trace(const char *config);

DESCRIPTION

This function configures the logging behavior to make some parts of curl more verbose or silent than others.

This function may be called during the initialization phase of a program. It does not have to be. It can be called several times even, possibly overwriting settings of previous calls.

Calling this function after transfers have been started is undefined. On some platforms/architectures it might take effect, on others not.

This function is thread-safe since libcurl 8.3.0 if curl_version_info(3) has the CURL_VERSION_THREADSAFE feature bit set (most platforms).

If this is not thread-safe, you must not call this function when any other thread in the program (i.e. a thread sharing the same memory) is running. This does not only mean no other thread that is using libcurl. Because curl_global_init(3) may call functions of other libraries that are similarly thread-unsafe, it could conflict with any other thread that uses these other libraries.

If you are initializing libcurl from a Windows DLL you should not initialize it from DllMain or a static initializer because Windows holds the loader lock during that time and it could cause a deadlock.

The config string is a list of comma-separated component names. Names are case-insensitive and unknown names are ignored. The special name "all" applies to all components. Names may be prefixed with '+' or '-' to enable or disable detailed logging for a component.

The list of component names is not part of curl's public API. Names may be added or disappear in future versions of libcurl. Since unknown names are silently ignored, outdated log configurations does not cause errors when upgrading libcurl. Given that, some names can be expected to be fairly stable and are listed below for easy reference.

Note that log configuration applies only to transfers where debug logging is enabled. See CURLOPT_VERBOSE(3) or CURLOPT_DEBUGFUNCTION(3) on how to control that.

TRACE COMPONENTS

tcp

Tracing of TCP socket handling: connect, sends, receives.

ssl

Tracing of SSL/TLS operations, whichever SSL backend is used in your build.

ftp

Tracing of FTP operations when this protocol is enabled in your build.

http/2

Details about HTTP/2 handling: frames, events, I/O, etc.

http/3

Details about HTTP/3 handling: connect, frames, events, I/O etc.

http-proxy

Involved when transfers are tunneled through an HTTP proxy. "h1-proxy" or "h2-proxy" are also involved, depending on the HTTP version negotiated with the proxy.

In order to find out all components involved in a transfer, run it with "all" configured. You can then see all names involved in your libcurl version in the trace.

dns

Tracing of DNS operations to resolve hostnames and HTTPS records.

lib-ids

Adds transfer and connection identifiers as prefix to every call to CURLOPT_DEBUGFUNCTION(3). The format is [n-m] where n is the identifier of the transfer and m is the identifier of the connection. A literal x is used for internal transfers or when no connection is assigned.

For example, [5-x] is the prefix for transfer 5 that has no connection. The command line tool curluses the same format for its --trace-ids option.

lib-ids is intended for libcurl applications that handle multiple transfers but have no own way to identify in trace output which transfer a trace event is connected to.

doh

Former name for DNS-over-HTTP operations. Now an alias for dns.

multi

Traces multi operations managing transfers' state changes and sockets poll states.

read

Traces reading of upload data from the application in order to send it to the server.

ssh

Tracing of SSH related protocols SCP and SFTP.

ssls

Tracing of SSL Session handling, e.g. caching/import/export.

smtp

Tracing of SMTP operations when this protocol is enabled in your build.

threads

Tracing of thread queue and pools, used in threaded DNS resolving.

timer

Tracing of timers set for transfers.

write

Traces writing of download data, received from the server, to the application.

ws

Tracing of WebSocket operations when this protocol is enabled in your build.

TRACE GROUPS

Besides the specific component names there are the following group names defined:

all

network

All components involved in bare network I/O, including the SSL layer.

All components that your libcurl is built with.

protocol

All components involved in transfer protocols, such as 'ftp' and 'http/2'.

proxy

All components involved in use of proxies.

%PROTOCOLS%

EXAMPLE

int main(void)
{
  /* log details of HTTP/2 and SSL handling */
  curl_global_trace("http/2,ssl");

  /* log all details, except SSL handling */
  curl_global_trace("all,-ssl");
}

Below is a trace sample where "http/2" was configured. The trace output of an enabled component appears at the beginning in brackets.

* [HTTP/2] [h2sid=1] cf_send(len=96) submit https://example.com/
...
* [HTTP/2] [h2sid=1] FRAME[HEADERS]
* [HTTP/2] [h2sid=1] 249 header bytes
...

%AVAILABILITY%

RETURN VALUE

If this function returns non-zero, something went wrong and the configuration may not have any effects or may only been applied partially.