Skip to content

fix(toolchain): build the wasi-libc sysroot on bash 3.2 - #1918

Open
WyvernMonarch wants to merge 1 commit into
rivet-dev:mainfrom
WyvernMonarch:fix/wasi-libc-sysroot-bash32
Open

fix(toolchain): build the wasi-libc sysroot on bash 3.2#1918
WyvernMonarch wants to merge 1 commit into
rivet-dev:mainfrom
WyvernMonarch:fix/wasi-libc-sysroot-bash32

Conversation

@WyvernMonarch

Copy link
Copy Markdown

Summary

patch-wasi-libc.sh uses mapfile (a bash 4 builtin) under a #!/bin/bash shebang. macOS ships bash 3.2 at /bin/bash, so the sysroot build dies with exit 127 before applying any patch — the wasm command set cannot be built on darwin at all. This rewrites the mapfile usage in bash-3.2-compatible form; behavior on bash 4+ is unchanged.

Found while building the wasm coreutils payload on a mac; with this fix the full sysroot + command-set build completes on stock macOS bash.

🤖 Generated with Claude Code

`patch-wasi-libc.sh` collected its patch list with `mapfile`, a bash 4
builtin. macOS ships bash 3.2 as /bin/bash, which the script's shebang
selects, so `make -C toolchain/c sysroot` died immediately with
"mapfile: command not found" (exit 127) before applying a single patch —
the wasm command set could not be built on darwin at all.

Read the list with a `while IFS= read -r` loop instead. Same ordering
(forward for apply/check, reverse for reverse), same empty-list handling,
and no bash-4 builtins. Avoids passing an empty array under `set -u`,
which bash 3.2 also rejects, by selecting the sort order with a function
rather than an argument array.

Verified: `make -C toolchain/c sysroot` now completes (exit 0) on
darwin 24.1 / bash 3.2, and `make pr-commands` builds 101 wasm binaries
on top of the resulting sysroot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant