alpha-crtl: 3 rungs so REAL zlib 1.3.1 links zero-deferred out-of-box - #869
Merged
Merged
Conversation
Close the three CRTL residuals a prior probe measured on the alpha-dec-vms port (all 15 zlib TUs already compile clean at harness flags; these were the LINK/header-surface gaps that kept it from linking without manual symbol adds or labelled probes): 1. unixio.h on the port CRTL include surface. zconf.h does `#ifdef VMS #include <unixio.h>` -- the alpha-dec-vms port predefines VMS (correctly; it IS a VMS toolchain), but the musl-alpha CRTL header surface had no <unixio.h>. Add a faithful, DECLARE-ONLY <unixio.h> to the alpha-dec-vms arch overlay (open/close/read/write/lseek/dup/dup2/isatty/ unlink/access/ftruncate/fsync/chdir/getcwd) -- every one already IMPLEMENTED by the port musl; signatures track musl's own unistd.h/fcntl.h so a TU that includes both sees identical prototypes. VMS-target-scoped (arch overlay), never surfaced for a non-VMS target. 2. Export the errno accessor from the alpha DECC$SHR. musl's <errno.h> defines `errno` as `(*__errno_location())`; that plain, musl-internal name is not a DEC C RTL surface name, so the alpha cc1 does NOT decorate it to decc$* and the linker-view decc$ enumeration misses it. LINK.EXE's EVAX reader names the external C symbol with one leading underscore prepended (uniformly for the musl definition and every consumer reference), so at the vector level it is `___errno_location` (three underscores) -- the exact name gzread.obj deferred. Add `___errno_location=PROCEDURE` to the alpha-branch symbol vector, bringing alpha to parity with the generic (x86_64/aarch64) branch, which already exports the errno accessor. Alpha-branch only; the generic branch is untouched. 3. --use LIBOTS$SHR.EXE on the canonical consumer link. The port lowers every integer divide/remainder to OTS$DIV_*/OTS$REM_* (Alpha has no integer-divide instruction); those universals live in the SEPARATE LIBOTS$ shareable. DECC$SHR imports OTS$ for its own use but does not transitively re-export it, so a consumer that divides (zlib, and most real C) defers OTS$DIV_UL/ OTS$REM_UI against DECC$SHR alone. Add `--use LIBOTS$SHR.EXE` alongside `--use DECC$SHR.EXE` in build-joint-image.sh's link recipe. LINK binds only REFERENCED imports, so this is inert for programs (like the default joint_main) that emit no OTS$ call. VERIFIED (containerized, build-to-/tmp, Rule-9-clean; NOT run under qemu-user): REAL zlib 1.3.1 (pinned sha256 9a93b2b7...df23) -- all 15 TUs + a compress/ uncompress round-trip main cross-compiled at harness flags (-mpointer-size=64 -g0) + -DZ_HAVE_UNISTD_H, linked against the FIXED DECC$SHR/LIBOTS$ via the FIXED recipe -> 0 %LINK-F-UNDEF OUT-OF-BOX (no manual adds), EM_ALPHA ET_DYN. No regression: default joint_e2e (crt0 + joint_main, DECC$SHR only) still links clean; the errno edit is inside the alpha branch of mk_decc_shr.sh so the aarch64 crtl_rms / generic branch is byte-unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 3 CRTL rungs
A prior probe measured that all 15 zlib 1.3.1 TUs already compile clean on the alpha-dec-vms port (0 EVAX cc1 defect at harness flags). These three fixes close the remaining LINK / header-surface residuals so REAL zlib compiles and links zero-deferred out-of-box — no labelled probes, no manual symbol adds.
zconf.hfires#ifdef VMS #include <unixio.h>(port predefines VMS — correct, it IS a VMS toolchain) but the musl-alpha CRTL header surface had no<unixio.h>tools/cross-alpha-vms/musl-arch/arch/alpha-dec-vms/unixio.h— faithful DECLARE-ONLY DEC C UNIX-I/O header (open/close/read/write/lseek/dup/dup2/isatty/unlink/access/ftruncate/fsync/chdir/getcwd), every entry already implemented by the port musl; VMS-target-scoped in the arch overlayerrnoaccessor UNDEF at LINK — musl'serrno=(*__errno_location()), an undecorated musl-internal name the alpha cc1 does not map todecc$*, so the linker-viewdecc$enumeration misses itsrc/vmslink/mk_decc_shr.sh— add___errno_location=PROCEDUREto the alpha-branch symbol vector (LINK.EXE's EVAX reader represents the external C symbol__errno_locationwith one leading underscore prepended, uniformly for def + ref →___errno_location, three underscores, the exact name gzread.obj deferred). Brings alpha to parity with the generic branch, which already exports the errno accessorOTS$DIV_UL/OTS$REM_UIUNDEF — the port lowers integer divide/rem to OTS$ calls; those live in the SEPARATE LIBOTS$ shareable, which DECC$SHR imports but does not re-exporttools/cross-alpha-vms/joint-e2e/build-joint-image.sh— add--use LIBOTS$SHR.EXEalongside--use DECC$SHR.EXEin the canonical consumer link recipe. LINK binds only referenced imports → inert for OTS-free programserrno-mechanism note
The C symbol is
__errno_location(two underscores; how GNU nm reports it inlibc.a). LINK.EXE's EVAX symbol reader prepends one leading underscore to external C symbols — uniformly for the musl definition and every consumer reference — so at the link/vector level the name is___errno_location(three underscores). This is why the two-underscore C-form export did NOT resolvegzread.obj's reference (%LINK-F-UNDEF, EVAX: undefined symbol '___errno_location' referenced by gzread.obj); exporting the three-underscore name closes it. The DEC-C-decorateddecc$get_errno_addris a different (DEC C) errno ABI and is unrelated to what musl-compiled consumer code references.Zlib zero-deferred out-of-box — proof
Containerized (
ovmx-cross-alpha-vms), build-to-/tmp, Rule-9-clean. Not run under qemu-user (BOOT-A/B is the runtime test).sha256 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23.-mpointer-size=64 -g0) +-DZ_HAVE_UNISTD_H→ compile clean.--transfer __main --use DECC$SHR.EXE --use LIBOTS_SHR.EXE):zlib link rc=0 ; LINK-F-UNDEF count=0→ ZERO-DEFERRED OUT-OF-BOX (no manual adds)Machine: Alpha,Type: DYNunixio.h present at .../arch/alpha-dec-vms/unixio.h; all 15 TUs (incl. gzread, which pulls<unixio.h>via zconf.h) compile.No regression
--use DECC$SHR.EXEonly) rebuilt live → links clean (rung-3's LIBOTS is inert for OTS-free programs).run_vmsrms_native.sh, which already exports__errno_location): depends solely on the generic branch ofmk_decc_shr.sh; the errno edit is inside the alpha branch (if [ "$OVMX_DECC_ARCH" = alpha ]), so that branch is byte-unchanged → structurally cannot regress. unixio.h is alpha-arch-scoped; the LIBOTS edit is joint-only.zlib build recipe (for the PR record)
Out-of-scope observation (separate, not a CRTL rung)
Compiling zlib at
-O2(not harness flags) surfaces an EVAX cc1/as codegen defect:deflate.cat-O2produces.sthe alpha-dec-vmsasrejects (Error: syntax error). Independent of these three rungs (they are all LINK / header-surface); tracked separately.🤖 Generated with Claude Code