Skip to content

fix: build the clib on macOS without nproc - #239

Merged
s2x merged 7 commits into
crazy-goat:mainfrom
stantheman0128:fix/mac-make-jobs-without-nproc
Oct 3, 2026
Merged

s2x merged 7 commits into
crazy-goat:mainfrom
stantheman0128:fix/mac-make-jobs-without-nproc

Conversation

@stantheman0128

Copy link
Copy Markdown
Contributor

Summary

Fixes the nproc half of #95.

Builder::build() ran make -j$(nproc). This Mac has no nproc, so the command substitution exits 127. The job count is now sysctl -n hw.ncpu, then getconf _NPROCESSORS_ONLN, then 1. The g++ / clang++ null-coalescing check in the same issue was not changed. php is not installed here, so that branch was not executed.

prepared with Cursor

Verification

Red, this Mac:

nproc
exit 127
nproc: command not found

Green:

bash tests/make-jobs-darwin.test.sh
make jobs darwin ok (nproc exit 127, jobs <n>)

sysctl -n hw.ncpu returned a positive integer. php tests were not run. The Docker nproc in docker/Dockerfile was left alone. That image is Linux.

Made with Cursor

stantheman0128 and others added 2 commits September 23, 2026 02:42
macOS does not ship nproc, so the clib build command failed before
make started. sysctl and getconf are already on this system.

Co-authored-by: Cursor <cursoragent@cursor.com>
The Darwin job-count check was failing on its own explanation.

Co-authored-by: Cursor <cursoragent@cursor.com>
@s2x

s2x commented Oct 2, 2026

Copy link
Copy Markdown
Member

Thanks for the fix and the test, and sorry for the long wait.

main now has a new CI workflow (#243): outside pull requests are no longer skipped, and the required check is ci-ok. The branch must be up to date with main before merging. Could you rebase on (or merge) the current main? CI will then run the full test matrix and lint (bin/lint.sh). A short entry under [Unreleased] in CHANGELOG.md would be welcome too.

@stantheman0128

Copy link
Copy Markdown
Contributor Author

Merged current main and added an Unreleased changelog note for the macOS make job count. The local job-count test still passes. CI should be able to run ci-ok on this head.

@stantheman0128

Copy link
Copy Markdown
Contributor Author

shellcheck SC2016 was the remaining lint failure. The search stays in single quotes so it matches the literal $(nproc) in Builder.php, with a disable on that line. bash tests/make-jobs-darwin.test.sh still passes locally (nproc exit 127).

@stantheman0128

Copy link
Copy Markdown
Contributor Author

Merged current main again (5cb9e59). The Unreleased fixed section keeps the macOS make line together with the newer download and FFI notes. bash tests/make-jobs-darwin.test.sh still passes locally (nproc exit 127).

@s2x
s2x merged commit f1d01fd into crazy-goat:main Oct 3, 2026
7 checks passed
@s2x

s2x commented Oct 3, 2026

Copy link
Copy Markdown
Member

Thank you @stantheman0128 for the contribution and for keeping this PR up to date! All CI checks are now passing, and the fix has been merged. Thanks for improving the macOS build experience and adding the regression test.

s2x added a commit that referenced this pull request Oct 3, 2026
## Summary

Fixes #188.

`Builder::isBuildAvailable()` probed PATH with Unix-only `which`, so on
Windows it always returned false even when cmake and a C++ compiler were
installed. It now uses `where` when `PHP_OS_FAMILY === 'Windows'`, and
keeps `which` elsewhere. Independent of #239 (macOS `nproc`).

prepared with Cursor

## Verification

Evidence type: PATH fixture on macOS (not a live Win11 run). This Mac
has no Windows and no `php` binary.

Red class (cmake on PATH, `which` absent):

```
env -i PATH=<fixture-bin> /bin/bash --noprofile --norc -c 'which cmake 2>/dev/null'
exit 127
```

Green:

```
bash tests/windows-which-lookup.test.sh
windows which-lookup fixture ok (which missing exit 127, where found cmake)
```

Source checks in that script: Windows `PHP_OS_FAMILY` branch, `where`,
`2>NUL`, and no unconditional `shell_exec('which ...')`. PHPUnit was not
run (`php` not installed here).


Made with [Cursor](https://cursor.com)

---------

Co-authored-by: stantheman0128 <stantheman0128@users.noreply.github.com>
Co-authored-by: Piotr Hałas <halaspiotr@gmail.com>
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.

2 participants