name: Unix ARM64 build description: Build and smoke-test TypePHP on a Unix ARM64 runner inputs: php-version: description: PHP minor version required: true os: description: Package operating-system identifier required: true library-extension: description: Shared-library extension used by PHPX required: true smoke-directory: description: Platform smoke project directory below .github/smoke required: true smoke-binary: description: Platform smoke executable name required: true smoke-output: description: Expected platform smoke output required: true runs: using: composite steps: - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ inputs.php-version }} coverage: none extensions: mbstring ini-values: precision=17, memory_limit=4G, error_reporting=E_ERROR|E_WARNING, display_errors=1, display_startup_errors=1, log_errors=0 tools: composer:v2 env: fail-fast: true phpts: ts update: true - name: Show PHP environment shell: bash run: | php -v php-config --version php --ini php -r 'printf("PHP_ZTS=%d\nopcache.enable=%s\nopcache.enable_cli=%s\nopcache.jit=%s\nopcache.jit_buffer_size=%s\npcre.jit=%s\n", PHP_ZTS, ini_get("opcache.enable"), ini_get("opcache.enable_cli"), ini_get("opcache.jit"), ini_get("opcache.jit_buffer_size"), ini_get("pcre.jit"));' - name: Install Linux build dependencies if: inputs.os == 'linux' shell: bash run: | sudo apt-get update sudo apt-get install --yes build-essential cmake libgmp-dev libmpfr-dev pkg-config - name: Install macOS build dependencies if: inputs.os == 'macos' shell: bash run: brew install cmake gmp mpfr pkg-config - name: Verify ZTS PHP and architecture shell: bash run: | php -r 'if (!PHP_ZTS) { fwrite(STDERR, "Expected a ZTS PHP build\n"); exit(1); }' case "$(php -r 'echo PHP_VERSION;')" in "${{ inputs.php-version }}"*) ;; *) echo "setup-php installed an unexpected PHP version" >&2; exit 1 ;; esac case "$(uname -m)" in arm64|aarch64) ;; *) echo "Expected an ARM64 runner, got $(uname -m)" >&2; exit 1 ;; esac php_home="$(php-config --prefix)" embed_library="${php_home}/lib/libphp.${{ inputs.library-extension }}" test -x "${php_home}/bin/php-config" test -f "${embed_library}" echo "PHP_HOME=${php_home}" >> "${GITHUB_ENV}" if [[ '${{ inputs.os }}' == 'linux' ]]; then echo "LD_LIBRARY_PATH=${PHPX_HOME}/lib:${php_home}/lib" >> "${GITHUB_ENV}" else echo "DYLD_LIBRARY_PATH=${PHPX_HOME}/lib:${php_home}/lib" >> "${GITHUB_ENV}" fi php-config --configure-options - name: Patch php_hash.h C++ compatibility uses: ./.github/actions/patch-php-headers - name: Install Composer dependencies shell: bash run: composer install --prefer-dist --no-progress - name: Build PHPX shell: bash run: | cmake -S "${PHPX_HOME}" -B "${PHPX_HOME}/build" \ -D CMAKE_BUILD_TYPE=Release \ -D BUILD_TESTS=OFF \ -D BUILD_EXT=OFF \ -D GITHUB_ACTION=ON \ -D php_dir="${PHP_HOME}" cmake --build "${PHPX_HOME}/build" --target phpx --parallel 2 test -f "${PHPX_HOME}/lib/libphpx.${{ inputs.library-extension }}" - name: Build tpc shell: bash run: | php bin/tpc.php project.yml --job 2 --no-progress test -x ./tpc file ./tpc file ./tpc | grep -Eiq 'arm64|aarch64|ARM aarch64' ./tpc --version - name: Diagnose tpc crash if: failure() && inputs.os == 'linux' shell: bash run: | if [[ ! -x ./tpc ]]; then exit 0 fi debug_dir=".github/ci-debug/${{ inputs.os }}-arm64-php-${{ inputs.php-version }}" mkdir -p "${debug_dir}" if ! command -v gdb >/dev/null 2>&1; then sudo apt-get update sudo apt-get install --yes gdb fi { uname -a g++ --version php -v php-config --configure-options php -m file ./tpc ldd ./tpc sha256sum ./tpc "${PHPX_HOME}/lib/libphpx.so" "${PHP_HOME}/lib/libphp.so" readelf -n ./tpc readelf -d ./tpc } > "${debug_dir}/environment.txt" 2>&1 gdb -q -batch \ -ex 'set pagination off' \ -ex 'set print thread-events off' \ -ex run \ -ex 'info registers' \ -ex 'info proc mappings' \ -ex 'info sharedlibrary' \ -ex 'x/32i $pc-32' \ -ex 'thread apply all bt full' \ --args ./tpc --version \ > "${debug_dir}/gdb.txt" 2>&1 || true cp -L "${PHPX_HOME}/lib/libphpx.so" "${debug_dir}/libphpx.so" cp -L "${PHP_HOME}/lib/libphp.so" "${debug_dir}/libphp.so" - name: Run platform smoke test shell: bash run: | smoke_root=".github/smoke/${{ inputs.smoke-directory }}" ./tpc "${smoke_root}/project.yml" --job 1 --no-progress smoke_binary="${smoke_root}/${{ inputs.smoke-binary }}" test -x "${smoke_binary}" output="$("${smoke_binary}")" test "${output}" = '${{ inputs.smoke-output }}' - name: Show native dependencies shell: bash run: | if [[ '${{ inputs.os }}' == 'linux' ]]; then ldd ./tpc else otool -L ./tpc fi - name: Package tested compiler if: startsWith(github.ref, 'refs/tags/') && inputs.php-version == '8.5' shell: bash run: | composer install --no-dev --prefer-dist --no-progress --classmap-authoritative export TYPEPHP_PACKAGE_VERSION="${GITHUB_REF_NAME}" php package.php test "$(find . -maxdepth 1 -name 'tpc_v*_${{ inputs.os }}_arm64.tar.gz' -type f | wc -l)" -eq 1 - name: Upload release package if: startsWith(github.ref, 'refs/tags/') && inputs.php-version == '8.5' uses: actions/upload-artifact@v4 with: name: release-${{ inputs.os }}-arm64-php-${{ inputs.php-version }}-zts if-no-files-found: error retention-days: 1 path: tpc_v*_${{ inputs.os }}_arm64.tar.gz - name: Upload platform build outputs if: always() uses: actions/upload-artifact@v4 with: name: tpc-${{ inputs.os }}-arm64-php-${{ inputs.php-version }}-zts include-hidden-files: true if-no-files-found: warn retention-days: 7 path: | tpc tpc.rsp build/**/*.cc build/**/*.h build/**/*.rsp .github/ci-debug/** .github/smoke/${{ inputs.smoke-directory }}/${{ inputs.smoke-binary }} .github/smoke/${{ inputs.smoke-directory }}/build/**/*.cc .github/smoke/${{ inputs.smoke-directory }}/build/**/*.h