mirror of
https://github.com/open-goal/jak-project
synced 2026-09-12 20:56:09 -04:00
5d5e35fb9b
## 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)
231 lines
5.6 KiB
Markdown
Vendored
Generated
231 lines
5.6 KiB
Markdown
Vendored
Generated
<!--
|
|
Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
|
|
SPDX-License-Identifier: curl
|
|
-->
|
|
|
|
# String parsing with `strparse`
|
|
|
|
The functions take input via a pointer to a pointer, which allows the
|
|
functions to advance the pointer on success which then by extension allows
|
|
"chaining" of functions like this example that gets a word, a space and then a
|
|
second word:
|
|
|
|
~~~c
|
|
if(curlx_str_word(&line, &word1, MAX) ||
|
|
curlx_str_singlespace(&line) ||
|
|
curlx_str_word(&line, &word2, MAX))
|
|
fprintf(stderr, "ERROR\n");
|
|
~~~
|
|
|
|
The input pointer **must** point to a null-terminated buffer area or these
|
|
functions risk continuing "off the edge".
|
|
|
|
## Strings
|
|
|
|
The functions that return string information does so by populating a
|
|
`struct Curl_str`:
|
|
|
|
~~~c
|
|
struct Curl_str {
|
|
char *str;
|
|
size_t len;
|
|
};
|
|
~~~
|
|
|
|
Access the struct fields with `curlx_str()` for the pointer and `curlx_strlen()`
|
|
for the length rather than using the struct fields directly.
|
|
|
|
## `curlx_str_init`
|
|
|
|
~~~c
|
|
void curlx_str_init(struct Curl_str *out)
|
|
~~~
|
|
|
|
This initiates a string struct. The parser functions that store info in
|
|
strings always init the string themselves, so this stand-alone use is often
|
|
not necessary.
|
|
|
|
## `curlx_str_assign`
|
|
|
|
~~~c
|
|
void curlx_str_assign(struct Curl_str *out, const char *str, size_t len)
|
|
~~~
|
|
|
|
Set a pointer and associated length in the string struct.
|
|
|
|
## `curlx_str_word`
|
|
|
|
~~~c
|
|
int curlx_str_word(char **linep, struct Curl_str *out, const size_t max);
|
|
~~~
|
|
|
|
Get a sequence of bytes until the first space or the end of the string. Return
|
|
non-zero on error. There is no way to include a space in the word, no sort of
|
|
escaping. The word must be at least one byte, otherwise it is considered an
|
|
error.
|
|
|
|
`max` is the longest accepted word, or it returns error.
|
|
|
|
On a successful return, `linep` is updated to point to the byte immediately
|
|
following the parsed word.
|
|
|
|
## `curlx_str_until`
|
|
|
|
~~~c
|
|
int curlx_str_until(char **linep, struct Curl_str *out, const size_t max,
|
|
char delim);
|
|
~~~
|
|
|
|
Like `curlx_str_word` but instead of parsing to space, it parses to a given
|
|
custom delimiter non-zero byte `delim`.
|
|
|
|
`max` is the longest accepted word, or it returns error.
|
|
|
|
The parsed word must be at least one byte, otherwise it is considered an
|
|
error.
|
|
|
|
## `curlx_str_untilnl`
|
|
|
|
~~~c
|
|
int curlx_str_untilnl(char **linep, struct Curl_str *out, const size_t max);
|
|
~~~
|
|
|
|
Like `curlx_str_untilnl` but instead parses until it finds a "newline byte".
|
|
That means either a CR (ASCII 13) or an LF (ASCII 10) octet.
|
|
|
|
`max` is the longest accepted word, or it returns error.
|
|
|
|
The parsed word must be at least one byte, otherwise it is considered an
|
|
error.
|
|
|
|
## `curlx_str_cspn`
|
|
|
|
~~~c
|
|
int curlx_str_cspn(const char **linep, struct Curl_str *out, const char *cspn);
|
|
~~~
|
|
|
|
Get a sequence of characters until one of the bytes in the `cspn` string
|
|
matches. Similar to the `strcspn` function.
|
|
|
|
## `curlx_str_quotedword`
|
|
|
|
~~~c
|
|
int curlx_str_quotedword(char **linep, struct Curl_str *out, const size_t max);
|
|
~~~
|
|
|
|
Get a "quoted" word. This means everything that is provided within a leading
|
|
and an ending double quote character. No escaping possible.
|
|
|
|
`max` is the longest accepted word, or it returns error.
|
|
|
|
The parsed word must be at least one byte, otherwise it is considered an
|
|
error.
|
|
|
|
## `curlx_str_single`
|
|
|
|
~~~c
|
|
int curlx_str_single(char **linep, char byte);
|
|
~~~
|
|
|
|
Advance over a single character provided in `byte`. Return non-zero on error.
|
|
|
|
## `curlx_str_singlespace`
|
|
|
|
~~~c
|
|
int curlx_str_singlespace(char **linep);
|
|
~~~
|
|
|
|
Advance over a single ASCII space. Return non-zero on error.
|
|
|
|
## `curlx_str_passblanks`
|
|
|
|
~~~c
|
|
void curlx_str_passblanks(char **linep);
|
|
~~~
|
|
|
|
Advance over all spaces and tabs.
|
|
|
|
## `curlx_str_trimblanks`
|
|
|
|
~~~c
|
|
void curlx_str_trimblanks(struct Curl_str *out);
|
|
~~~
|
|
|
|
Trim off blanks (spaces and tabs) from the start and the end of the given
|
|
string.
|
|
|
|
## `curlx_str_number`
|
|
|
|
~~~c
|
|
int curlx_str_number(char **linep, curl_size_t *nump, size_t max);
|
|
~~~
|
|
|
|
Get an unsigned decimal number not larger than `max`. Leading zeroes are
|
|
swallowed. Return non-zero on error. Returns error if there was not a single
|
|
digit.
|
|
|
|
## `curlx_str_numblanks`
|
|
|
|
~~~c
|
|
int curlx_str_numblanks(char **linep, curl_size_t *nump);
|
|
~~~
|
|
|
|
Get an unsigned 63-bit decimal number. Leading blanks and zeroes are skipped.
|
|
Returns non-zero on error. Returns error if there was not a single digit.
|
|
|
|
## `curlx_str_hex`
|
|
|
|
~~~c
|
|
int curlx_str_hex(char **linep, curl_size_t *nump, size_t max);
|
|
~~~
|
|
|
|
Get an unsigned hexadecimal number not larger than `max`. Leading zeroes are
|
|
swallowed. Return non-zero on error. Returns error if there was not a single
|
|
digit. Does *not* handled `0x` prefix.
|
|
|
|
## `curlx_str_octal`
|
|
|
|
~~~c
|
|
int curlx_str_octal(char **linep, curl_size_t *nump, size_t max);
|
|
~~~
|
|
|
|
Get an unsigned octal number not larger than `max`. Leading zeroes are
|
|
swallowed. Return non-zero on error. Returns error if there was not a single
|
|
digit.
|
|
|
|
## `curlx_str_newline`
|
|
|
|
~~~c
|
|
int curlx_str_newline(char **linep);
|
|
~~~
|
|
|
|
Check for a single CR or LF. Return non-zero on error */
|
|
|
|
## `curlx_str_casecompare`
|
|
|
|
~~~c
|
|
int curlx_str_casecompare(struct Curl_str *str, const char *check);
|
|
~~~
|
|
|
|
Returns true if the provided string in the `str` argument matches the `check`
|
|
string case insensitively.
|
|
|
|
## `curlx_str_cmp`
|
|
|
|
~~~c
|
|
int curlx_str_cmp(struct Curl_str *str, const char *check);
|
|
~~~
|
|
|
|
Returns true if the provided string in the `str` argument matches the `check`
|
|
string case sensitively. This is *not* the same return code as `strcmp`.
|
|
|
|
## `curlx_str_nudge`
|
|
|
|
~~~c
|
|
int curlx_str_nudge(struct Curl_str *str, size_t num);
|
|
~~~
|
|
|
|
Removes `num` bytes from the beginning (left) of the string kept in `str`. If
|
|
`num` is larger than the string, it instead returns an error.
|