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)
284 lines
9.8 KiB
C
Vendored
Generated
284 lines
9.8 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"
|
|
|
|
/***********************************************************************
|
|
* Only for plain IPv4 builds
|
|
**********************************************************************/
|
|
#ifdef CURLRES_IPV4 /* plain IPv4 code coming up */
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
#include <netinet/in.h>
|
|
#endif
|
|
#ifdef HAVE_NETDB_H
|
|
#include <netdb.h>
|
|
#endif
|
|
#ifdef HAVE_ARPA_INET_H
|
|
#include <arpa/inet.h>
|
|
#endif
|
|
#ifdef __VMS
|
|
#include <in.h>
|
|
#include <inet.h>
|
|
#endif
|
|
|
|
#include "urldata.h"
|
|
#include "curl_addrinfo.h"
|
|
#include "curl_trc.h"
|
|
#include "hostip.h"
|
|
#include "url.h"
|
|
|
|
|
|
#ifdef CURLRES_SYNCH
|
|
|
|
/*
|
|
* Curl_sync_getaddrinfo() - the IPv4 synchronous version.
|
|
*
|
|
* The original code to this function was from the Dancer source code, written
|
|
* by Bjorn Reese, it has since been patched and modified considerably.
|
|
*
|
|
* gethostbyname_r() is the thread-safe version of the gethostbyname()
|
|
* function. When we build for plain IPv4, we attempt to use this
|
|
* function. There are _three_ different gethostbyname_r() versions, and we
|
|
* detect which one this platform supports in the configure script and set up
|
|
* the HAVE_GETHOSTBYNAME_R_3, HAVE_GETHOSTBYNAME_R_5 or
|
|
* HAVE_GETHOSTBYNAME_R_6 defines accordingly. Note that HAVE_GETADDRBYNAME
|
|
* has the corresponding rules. This is primarily on *nix. Note that some Unix
|
|
* flavors have thread-safe versions of the plain gethostbyname() etc.
|
|
*
|
|
*/
|
|
struct Curl_addrinfo *Curl_sync_getaddrinfo(struct Curl_easy *data,
|
|
uint8_t dns_queries,
|
|
const char *hostname,
|
|
uint16_t port,
|
|
uint8_t transport)
|
|
{
|
|
struct Curl_addrinfo *ai = NULL;
|
|
|
|
(void)dns_queries;
|
|
(void)transport;
|
|
|
|
ai = Curl_ipv4_resolve_r(hostname, port);
|
|
if(!ai)
|
|
infof(data, "Curl_ipv4_resolve_r failed for %s", hostname);
|
|
|
|
return ai;
|
|
}
|
|
#endif /* CURLRES_SYNCH */
|
|
#endif /* CURLRES_IPV4 */
|
|
|
|
#if defined(CURLRES_IPV4) && !defined(USE_RESOLV_ARES) && \
|
|
!defined(CURLRES_AMIGA)
|
|
|
|
/*
|
|
* Curl_ipv4_resolve_r() - ipv4 thread-safe resolver function.
|
|
*
|
|
* This is used for both synchronous and asynchronous resolver builds,
|
|
* implying that only thread-safe code and function calls may be used.
|
|
*
|
|
*/
|
|
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|
uint16_t port)
|
|
{
|
|
#if !(defined(HAVE_GETADDRINFO) && defined(HAVE_GETADDRINFO_THREADSAFE)) && \
|
|
defined(HAVE_GETHOSTBYNAME_R_3)
|
|
int res;
|
|
#endif
|
|
struct Curl_addrinfo *ai = NULL;
|
|
#if !(defined(HAVE_GETADDRINFO) && defined(HAVE_GETADDRINFO_THREADSAFE))
|
|
struct hostent *h = NULL;
|
|
struct hostent *buf = NULL;
|
|
#endif
|
|
|
|
#if defined(HAVE_GETADDRINFO) && defined(HAVE_GETADDRINFO_THREADSAFE)
|
|
struct addrinfo hints;
|
|
char sbuf[12];
|
|
char *sbufptr = NULL;
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
hints.ai_family = PF_INET;
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
if(port) {
|
|
curl_msnprintf(sbuf, sizeof(sbuf), "%d", port);
|
|
sbufptr = sbuf;
|
|
}
|
|
|
|
(void)Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &ai);
|
|
|
|
#elif defined(HAVE_GETHOSTBYNAME_R)
|
|
/*
|
|
* gethostbyname_r() is the preferred resolve function for many platforms.
|
|
* Since there are three different versions of it, the following code is
|
|
* somewhat #ifdef-ridden.
|
|
*/
|
|
int h_errnop;
|
|
|
|
buf = curlx_calloc(1, CURL_HOSTENT_SIZE);
|
|
if(!buf)
|
|
return NULL; /* major failure */
|
|
/*
|
|
* The clearing of the buffer is a workaround for a gethostbyname_r bug in
|
|
* QNX Neutrino and it is also _required_ for some of these functions on some
|
|
* platforms.
|
|
*/
|
|
|
|
#ifdef HAVE_GETHOSTBYNAME_R_5
|
|
/* Solaris, IRIX and more */
|
|
h = gethostbyname_r(hostname,
|
|
(struct hostent *)buf,
|
|
(char *)buf + sizeof(struct hostent),
|
|
CURL_HOSTENT_SIZE - sizeof(struct hostent),
|
|
&h_errnop);
|
|
|
|
/* If the buffer is too small, it returns NULL and sets errno to
|
|
* ERANGE. The errno is thread-safe if this is compiled with
|
|
* -D_REENTRANT as then the 'errno' variable is a macro defined to get
|
|
* used properly for threads.
|
|
*/
|
|
|
|
if(h) {
|
|
;
|
|
}
|
|
else
|
|
#elif defined(HAVE_GETHOSTBYNAME_R_6)
|
|
/* Linux */
|
|
|
|
(void)gethostbyname_r(hostname,
|
|
(struct hostent *)buf,
|
|
(char *)buf + sizeof(struct hostent),
|
|
CURL_HOSTENT_SIZE - sizeof(struct hostent),
|
|
&h, /* DIFFERENCE */
|
|
&h_errnop);
|
|
/* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
|
|
* sudden this function returns EAGAIN if the given buffer size is too
|
|
* small. Previous versions are known to return ERANGE for the same
|
|
* problem.
|
|
*
|
|
* This would not be such a big problem if older versions would not
|
|
* sometimes return EAGAIN on a common failure case. Alas, we cannot
|
|
* assume that EAGAIN *or* ERANGE means ERANGE for any given version of
|
|
* glibc.
|
|
*
|
|
* For now, we do that and thus we may call the function repeatedly and
|
|
* fail for older glibc versions that return EAGAIN, until we run out of
|
|
* buffer size (step_size grows beyond CURL_HOSTENT_SIZE).
|
|
*
|
|
* If anyone has a better fix, please tell us!
|
|
*
|
|
* -------------------------------------------------------------------
|
|
*
|
|
* On October 23rd 2003, Dan C dug up more details on the mysteries of
|
|
* gethostbyname_r() in glibc:
|
|
*
|
|
* In glibc 2.2.5 the interface is different (this has also been
|
|
* discovered in glibc 2.1.1-6 as shipped by Redhat 6). What I cannot
|
|
* explain, is that tests performed on glibc 2.2.4-34 and 2.2.4-32
|
|
* (shipped/upgraded by Redhat 7.2) do not show this behavior!
|
|
*
|
|
* In this "buggy" version, the return code is -1 on error and 'errno'
|
|
* is set to the ERANGE or EAGAIN code. Note that 'errno' is not a
|
|
* thread-safe variable.
|
|
*/
|
|
|
|
if(!h) /* failure */
|
|
#elif defined(HAVE_GETHOSTBYNAME_R_3)
|
|
/* AIX, Digital UNIX/Tru64, HP-UX 10, more? */
|
|
|
|
/* For AIX 4.3 or later, we do not use gethostbyname_r() at all, because of
|
|
* the plain fact that it does not return unique full buffers on each
|
|
* call, but instead several of the pointers in the hostent structs will
|
|
* point to the same actual data! This have the unfortunate down-side that
|
|
* our caching system breaks down horribly. Luckily for us though, AIX 4.3
|
|
* and more recent versions have a "completely thread-safe"[*] libc where
|
|
* all the data is stored in thread-specific memory areas making calls to
|
|
* the plain old gethostbyname() work fine even for multi-threaded
|
|
* programs.
|
|
*
|
|
* This AIX 4.3 or later detection is all made in the configure script.
|
|
*
|
|
* Troels Walsted Hansen helped us work this out on March 3rd, 2003.
|
|
*
|
|
* [*] = much later we have found out that it is not at all "completely
|
|
* thread-safe", but at least the gethostbyname() function is.
|
|
*/
|
|
|
|
if(CURL_HOSTENT_SIZE >=
|
|
(sizeof(struct hostent) + sizeof(struct hostent_data))) {
|
|
|
|
/* August 22nd, 2000: Albert Chin-A-Young brought an updated version
|
|
* that should work! September 20: Richard Prescott worked on the buffer
|
|
* size dilemma.
|
|
*/
|
|
|
|
res = gethostbyname_r(hostname,
|
|
(struct hostent *)buf,
|
|
(struct hostent_data *)((char *)buf +
|
|
sizeof(struct hostent)));
|
|
h_errnop = SOCKERRNO; /* we do not deal with this, but set it anyway */
|
|
}
|
|
else
|
|
res = -1; /* failure, too smallish buffer size */
|
|
|
|
if(!res) { /* success */
|
|
|
|
h = buf; /* result expected in h */
|
|
|
|
/* This is the worst kind of the different gethostbyname_r() interfaces.
|
|
* Since we do not know how big buffer this particular lookup required,
|
|
* we cannot realloc down the huge alloc without doing closer analysis of
|
|
* the returned data. Thus, we always use CURL_HOSTENT_SIZE for every
|
|
* name lookup. Fixing this would require an extra allocation and then
|
|
* calling Curl_addrinfo_copy() that subsequent reallocation down the new
|
|
* memory area to the actually used amount.
|
|
*/
|
|
}
|
|
else
|
|
#endif /* HAVE_...BYNAME_R_5 || HAVE_...BYNAME_R_6 || HAVE_...BYNAME_R_3 */
|
|
{
|
|
h = NULL; /* set return code to NULL */
|
|
curlx_free(buf);
|
|
}
|
|
#else /* (HAVE_GETADDRINFO && HAVE_GETADDRINFO_THREADSAFE) ||
|
|
HAVE_GETHOSTBYNAME_R */
|
|
/*
|
|
* Here is code for platforms that do not have a thread-safe
|
|
* getaddrinfo() nor gethostbyname_r() function or for which
|
|
* gethostbyname() is the preferred one.
|
|
*/
|
|
h = gethostbyname(CURL_UNCONST(hostname));
|
|
#endif /* (HAVE_GETADDRINFO && HAVE_GETADDRINFO_THREADSAFE) ||
|
|
HAVE_GETHOSTBYNAME_R */
|
|
|
|
#if !(defined(HAVE_GETADDRINFO) && defined(HAVE_GETADDRINFO_THREADSAFE))
|
|
if(h) {
|
|
ai = Curl_he2ai(h, port);
|
|
|
|
if(buf) /* used a *_r() function */
|
|
curlx_free(buf);
|
|
}
|
|
#endif
|
|
|
|
return ai;
|
|
}
|
|
#endif /* CURLRES_IPV4 && !USE_RESOLV_ARES && !CURLRES_AMIGA */
|