Skip to content

Add MacOS Support in CI/CD - #11

Merged
supanadit merged 17 commits into
mainfrom
development
Jul 22, 2026
Merged

supanadit merged 17 commits into
mainfrom
development

Conversation

@supanadit

Copy link
Copy Markdown
Owner

I start supporting MacOS, since it also based on Unix and more likely to works out of the box.

supanadit added 17 commits July 21, 2026 23:12
When a dependency (like openssl) is satisfied by a system package
instead of being built from source, the placeholder resolution was
still generating paths to non-existent local directories.

For example, curl's configure flag with openssl placeholder was being
replaced with a path like ~/.phpv/packages/openssl/1.1.1w even
when the system OpenSSL 3.x was being used.

Now resolveDepPlaceholders checks if the dependency was actually
built locally before replacing the placeholder. If not, the flag
is skipped entirely, letting configure find the system version
via pkg-config or default search paths.

This fixes the "bad openssl prefix" error in CI where
system packages satisfy dependency constraints.
The awalsh128/cache-apt-pkgs-action@v1 action was failing with:
- manifest_all.log: No such file or directory
- substring expression < 0 error

Replace with direct apt-get install commands which are more reliable
and don't require caching since we removed caching from the workflow.
PHP's configure script couldn't find libpng and other libraries
via pkg-config. Set PKG_CONFIG_PATH environment variable to
include standard Ubuntu library paths so configure can find
system libraries.
Cache the PHPV_ROOT directory so compiled PHP binaries and
dependencies persist across CI runs. Only rebuild when source
files change. This saves ~30-60 minutes per PHP version.
Cache only the /caches directory (downloaded tarballs)
instead of the entire PHPV_ROOT. This avoids re-downloading source
archives on every run while still rebuilding PHP from scratch each
time to ensure ABI compatibility.
OpenSSL's Configure script requires an explicit target platform.
Previously hardcoded to linux-x86_64, which fails on macOS.
Now detects the platform at runtime:
  - darwin/arm64 -> darwin64-arm64-cc
  - darwin/amd64 -> darwin64-x86_64-cc
  - linux/amd64  -> linux-x86_64
OpenSSL 1.1.1w ships both 'config' (shell auto-detection) and
'Configure' (perl with explicit target). The 'config' script
fails to auto-detect on macOS. Prefer 'Configure' with the
runtime-detected target (darwin64-arm64-cc / darwin64-x86_64-cc)
so it works on both Linux and macOS.
…ve FS

macOS has a case-insensitive filesystem, so os.Stat('configure')
matches OpenSSL's 'Configure' script. This caused the generic
configure path to run OpenSSL's Configure without a target platform.

Move the OpenSSL check before the generic configure check so the
perl-based Configure with explicit target (darwin64-arm64-cc) is
used correctly.
The global CPPFLAGS pointed to Homebrew's ICU 78 headers, which
require C++17. When building ICU 74.2 from source, these headers
were picked up instead of the local source headers, causing
C++17 extension errors with the -std=c++11 flag.

PKG_CONFIG_PATH alone is sufficient for system package detection.
The forge handles include/lib paths internally when building from
source.
macOS uses clang by default, but the build plan hardcoded 'gcc' as
the compiler. GCC-specific flags like -fpermissive caused clang to
fail with 'C compiler cannot create executables'.

Changes:
- Add detectCompiler() in graph/service.go (clang on darwin, gcc otherwise)
- Add clang compiler flag rules in compiler.go (no -fpermissive)
- Use DYLD_LIBRARY_PATH instead of LD_LIBRARY_PATH on macOS
- Update resolveDepPlaceholders tests for new skip behavior
collectSystemFlags was adding -I/usr/include, -L/usr/lib64, and
-Wl,-rpath,/usr/lib64 which don't exist on macOS. This caused the
macOS linker to fail with 'C compiler cannot create executables'
when system packages were used. Skip these on darwin.
BuildPlan mixed -std=gnu11 (C) and -std=gnu++17 (C++) into a single
CompilerFlags list. The assembler put both into CFLAGS, causing clang
to fail with 'C compiler cannot create executables' because
-std=gnu++17 is not valid for C compilation.

Split CompilerFlags into C-only (CompilerFlags) and C++-only
(CXXCompilerFlags). CFLAGS gets only C flags; CXXFLAGS gets C++ flags.
On macOS, iconv is part of libSystem but PHP 7.4's configure looks
for a standalone libiconv which isn't found. Install libiconv via
Homebrew and resolve --with-iconv to /opt/homebrew/opt/libiconv on
darwin.
Two linking errors on macOS:

1. iconv: libxml2 (built from source) references iconv symbols but
   the macOS linker can't find libiconv. Pass Homebrew libiconv
   paths (CPPFLAGS/LDFLAGS) to dependency builds and add -liconv
   to PHP's LDFLAGS.

2. res_9_*: PHP 7.4's DNS extension references resolver functions
   that live in libresolv on macOS. Add -lresolv to PHP's LDFLAGS.
macOS's dynamic linker (dyld) reads DYLD_LIBRARY_PATH, not
LD_LIBRARY_PATH. The shim script hardcoded LD_LIBRARY_PATH which
meant the PHP binary couldn't find locally-built ICU libraries
at runtime (libicuio.74.dylib, libicuio.63.dylib).

Use a runtime uname check to select the correct library path
variable name.
@supanadit
supanadit merged commit 1bcedff into main Jul 22, 2026
13 checks passed
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