Add macOS (Apple Silicon) build support#3
Merged
Merged
Conversation
The source was already POSIX-portable; only the build config was Linux/GCC specific. Make the build, CI, and docs cross-platform. - Makefile: detect Darwin via uname; drop -static-libstdc++/-static-libgcc (Apple clang has no such flags, libc++ is OS-provided and ABI-stable) and use otool -L instead of ldd. - CI: add a macos-14 (Apple Silicon) job to the build matrix; split deps into apt (Linux) and brew (macOS); use portable getconf for job count; ship a hprscript-macos-arm64 release asset (Linux x86-64 asset name unchanged). - Docs: README/HPRSCRIPT.md now document macOS install, Homebrew build deps, otool verification, and a Gatekeeper quarantine note. Also corrects the stale "Built for Linux x86-64" string left over from the Vectorscan switch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The macOS CI job failed building Vectorscan's hscollider tool, which needs pcre.h (pkg-config found Homebrew libpcre but the header isn't on clang's default include path). hprscript only links libhs.a, so build just the library: -DBUILD_TOOLS=OFF -DBUILD_UNIT=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARKS=OFF. Also removes an unneeded PCRE dependency and substantially speeds up the one-time Vectorscan build on every platform. Applied to both the CI workflow and the README build-from-source recipe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
BSD/macOS `wc -l` left-pads its count (" 5"), so the string compare
[[ "$COUNT" == "5" ]] failed even though the distinct-file count was correct.
Count lines with awk 'END{print NR}' instead, which emits a clean unpadded
integer on both GNU and BSD userlands.
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.
Summary
The
hprscriptsource was already POSIX-portable (mmap/posix_madvise/read, C++17<filesystem>) — only the build configuration was Linux/GCC-specific. This makes the build, CI, and docs cross-platform so it builds on macOS in addition to Linux.(iOS is intentionally not targeted — it has no user-accessible shell or
PATHfor a CLI tool to run in.)Changes
uname -s; on macOS drop-static-libstdc++/-static-libgcc(Apple clang has no such flags, and libc++ is OS-provided + ABI-stable) and useotool -Linstead ofldd. Linux behavior unchanged..github/workflows/build.yml): add amacos-14(Apple Silicon) job to the build matrix; split dependency install intoapt(Linux) andbrew(macOS); replacenprocwith portablegetconf _NPROCESSORS_ONLN; ship ahprscript-macos-arm64release asset. The Linux x86-64 asset keeps the namehprscriptso the documentedreleases/latest/download/hprscriptURL stays stable.README.md,HPRSCRIPT.md): document macOS install, Homebrew build deps,otoolverification, and a Gatekeeper quarantine note. Also corrects a stale "Built for Linux x86-64" string left over from the Vectorscan switch.Build matrix
ubuntu-22.04hprscriptubuntu-22.04-armhprscript-linux-arm64macos-14hprscript-macos-arm64Testing
makeclean, onlylibc/libm/ld-linuxdynamic).macos-14job before tagging a release.🤖 Generated with Claude Code