mirror of
https://github.com/open-goal/jak-project
synced 2026-08-19 22:12:24 -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)
233 lines
7.6 KiB
C
Vendored
Generated
233 lines
7.6 KiB
C
Vendored
Generated
#ifndef HEADER_CURL_SELECT_H
|
|
#define HEADER_CURL_SELECT_H
|
|
/***************************************************************************
|
|
* _ _ ____ _
|
|
* 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"
|
|
|
|
#ifdef HAVE_POLL_H
|
|
#include <poll.h>
|
|
#elif defined(HAVE_SYS_POLL_H)
|
|
#include <sys/poll.h>
|
|
#endif
|
|
|
|
/*
|
|
* Definition of pollfd struct and constants for platforms lacking them.
|
|
*/
|
|
|
|
#if !defined(HAVE_SYS_POLL_H) && !defined(HAVE_POLL_H) && !defined(POLLIN)
|
|
|
|
#define POLLIN 0x01
|
|
#define POLLPRI 0x02
|
|
#define POLLOUT 0x04
|
|
#define POLLERR 0x08
|
|
#define POLLHUP 0x10
|
|
#define POLLNVAL 0x20
|
|
|
|
struct pollfd {
|
|
curl_socket_t fd;
|
|
short events;
|
|
short revents;
|
|
};
|
|
|
|
#endif
|
|
|
|
#ifndef POLLRDNORM
|
|
#define POLLRDNORM POLLIN
|
|
#endif
|
|
|
|
#ifndef POLLWRNORM
|
|
#define POLLWRNORM POLLOUT
|
|
#endif
|
|
|
|
#ifndef POLLRDBAND
|
|
#define POLLRDBAND POLLPRI
|
|
#endif
|
|
|
|
/* there are three CSELECT defines that are defined in the public header that
|
|
are exposed to users, but this *IN2 bit is only ever used internally and
|
|
therefore defined here */
|
|
#define CURL_CSELECT_IN2 (CURL_CSELECT_ERR << 1)
|
|
|
|
int Curl_socket_check(curl_socket_t readfd0,
|
|
curl_socket_t readfd1,
|
|
curl_socket_t writefd,
|
|
timediff_t timeout_ms);
|
|
#define SOCKET_READABLE(x, z) \
|
|
Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
|
|
#define SOCKET_WRITABLE(x, z) \
|
|
Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, x, z)
|
|
|
|
int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms);
|
|
|
|
/*
|
|
With Winsock the valid range is [0..INVALID_SOCKET-1] according to
|
|
https://learn.microsoft.com/windows/win32/winsock/socket-data-type-2
|
|
*/
|
|
#ifdef USE_WINSOCK
|
|
#define VALID_SOCK(s) ((s) < INVALID_SOCKET)
|
|
#define FDSET_SOCK(x) 1
|
|
#define VERIFY_SOCK(x) \
|
|
do { \
|
|
if(!VALID_SOCK(x)) { \
|
|
SET_SOCKERRNO(SOCKEINVAL); \
|
|
return -1; \
|
|
} \
|
|
} while(0)
|
|
#else
|
|
#define VALID_SOCK(s) ((s) >= 0)
|
|
|
|
/* If the socket is small enough to get set or read from an fdset */
|
|
#define FDSET_SOCK(s) ((s) < FD_SETSIZE)
|
|
|
|
#define VERIFY_SOCK(x) \
|
|
do { \
|
|
if(!VALID_SOCK(x) || !FDSET_SOCK(x)) { \
|
|
SET_SOCKERRNO(SOCKEINVAL); \
|
|
return -1; \
|
|
} \
|
|
} while(0)
|
|
#endif
|
|
|
|
/* Keep the sockets to poll for an easy handle.
|
|
* `actions` are bitmaps of CURL_POLL_IN and CURL_POLL_OUT.
|
|
* Starts with small capacity, grows on demand.
|
|
*/
|
|
#define EZ_POLLSET_DEF_COUNT 2
|
|
|
|
struct easy_pollset {
|
|
curl_socket_t *sockets;
|
|
unsigned char *actions;
|
|
unsigned int n;
|
|
unsigned int count;
|
|
#ifdef DEBUGBUILD
|
|
int init;
|
|
#endif
|
|
curl_socket_t def_sockets[EZ_POLLSET_DEF_COUNT];
|
|
unsigned char def_actions[EZ_POLLSET_DEF_COUNT];
|
|
};
|
|
|
|
#ifdef DEBUGBUILD
|
|
#define CURL_EASY_POLLSET_MAGIC 0x7a657370
|
|
#endif
|
|
|
|
/* allocate and initialize */
|
|
struct easy_pollset *Curl_pollset_create(void);
|
|
|
|
/* Initialize before first use */
|
|
void Curl_pollset_init(struct easy_pollset *ps);
|
|
/* Free any allocated resources */
|
|
void Curl_pollset_cleanup(struct easy_pollset *ps);
|
|
/* Reset to an empty pollset */
|
|
void Curl_pollset_reset(struct easy_pollset *ps);
|
|
/* Move pollset from to pollset to, replacing all in to,
|
|
* leaving from empty. */
|
|
void Curl_pollset_move(struct easy_pollset *to, struct easy_pollset *from);
|
|
|
|
/* Change the poll flags (CURL_POLL_IN/CURL_POLL_OUT) to the poll set for
|
|
* socket `sock`. If the socket is not already part of the poll set, it
|
|
* will be added.
|
|
* If the socket is present and all poll flags are cleared, it will be removed.
|
|
*/
|
|
CURLcode Curl_pollset_change(struct Curl_easy *data,
|
|
struct easy_pollset *ps, curl_socket_t sock,
|
|
int add_flags,
|
|
int remove_flags) WARN_UNUSED_RESULT;
|
|
|
|
CURLcode Curl_pollset_set(struct Curl_easy *data,
|
|
struct easy_pollset *ps, curl_socket_t sock,
|
|
bool do_in, bool do_out) WARN_UNUSED_RESULT;
|
|
|
|
#define Curl_pollset_add_in(data, ps, sock) \
|
|
Curl_pollset_change(data, ps, sock, CURL_POLL_IN, 0)
|
|
#define Curl_pollset_remove_in(data, ps, sock) \
|
|
Curl_pollset_change(data, ps, sock, 0, CURL_POLL_IN)
|
|
#define Curl_pollset_add_out(data, ps, sock) \
|
|
Curl_pollset_change(data, ps, sock, CURL_POLL_OUT, 0)
|
|
#define Curl_pollset_remove_out(data, ps, sock) \
|
|
Curl_pollset_change(data, ps, sock, 0, CURL_POLL_OUT)
|
|
#define Curl_pollset_add_inout(data, ps, sock) \
|
|
Curl_pollset_change(data, ps, sock, CURL_POLL_IN | CURL_POLL_OUT, 0)
|
|
#define Curl_pollset_set_in_only(data, ps, sock) \
|
|
Curl_pollset_change(data, ps, sock, CURL_POLL_IN, CURL_POLL_OUT)
|
|
#define Curl_pollset_set_out_only(data, ps, sock) \
|
|
Curl_pollset_change(data, ps, sock, CURL_POLL_OUT, CURL_POLL_IN)
|
|
|
|
/* return < = on error, 0 on timeout or how many sockets are ready */
|
|
int Curl_pollset_poll(struct Curl_easy *data,
|
|
struct easy_pollset *ps,
|
|
timediff_t timeout_ms);
|
|
|
|
/**
|
|
* Check if the pollset, as is, wants to read and/or write regarding
|
|
* the given socket.
|
|
*/
|
|
void Curl_pollset_check(struct Curl_easy *data,
|
|
struct easy_pollset *ps, curl_socket_t sock,
|
|
bool *pwant_read, bool *pwant_write);
|
|
|
|
/* TRUE if the pollset contains socket with CURL_POLL_IN. */
|
|
bool Curl_pollset_want_recv(struct Curl_easy *data,
|
|
struct easy_pollset *ps,
|
|
curl_socket_t sock);
|
|
/* TRUE if the pollset contains socket with CURL_POLL_OUT. */
|
|
bool Curl_pollset_want_send(struct Curl_easy *data,
|
|
struct easy_pollset *ps,
|
|
curl_socket_t sock);
|
|
|
|
struct curl_pollfds {
|
|
struct pollfd *pfds;
|
|
unsigned int n;
|
|
unsigned int count;
|
|
BIT(allocated_pfds);
|
|
};
|
|
|
|
void Curl_pollfds_init(struct curl_pollfds *cpfds,
|
|
struct pollfd *static_pfds,
|
|
unsigned int static_count);
|
|
|
|
void Curl_pollfds_reset(struct curl_pollfds *cpfds);
|
|
|
|
void Curl_pollfds_cleanup(struct curl_pollfds *cpfds);
|
|
|
|
CURLcode Curl_pollfds_add_ps(struct curl_pollfds *cpfds,
|
|
struct easy_pollset *ps);
|
|
|
|
CURLcode Curl_pollfds_add_sock(struct curl_pollfds *cpfds,
|
|
curl_socket_t sock, short events);
|
|
|
|
struct Curl_waitfds {
|
|
struct curl_waitfd *wfds;
|
|
unsigned int n;
|
|
unsigned int count;
|
|
};
|
|
|
|
void Curl_waitfds_init(struct Curl_waitfds *cwfds,
|
|
struct curl_waitfd *static_wfds,
|
|
unsigned int static_count);
|
|
|
|
unsigned int Curl_waitfds_add_ps(struct Curl_waitfds *cwfds,
|
|
struct easy_pollset *ps);
|
|
|
|
#endif /* HEADER_CURL_SELECT_H */
|