Files
jak-project/third-party/curl/tests/data/test1185
T
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

250 lines
7.1 KiB
XML
Vendored
Generated

<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
checksrc
</keywords>
</info>
# Client-side
<client>
<name>
checksrc
</name>
<command type="perl">
%SRCDIR/../scripts/checksrc.pl -bmagicbad -balsobad %LOGDIR/code%TESTNUMBER.c
</command>
<file name="%LOGDIR/code%TESTNUMBER.c">
/* test source code
* Violate each rule at least once.
**/
int hello; /*------------------------------------------------------------------*/
int%TABtab;
int trailing_space;
int a = func ();
int b = func( b);
int b = func(b );
func(a, b , c);
int hello()
{
return(2);
}
func(a, b,c);
if(a == 2) {
;
} else {
moo = 2;
}
if(a == 2){ /* followed by comment */
;
}
func_return() ;
a = sprintf(buffer, "%s", moo);
FILE *f = curlx_fopen("filename", "r");
void startfunc(int a, int b) {
func();
}
for(;;) {
func(1);
} while(1);
char * name = "hello";
char* name = "hello";
int foo=bar;
int foo= bar;
int foo = bar;
int foo = bar;foo++;
for(;;) {
moo();
moo();
}
int a = sizeof int;
int a = magicbad(buffer, alsobad(buffer), "%d", 99);
int moo = hej?wrong:a>b;
int moo2 = wrong2:(a)>(b);
if(a) b++;
if(sprintf(buffer, "%s", moo)) {}
*buffer_len = (ssize_t)alsobad((char *)buffer, NULL, 16);
# if defined(SINGLE_MACRO)
#if ! defined(__macro_10)
#elif !defined(TESTMACRO)
#endif
#endif
#endif
// CPP comment ?
int d = impl->magicbad(1); /* member function always allowed */
int e = impl.magicbad(); /* member function always allowed */
curlx_free(ptr); /* two line
comment */
ptr = NULL; /* comment more */
/* comment does not end
</file>
</client>
# Verify data after the test has been "shot"
<verify>
<stdout>
./%LOGDIR/code1185.c:4:82: warning: Longer than 79 columns (LONGLINE)
int hello; /*------------------------------------------------------------------*/
./%LOGDIR/code1185.c:5:4: error: Contains TAB character (TABS)
int%TABtab;
^
./%LOGDIR/code1185.c:7:13: warning: func with space (SPACEBEFOREPAREN)
int a = func ();
^
./%LOGDIR/code1185.c:8:14: warning: space after open parenthesis (SPACEAFTERPAREN)
int b = func( b);
^
./%LOGDIR/code1185.c:9:16: warning: space before close parenthesis (SPACEBEFORECLOSE)
int b = func(b );
^
./%LOGDIR/code1185.c:10:11: warning: space before comma (SPACEBEFORECOMMA)
func(a, b , c);
^
./%LOGDIR/code1185.c:14:9: warning: return without space before paren (RETURNNOSPACE)
return(2);
^
./%LOGDIR/code1185.c:16:11: warning: comma without following space (COMMANOSPACE)
func(a, b,c);
^
./%LOGDIR/code1185.c:18:12: warning: wrongly placed open brace (BRACEPOS)
if(a == 2) {
^
./%LOGDIR/code1185.c:20:1: warning: else after closing brace on same line (BRACEELSE)
} else {
^
./%LOGDIR/code1185.c:24:11: warning: missing space after close paren (PARENBRACE)
if(a == 2){%SP%SP
^
./%LOGDIR/code1185.c:28:14: warning: no space before semicolon (SPACESEMICOLON)
func_return() ;
^
./%LOGDIR/code1185.c:30:5: warning: use of sprintf is banned (BANNEDFUNC)
a = sprintf(buffer, "%s", moo);
^
./%LOGDIR/code1185.c:32:11: warning: use of non-binary fopen without FOPEN_* macro: r (FOPENMODE)
FILE *f = curlx_fopen("filename", "r");
^
./%LOGDIR/code1185.c:34:30: warning: wrongly placed open brace (BRACEPOS)
void startfunc(int a, int b) {
^
./%LOGDIR/code1185.c:39:6: warning: not indented 2 steps (uses 4) (INDENTATION)
func(1);
^
./%LOGDIR/code1185.c:42:8: warning: space after declarative asterisk (ASTERISKSPACE)
char * name = "hello";
^
./%LOGDIR/code1185.c:43:7: warning: space after declarative asterisk (ASTERISKSPACE)
char* name = "hello";
^
./%LOGDIR/code1185.c:43:6: warning: no space before asterisk (ASTERISKNOSPACE)
char* name = "hello";
^
./%LOGDIR/code1185.c:45:10: warning: no space after equals sign (EQUALSNOSPACE)
int foo=bar;
^
./%LOGDIR/code1185.c:46:9: warning: no space before equals sign (NOSPACEEQUALS)
int foo= bar;
^
./%LOGDIR/code1185.c:48:16: warning: no space after semicolon (SEMINOSPACE)
int foo = bar;foo++;
^
./%LOGDIR/code1185.c:49:10: warning: multiple spaces (MULTISPACE)
for(;;) {
^
./%LOGDIR/code1185.c:50:5: warning: not indented 2 steps (uses 3) (INDENTATION)
moo();
^
./%LOGDIR/code1185.c:52:3: warning: Suspicious close brace indentation (CLOSEBRACE)
moo();
^
./%LOGDIR/code1185.c:54:16: warning: sizeof without parenthesis (SIZEOFNOPAREN)
int a = sizeof int;
^
./%LOGDIR/code1185.c:55:10: warning: use of magicbad is banned (BANNEDFUNC)
int a = magicbad(buffer, alsobad(buffer), "%d", 99);
^
./%LOGDIR/code1185.c:55:27: warning: use of alsobad is banned (BANNEDFUNC)
int a = magicbad(buffer, alsobad(buffer), "%d", 99);
^
./%LOGDIR/code1185.c:56:21: warning: missing space before colon (NOSPACEC)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:22: warning: missing space after colon (NOSPACEC)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:15: warning: missing space before question mark (NOSPACEQ)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:16: warning: missing space after question mark (NOSPACEQ)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:23: warning: missing space before less or greater than (NOSPACETHAN)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:56:23: warning: missing space after less or greater than (NOSPACETHAN)
int moo = hej?wrong:a>b;
^
./%LOGDIR/code1185.c:57:23: warning: missing space before less or greater than (NOSPACETHAN)
int moo2 = wrong2:(a)>(b);
^
./%LOGDIR/code1185.c:57:23: warning: missing space after less or greater than (NOSPACETHAN)
int moo2 = wrong2:(a)>(b);
^
./%LOGDIR/code1185.c:59:7: warning: conditional block on the same line (ONELINECONDITION)
if(a) b++;
^
./%LOGDIR/code1185.c:61:5: warning: use of sprintf is banned (BANNEDFUNC)
if(sprintf(buffer, "%s", moo)) {}
^
./%LOGDIR/code1185.c:62:25: warning: use of alsobad is banned (BANNEDFUNC)
*buffer_len = (ssize_t)alsobad((char *)buffer, NULL, 16);
^
./%LOGDIR/code1185.c:64:14: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE)
# if defined(SINGLE_MACRO)
^
./%LOGDIR/code1185.c:65:17: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE)
#if ! defined(__macro_10)
^
./%LOGDIR/code1185.c:65:1: warning: space before preprocessor hash (CPPSPACE)
#if ! defined(__macro_10)
^
./%LOGDIR/code1185.c:71:2: warning: // comment (CPPCOMMENTS)
// CPP comment ?
^
./%LOGDIR/code1185.c:78:2: warning: replace curlx_free() + NULL assignment with curlx_safefree() (USESAFEFREE)
ptr = NULL; /* comment more */
^
./%LOGDIR/code1185.c:1:1: error: Missing copyright statement (COPYRIGHT)
%SP
^
./%LOGDIR/code1185.c:1:1: error: Missing closing comment (OPENCOMMENT)
%SP
^
checksrc: 3 errors and 43 warnings
</stdout>
<errorcode>
5
</errorcode>
</verify>
</testcase>