mirror of
https://github.com/open-goal/jak-project
synced 2026-08-20 14:24:45 -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)
386 lines
10 KiB
C
Vendored
Generated
386 lines
10 KiB
C
Vendored
Generated
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
#include "curl_setup.h"
|
|
|
|
#include "dynhds.h"
|
|
#include "strcase.h"
|
|
|
|
static struct dynhds_entry *entry_new(const char *name, size_t namelen,
|
|
const char *value, size_t valuelen,
|
|
int opts)
|
|
{
|
|
struct dynhds_entry *e;
|
|
char *p;
|
|
|
|
DEBUGASSERT(name);
|
|
DEBUGASSERT(value);
|
|
e = curlx_calloc(1, sizeof(*e) + namelen + valuelen + 2);
|
|
if(!e)
|
|
return NULL;
|
|
e->name = p = (char *)e + sizeof(*e);
|
|
memcpy(p, name, namelen);
|
|
e->namelen = namelen;
|
|
e->value = p += namelen + 1; /* leave a \0 at the end of name */
|
|
memcpy(p, value, valuelen);
|
|
e->valuelen = valuelen;
|
|
if(opts & DYNHDS_OPT_LOWERCASE)
|
|
Curl_strntolower(e->name, e->name, e->namelen);
|
|
return e;
|
|
}
|
|
|
|
static void entry_free(struct dynhds_entry *e)
|
|
{
|
|
curlx_free(e);
|
|
}
|
|
|
|
void Curl_dynhds_init(struct dynhds *dynhds, size_t max_entries,
|
|
size_t max_strs_size)
|
|
{
|
|
DEBUGASSERT(dynhds);
|
|
DEBUGASSERT(max_strs_size);
|
|
dynhds->hds = NULL;
|
|
dynhds->hds_len = dynhds->hds_allc = dynhds->strs_len = 0;
|
|
dynhds->max_entries = max_entries;
|
|
dynhds->max_strs_size = max_strs_size;
|
|
dynhds->opts = 0;
|
|
}
|
|
|
|
void Curl_dynhds_free(struct dynhds *dynhds)
|
|
{
|
|
DEBUGASSERT(dynhds);
|
|
if(dynhds->hds && dynhds->hds_len) {
|
|
size_t i;
|
|
DEBUGASSERT(dynhds->hds);
|
|
for(i = 0; i < dynhds->hds_len; ++i) {
|
|
entry_free(dynhds->hds[i]);
|
|
}
|
|
}
|
|
curlx_safefree(dynhds->hds);
|
|
dynhds->hds_len = dynhds->hds_allc = dynhds->strs_len = 0;
|
|
}
|
|
|
|
void Curl_dynhds_reset(struct dynhds *dynhds)
|
|
{
|
|
DEBUGASSERT(dynhds);
|
|
if(dynhds->hds_len) {
|
|
size_t i;
|
|
DEBUGASSERT(dynhds->hds);
|
|
for(i = 0; i < dynhds->hds_len; ++i) {
|
|
entry_free(dynhds->hds[i]);
|
|
dynhds->hds[i] = NULL;
|
|
}
|
|
}
|
|
dynhds->hds_len = dynhds->strs_len = 0;
|
|
}
|
|
|
|
size_t Curl_dynhds_count(struct dynhds *dynhds)
|
|
{
|
|
return dynhds->hds_len;
|
|
}
|
|
|
|
void Curl_dynhds_set_opts(struct dynhds *dynhds, int opts)
|
|
{
|
|
dynhds->opts = opts;
|
|
}
|
|
|
|
struct dynhds_entry *Curl_dynhds_getn(struct dynhds *dynhds, size_t n)
|
|
{
|
|
DEBUGASSERT(dynhds);
|
|
return (n < dynhds->hds_len) ? dynhds->hds[n] : NULL;
|
|
}
|
|
|
|
struct dynhds_entry *Curl_dynhds_get(struct dynhds *dynhds, const char *name,
|
|
size_t namelen)
|
|
{
|
|
size_t i;
|
|
for(i = 0; i < dynhds->hds_len; ++i) {
|
|
if(dynhds->hds[i]->namelen == namelen &&
|
|
curl_strnequal(dynhds->hds[i]->name, name, namelen)) {
|
|
return dynhds->hds[i];
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
struct dynhds_entry *Curl_dynhds_cget(struct dynhds *dynhds, const char *name)
|
|
{
|
|
return Curl_dynhds_get(dynhds, name, strlen(name));
|
|
}
|
|
|
|
CURLcode Curl_dynhds_add(struct dynhds *dynhds,
|
|
const char *name, size_t namelen,
|
|
const char *value, size_t valuelen)
|
|
{
|
|
struct dynhds_entry *entry = NULL;
|
|
CURLcode result = CURLE_OUT_OF_MEMORY;
|
|
|
|
DEBUGASSERT(dynhds);
|
|
if(dynhds->max_entries && dynhds->hds_len >= dynhds->max_entries)
|
|
return CURLE_OUT_OF_MEMORY;
|
|
if(dynhds->strs_len + namelen + valuelen > dynhds->max_strs_size)
|
|
return CURLE_OUT_OF_MEMORY;
|
|
|
|
entry = entry_new(name, namelen, value, valuelen, dynhds->opts);
|
|
if(!entry)
|
|
goto out;
|
|
|
|
if(dynhds->hds_len + 1 >= dynhds->hds_allc) {
|
|
size_t nallc = dynhds->hds_len + 16;
|
|
struct dynhds_entry **nhds;
|
|
|
|
if(dynhds->max_entries && nallc > dynhds->max_entries)
|
|
nallc = dynhds->max_entries;
|
|
|
|
nhds = curlx_calloc(nallc, sizeof(struct dynhds_entry *));
|
|
if(!nhds)
|
|
goto out;
|
|
if(dynhds->hds) {
|
|
memcpy(nhds, dynhds->hds,
|
|
dynhds->hds_len * sizeof(struct dynhds_entry *));
|
|
curlx_safefree(dynhds->hds);
|
|
}
|
|
dynhds->hds = nhds;
|
|
dynhds->hds_allc = nallc;
|
|
}
|
|
dynhds->hds[dynhds->hds_len++] = entry;
|
|
entry = NULL;
|
|
dynhds->strs_len += namelen + valuelen;
|
|
result = CURLE_OK;
|
|
|
|
out:
|
|
if(entry)
|
|
entry_free(entry);
|
|
return result;
|
|
}
|
|
|
|
CURLcode Curl_dynhds_cadd(struct dynhds *dynhds,
|
|
const char *name, const char *value)
|
|
{
|
|
return Curl_dynhds_add(dynhds, name, strlen(name), value, strlen(value));
|
|
}
|
|
|
|
CURLcode Curl_dynhds_h1_add_line(struct dynhds *dynhds,
|
|
const char *line, size_t line_len)
|
|
{
|
|
const char *p;
|
|
const char *name;
|
|
size_t namelen;
|
|
const char *value;
|
|
size_t valuelen, i;
|
|
|
|
if(!line || !line_len)
|
|
return CURLE_OK;
|
|
|
|
p = memchr(line, ':', line_len);
|
|
if(!p)
|
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
|
name = line;
|
|
namelen = p - line;
|
|
p++; /* move past the colon */
|
|
for(i = namelen + 1; i < line_len; ++i, ++p) {
|
|
if(!ISBLANK(*p))
|
|
break;
|
|
}
|
|
value = p;
|
|
valuelen = line_len - i;
|
|
|
|
p = memchr(value, '\r', valuelen);
|
|
if(!p)
|
|
p = memchr(value, '\n', valuelen);
|
|
if(p)
|
|
valuelen = (size_t)(p - value);
|
|
|
|
return Curl_dynhds_add(dynhds, name, namelen, value, valuelen);
|
|
}
|
|
|
|
CURLcode Curl_dynhds_h1_cadd_line(struct dynhds *dynhds, const char *line)
|
|
{
|
|
return Curl_dynhds_h1_add_line(dynhds, line, line ? strlen(line) : 0);
|
|
}
|
|
|
|
#ifdef UNITTESTS
|
|
/* @unittest 2602 */
|
|
|
|
/**
|
|
* Return TRUE iff one or more headers with the given name exist.
|
|
*/
|
|
UNITTEST bool dynhds_contains(struct dynhds *dynhds,
|
|
const char *name, size_t namelen);
|
|
UNITTEST bool dynhds_contains(struct dynhds *dynhds,
|
|
const char *name, size_t namelen)
|
|
{
|
|
return !!Curl_dynhds_get(dynhds, name, namelen);
|
|
}
|
|
|
|
/* @unittest 2602 */
|
|
UNITTEST bool dynhds_ccontains(struct dynhds *dynhds, const char *name);
|
|
UNITTEST bool dynhds_ccontains(struct dynhds *dynhds, const char *name)
|
|
{
|
|
return dynhds_contains(dynhds, name, strlen(name));
|
|
}
|
|
|
|
/**
|
|
* Return how often the given name appears in `dynhds`.
|
|
* Names are case-insensitive.
|
|
*
|
|
* @unittest 2602
|
|
*/
|
|
UNITTEST size_t dynhds_count_name(struct dynhds *dynhds,
|
|
const char *name, size_t namelen);
|
|
UNITTEST size_t dynhds_count_name(struct dynhds *dynhds,
|
|
const char *name, size_t namelen)
|
|
{
|
|
size_t n = 0;
|
|
if(dynhds->hds_len) {
|
|
size_t i;
|
|
for(i = 0; i < dynhds->hds_len; ++i) {
|
|
if((namelen == dynhds->hds[i]->namelen) &&
|
|
curl_strnequal(name, dynhds->hds[i]->name, namelen))
|
|
++n;
|
|
}
|
|
}
|
|
return n;
|
|
}
|
|
|
|
/**
|
|
* Return how often the given null-terminated name appears in `dynhds`.
|
|
* Names are case-insensitive.
|
|
*
|
|
* @unittest 2602
|
|
*/
|
|
UNITTEST size_t dynhds_ccount_name(struct dynhds *dynhds,
|
|
const char *name);
|
|
UNITTEST size_t dynhds_ccount_name(struct dynhds *dynhds,
|
|
const char *name)
|
|
{
|
|
return dynhds_count_name(dynhds, name, strlen(name));
|
|
}
|
|
|
|
/**
|
|
* Remove all entries with the given name.
|
|
* Returns number of entries removed.
|
|
*
|
|
* @unittest 2602
|
|
*/
|
|
UNITTEST size_t dynhds_remove(struct dynhds *dynhds,
|
|
const char *name, size_t namelen);
|
|
UNITTEST size_t dynhds_remove(struct dynhds *dynhds,
|
|
const char *name, size_t namelen)
|
|
{
|
|
size_t n = 0;
|
|
if(dynhds->hds_len) {
|
|
size_t i, len;
|
|
for(i = 0; i < dynhds->hds_len; ++i) {
|
|
if((namelen == dynhds->hds[i]->namelen) &&
|
|
curl_strnequal(name, dynhds->hds[i]->name, namelen)) {
|
|
++n;
|
|
--dynhds->hds_len;
|
|
dynhds->strs_len -= (dynhds->hds[i]->namelen +
|
|
dynhds->hds[i]->valuelen);
|
|
entry_free(dynhds->hds[i]);
|
|
len = dynhds->hds_len - i; /* remaining entries */
|
|
if(len) {
|
|
memmove(&dynhds->hds[i], &dynhds->hds[i + 1],
|
|
len * sizeof(dynhds->hds[i]));
|
|
}
|
|
--i; /* do this index again */
|
|
}
|
|
}
|
|
}
|
|
return n;
|
|
}
|
|
|
|
/**
|
|
* Set the give header name and value, replacing any entries with
|
|
* the same name. The header is added at the end of all (remaining)
|
|
* entries.
|
|
*
|
|
* @unittest 2602
|
|
*/
|
|
UNITTEST CURLcode dynhds_set(struct dynhds *dynhds,
|
|
const char *name, size_t namelen,
|
|
const char *value, size_t valuelen);
|
|
UNITTEST CURLcode dynhds_set(struct dynhds *dynhds,
|
|
const char *name, size_t namelen,
|
|
const char *value, size_t valuelen)
|
|
{
|
|
dynhds_remove(dynhds, name, namelen);
|
|
return Curl_dynhds_add(dynhds, name, namelen, value, valuelen);
|
|
}
|
|
|
|
/* @unittest 2602 */
|
|
UNITTEST size_t dynhds_cremove(struct dynhds *dynhds, const char *name);
|
|
UNITTEST size_t dynhds_cremove(struct dynhds *dynhds, const char *name)
|
|
{
|
|
return dynhds_remove(dynhds, name, strlen(name));
|
|
}
|
|
|
|
#endif /* UNITTESTS */
|
|
|
|
CURLcode Curl_dynhds_h1_dprint(struct dynhds *dynhds, struct dynbuf *dbuf)
|
|
{
|
|
CURLcode result = CURLE_OK;
|
|
size_t i;
|
|
|
|
if(!dynhds->hds_len)
|
|
return result;
|
|
|
|
for(i = 0; i < dynhds->hds_len; ++i) {
|
|
result = curlx_dyn_addf(dbuf, "%.*s: %.*s\r\n",
|
|
(int)dynhds->hds[i]->namelen, dynhds->hds[i]->name,
|
|
(int)dynhds->hds[i]->valuelen,
|
|
dynhds->hds[i]->value);
|
|
if(result)
|
|
break;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#ifdef USE_NGHTTP2
|
|
|
|
nghttp2_nv *Curl_dynhds_to_nva(struct dynhds *dynhds, size_t *pcount)
|
|
{
|
|
nghttp2_nv *nva = curlx_calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len);
|
|
size_t i;
|
|
|
|
*pcount = 0;
|
|
if(!nva)
|
|
return NULL;
|
|
|
|
for(i = 0; i < dynhds->hds_len; ++i) {
|
|
struct dynhds_entry *e = dynhds->hds[i];
|
|
DEBUGASSERT(e);
|
|
nva[i].name = (unsigned char *)e->name;
|
|
nva[i].namelen = e->namelen;
|
|
nva[i].value = (unsigned char *)e->value;
|
|
nva[i].valuelen = e->valuelen;
|
|
nva[i].flags = NGHTTP2_NV_FLAG_NONE;
|
|
}
|
|
*pcount = dynhds->hds_len;
|
|
return nva;
|
|
}
|
|
|
|
#endif /* USE_NGHTTP2 */
|