Repository navigation
Add MacOS Support in CI/CD - #11
Merged
Merged
Conversation
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.
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.
I start supporting MacOS, since it also based on Unix and more likely to works out of the box.