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.8 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 libcurl-env-dbg 3 libcurl
libcurl-env (3)
All
n/a

NAME

libcurl-env-dbg - environment variables libcurl DEBUGBUILD understands

DESCRIPTION

This is a set of variables only recognized and used if libcurl was built "debug enabled", which should never be true for a library used in production. These variables are intended for internal use only, subject to change and have many effects on the behavior of libcurl. Refer to the source code to determine how exactly they are being used.

CURL_ALTSVC_HTTP

Bypass the AltSvc HTTPS protocol restriction if this variable exists.

CURL_DBG_SOCK_RBLOCK

The percentage of recv() calls that should be answered with an EAGAIN at random. For TCP/UNIX sockets.

CURL_DBG_SOCK_RMAX

The maximum data that shall be received from the network in one recv() call. For TCP/UNIX sockets. This is applied to every recv.

Example: CURL_DBG_SOCK_RMAX=400 means recv buffer size is limited to a maximum of 400 bytes.

CURL_DBG_SOCK_WBLOCK

The percentage of send() calls that should be answered with an EAGAIN at random. For TCP/UNIX sockets.

CURL_DBG_SOCK_WPARTIAL

The percentage of data that shall be written to the network. For TCP/UNIX sockets. This is applied to every send.

Example: CURL_DBG_SOCK_WPARTIAL=80 means a send with 1000 bytes would only send 800.

CURL_DBG_QUIC_WBLOCK

The percentage of send() calls that should be answered with EAGAIN at random. QUIC only.

CURL_DBG_SOCK_FAIL_IPV6

Fail opening of sockets for the IPv6 address family.

CURL_DEBUG

Trace logging behavior as an alternative to calling curl_global_trace(3).

Example: CURL_DEBUG=http/2 means trace details about HTTP/2 handling.

In the curl command line tool, built with --enable-debug, this environment variable adds to arguments like --verbose, -vvv. At least a single -v is needed to make the run emit trace output, but when it does, the contents of CURL_DEBUG are added and can override existing options.

Example: CURL_DEBUG=tcp,-http/2 curl -vv url means trace protocol details, triggered by -vv, add tracing of TCP in addition and remove tracing of HTTP/2.

CURL_DEBUG_SIZE

Fake the size returned by CURLINFO_HEADER_SIZE and CURLINFO_REQUEST_SIZE.

CURL_DNS_SERVER

When built with c-ares for name resolving, setting this environment variable to [IP:port] makes libcurl use that DNS server instead of the system default. This is used by the curl test suite.

CURL_FTP_PWD_STOP

When set, the first transfer - when using ftp: - returns before sending the PWD command and stop any further progress. This is used to test an edge case

CURL_GETHOSTNAME

Fake the local machine's unqualified hostname for NTLM and SMTP.

CURL_HSTS_HTTP

Bypass the HSTS HTTPS protocol restriction if this variable exists.

CURL_FORCETIME

A time of 0 is used for AWS signatures and NTLM if this variable exists.

CURL_ENTROPY

A fixed faked value to use instead of a proper random number so that functions in libcurl that are otherwise getting random outputs can be tested for what they generate.

CURL_SIGPIPE_DEBUG

When present, curl does not set SIGPIPE to ignore. This allows verification that libcurl does not cause SIGPIPE to be raised.

CURL_SMALLREQSEND

An alternative size of HTTP data to be sent at a time only if smaller than the current.

CURL_SMALLSENDS

An alternative size of socket data to be sent at a time only if smaller than the current.

CURL_TIME

Fake Unix timestamp to use for AltSvc, HSTS and CURLINFO variables that are time related.

This variable can also be used to fake the data returned by some CURLINFO variables that are not time-related (such as CURLINFO_LOCAL_PORT), and in that case the value is not a timestamp.

CURL_TRACE

LDAP tracing is enabled if this variable exists and its value is 1 or greater.

OpenLDAP tracing is separate. Refer to CURL_OPENLDAP_TRACE.

CURL_OPENLDAP_TRACE

OpenLDAP tracing is enabled if this variable exists and its value is 1 or greater. There is a number of debug levels, refer to openldap.c comments.

CURL_WS_CHUNK_SIZE

Used to influence the buffer chunk size used for WebSocket encoding and decoding.

CURL_WS_CHUNK_EAGAIN

Used to simulate blocking sends after this chunk size for WebSocket connections.

CURL_WS_FORCE_ZERO_MASK

Used to set the bitmask of all sent WebSocket frames to zero. The value of the environment variable does not matter.

CURL_FORBID_REUSE

Used to set the CURLOPT_FORBID_REUSE flag on each transfer initiated by the curl command line tool. The value of the environment variable does not matter.

CURL_GRACEFUL_SHUTDOWN

Make a blocking, graceful shutdown of all remaining connections when a multi handle is destroyed. This implicitly triggers for easy handles that are run via easy_perform. The value of the environment variable gives the shutdown timeout in milliseconds.

CURL_DBG_RESOLV_MAX_THREADS

Overrides the maximum number of threads for resolver.

CURL_DBG_RESOLV_DELAY

Makes ever threaded resolve experience an initial delay in milliseconds.

CURL_DBG_RESOLV_FAIL_DELAY

With a threaded resolver, delay each lookup by the given milliseconds and give a negative answer.

CURL_DBG_RESOLV_FAIL_IPV6

Make libcurl fail a resolve for IPv6 only.

CURL_QUICK_EXIT

Make curl use the quick exit option, even when built in debug mode.

CURL_DBG_AWAIT_HTTPSRR

When happy eyeballing for https: wait for the HTTPS-RR resolve answer to arrive before starting any connect attempt.

CURL_DBG_NO_USE_SSL_ON_FIRST

When passing --ssl-reqd, clear it for the first URL in a curl command. This allows testing of connection reuse in mixed STARTTLS needs.