Files
jak-project/third-party/curl/projects/vms/generate_vax_transfer.com
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

274 lines
8.1 KiB
Plaintext
Vendored
Generated

$! File: generate_vax_transfer.com
$!
$! File to generate and compile the VAX transfer vectors from reading in the
$! Alpha/Itanium gnv_libcurl_symbols.opt file.
$!
$! This procedure patches the VAX Macro32 assembler to be case sensitive
$! and then compiles the generated
$!
$! The output of this procedure is:
$! gnv_libcurl_xfer.mar_exact
$! gnv_libcurl_xfer.obj
$! gnv_libcurl_xfer.opt
$! macro32_exactcase.exe
$!
$! Copyright (C) John Malmberg
$!
$! Permission to use, copy, modify, and/or distribute this software for any
$! purpose with or without fee is hereby granted, provided that the above
$! copyright notice and this permission notice appear in all copies.
$!
$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
$!
$! SPDX-License-Identifier: ISC
$!
$!============================================================================
$!
$! Save this so we can get back.
$ default_dir = f$environment("default")
$!
$ on warning then goto all_exit
$!
$! Want hard tabs in the generated file.
$ tab[0,8] = 9
$!
$! This procedure is used on VAX only
$ if (f$getsyi("HW_MODEL") .ge. 1024)
$ then
$ write sys$output "This procedure is only used on VAX."
$ goto all_exit
$ endif
$!
$!
$! Get the libcurl version to generate the ident string.
$! ident string is max of 31 characters.
$!
$ ident_string = "unknown"
$ open/read cver [-.-.include.curl]curlver.h
$cver_loop:
$ read/end=cver_loop_end cver line_in
$ line_in = f$edit(line_in, "COMPRESS,TRIM")
$ if line_in .eqs. "" then goto cver_loop
$ code = f$extract(0, 1, line_in)
$ if code .nes. "#" then goto cver_loop
$ directive = f$element(0, " ", line_in)
$ if directive .nes. "#define" then goto cver_loop
$ name = f$element(1, " ", line_in)
$ if name .nes. "LIBCURL_VERSION" then goto cver_loop
$ ident_string = f$element(2, " ", line_in) - "" - ""
$cver_loop_end:
$ close cver
$!
$ open/read aopt gnv_libcurl_symbols.opt
$!
$! Write out the header
$ gosub do_header
$!
$ open/append vopt gnv_libcurl_xfer.mar_exact
$ write vopt tab,".IDENT /", ident_string, "/"
$!
$ write vopt tab, ".PSECT LIBCURL_XFERVECTORS -"
$ write vopt tab,tab,tab, "PIC,USR,CON,REL,GBL,SHR,EXE,RD,NOWRT,QUAD"
$ write vopt ""
$ write vopt tab, "SPARE", tab, "; never delete this spare"
$ write vopt ";"
$ write vopt ";", tab, "Exact case and upper case transfer vectors"
$!
$ alias_count = 0
$vector_loop:
$!
$! Read in symbol_vector
$!
$ read/end=vector_loop_end aopt line_in
$ line = f$edit(line_in, "UNCOMMENT,COMPRESS,TRIM")
$ if line .eqs. "" then goto vector_loop
$!
$ line_u = f$edit(line, "UPCASE")
$ key = f$element(0, "=", line_u)
$ if (key .eqs. "SYMBOL_VECTOR")
$ then
$ symbol_string = f$element(1, "=", line) - "("
$ symbol_type = f$element(2, "=", line_u) - ")"
$ symbol_name = f$element(1, "/", symbol_string)
$ if symbol_type .nes. "PROCEDURE"
$ then
$ write sys$output "%CURLBUILD-W-NOTPROC, " + -
$ "This procedure can only handle procedure vectors"
$ write sys$output -
"Data vectors require manual construction for which this procedure or"
$ write sys$output -
"the shared library needs to be updated to resolve."
$ write sys$output -
"the preferred solution is to have a procedure return the address of the "
$ write sys$output -
"the variable instead of having a variable, as if the size of the variable "
write sys$output -
"changes, the symbol vector is no longer backwards compatible."
$ endif
$ if (symbol_name .eqs. "/")
$ then
$ symbol_name = symbol_string
$ write vopt tab, symbol_type, tab, symbol_name
$ else
$ alias_count = alias_count + 1
$ symbol_alias = f$element(0, "/", symbol_string)
$ write vopt -
tab, "''symbol_type_U", tab, symbol_name, tab, symbol_alias
$ endif
$ endif
$ goto vector_loop
$vector_loop_end:
$!
$! End of pass one, second pass needed if aliases exist
$ close aopt
$!
$ if alias_count .eq. 0 then goto finish_file
$!
$! Start pass 2, write stub routine header
$!
$ open/read aopt gnv_libcurl_symbols.opt
$!
$alias_loop:
$!
$! Read in symbol_vector
$!
$ read/end=alias_loop_end aopt line_in
$ line = f$edit(line_in, "UNCOMMENT,COMPRESS,TRIM")
$ if line .eqs. "" then goto alias_loop
$!
$ line_u = f$edit(line, "UPCASE")
$ key = f$element(0, "=", line_u)
$ if (key .eqs. "SYMBOL_VECTOR")
$ then
$ symbol_string = f$element(1, "=", line) - "("
$ symbol_type = f$element(2, "=", line_u) - ")"
$ symbol_name = f$element(1, "/", symbol_string)
$ if (symbol_name .eqs. "/")
$ then
$ symbol_name = symbol_string
$ else
$ alias_count = alias_count + 1
$ symbol_alias = f$element(0, "/", symbol_string)
$ write vopt tab, ".ENTRY", tab, symbol_alias, ", ^M<>"
$ endif
$ endif
$ goto alias_loop
$! read in symbol_vector
$! if not alias, then loop
$! write out subroutine name
$!
$alias_loop_end:
$!
$ write vopt tab, "MOVL #1, R0"
$ write vopt tab, "RET"
$!
$finish_file:
$!
$ write vopt ""
$ write vopt tab, ".END"
$!
$ close aopt
$ close vopt
$!
$! Patch the Macro32 compiler
$!----------------------------
$ patched_macro = "sys$disk:[]macro32_exactcase.exe"
$ if f$search(patched_macro) .eqs. ""
$ then
$ copy sys$system:macro32.exe 'patched_macro'
$ patch @macro32_exactcase.patch
$ endif
$ define/user macro32 'patched_macro'
$ macro/object=gnv_libcurl_xfer.obj gnv_libcurl_xfer.mar_exact
$!
$! Create the option file for linking the shared image.
$ create gnv_libcurl_xfer.opt
$ open/append lco gnv_libcurl_xfer.opt
$ write lco "gsmatch=lequal,1,1"
$ write lco "cluster=transfer_vector,,,''default_dir'gnv_libcurl_xfer"
$ write lco "collect=libcurl_global, libcurl_xfervectors"
$ close lco
$!
$!
$ goto all_exit
$!
$! Process the header
$do_header:
$!
$! Force the mode of the file to same as text editor generated.
$ create gnv_libcurl_xfer.mar_exact
$deck
; File: gnv_libcurl_xfer.mar_exact
;
; VAX transfer vectors
;
; This needs to be compiled with a specialized patch on Macro32 to make it
; preserve the case of symbols instead of converting it to uppercase.
;
; This patched Macro32 requires all directives to be in upper case.
;
; There are three sets of symbols for transfer vectors here.
;
; The first for upper case which matches the tradition method of generating
; VAX transfer vectors.
;
; The second is the exact case for compatibility with open source C programs
; that expect exact case symbols in images. These are separated because a
; previous kit had only upper case symbols.
;
; The third is the routine stub that is used to resolve part of the upper
; case transfer vectors, with exact case entry symbols.
;
; When you add routines, you need to add them after the second set of transfer
; vectors for both upper and exact case, and then additional entry points
; in upper case added to stub routines.
;
;*************************************************************************
.TITLE libcurl_xfer - Transfer vector for libcurl
.DISABLE GLOBAL
;
; Macro to generate a transfer vector entry
;
.MACRO PROCEDURE NAME
.EXTRN 'NAME
.ALIGN QUAD
.TRANSFER 'NAME
.MASK 'NAME
JMP 'NAME+2
.ENDM
.MACRO PROCEDUREU NAME NAMEU
.EXTRN 'NAME
.ALIGN QUAD
.TRANSFER 'NAMEU
.MASK 'NAME
JMP 'NAME+2
.ENDM
;
;
; Macro to reserve a spare entry.
;
.MACRO SPARE
.ALIGN QUAD
.ALIGN QUAD
.QUAD 0
.ENDM
$EOD
$!
$!
$ return
$!
$all_exit:
$set def 'default_dir'
$exit '$status'