fix(toolchain): avoid bash / scripting issues on MacOS#1870
Open
sakompella wants to merge 4 commits into
Open
Conversation
bash versions under 4 lack `mapfile`. In particular, this means any macOS machines will break (especially as `#!` points to `/bin/bash` rather than using `#!/usr/bin/env bash`).
Not every environment ships GNU coreutils' sha256sum. In particular, macOS ships only `shasum -a 256` by default. Resolve the digest command once into an array (needed so it still composes with the xargs pipeline, since xargs execs external commands, not shell functions), matching the same command -v fallback already used in build-openssl-upstream.sh and build-ssh-upstream.sh.
…s GNU/BSD patch Some non-GNU patch implementations auto-answer their interactive "Ignore -R?" prompt's "[y]" default non-deterministically when stdin isn't a tty. In particular, BSD/Apple patch -- as shipped by macOS -- does this, which can make a reverse dry-run falsely report "already applied" on a genuinely unpatched tree, skipping the real patch application and causing later compile errors (e.g. libunwind's wasm-exception-support patch). Reproduced directly: without -f, a reverse dry-run against an unpatched tree reported false success; with -f, it correctly reports failure (and still correctly reports success against an already-patched tree). -f is a standard flag on both GNU and BSD patch, so this keeps the forward/reverse detection deterministic regardless of which implementation is on PATH.
Matches the env-relative shebang convention already used by most other scripts in the repo, and lets anyone with a newer bash earlier on PATH opt in without needing bash-3.2-compatible rewrites as a fallback. Left scripts/ralph/ralph-docker.sh, ralph-docker-per-iter.sh (docker orchestration wrappers whose target environment is fixed by the container image), scripts/ralph/ralph.sh, and the vendored upstream software/vim/share/vim/vim92/macros/less.sh untouched.
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.
This is a series of small script fixes.
toolchain/scripts/patch-wasi-libc.shuses#!/bin/bashshebang, as well asmapfilebuiltin.mapfilebash builtin is only available forbash 4.x/bin/bashis stuck on version3.2.57(on MacOS26.5) and will not update. Does not have access tomapfile, leading to failure runningmake sysroot, with errormapfile: command not foundwhile readloop over the same process substitutionshasumifsha256sumis not installed.patchalong with GNUpatch.#!/bin/bashwith#!/usr/bin/env bash, which is more standard, and will use$PATH(ex, if user usedbrew'sbash, which is more up-to-date, this would not have happened)