diff --git a/bin/phpsdk_buildtree.bat b/bin/phpsdk_buildtree.bat index d639059..3375286 100644 --- a/bin/phpsdk_buildtree.bat +++ b/bin/phpsdk_buildtree.bat @@ -27,6 +27,9 @@ if "%PHP_SDK_ARCH%" NEQ "" ( MD %_%\%%i\x64\deps\bin MD %_%\%%i\x64\deps\lib MD %_%\%%i\x64\deps\include + MD %_%\%%i\arm64\deps\bin + MD %_%\%%i\arm64\deps\lib + MD %_%\%%i\arm64\deps\include ) ) diff --git a/bin/phpsdk_deps.php b/bin/phpsdk_deps.php index e161ff3..31869c9 100644 --- a/bin/phpsdk_deps.php +++ b/bin/phpsdk_deps.php @@ -180,7 +180,7 @@ function usage(int $code = -1) echo "Usage: ", PHP_EOL, PHP_EOL; echo "Configuration:", PHP_EOL; echo " -b --branch Branch name, eg. 7.0, 7.1, etc. If omited, several guess methods apply.", PHP_EOL; - echo " -a --arch Architecture, x86 or x64. If omited, cl.exe is used to guess.", PHP_EOL; + echo " -a --arch Architecture, x86 or x64 or arm64. If omited, cl.exe is used to guess.", PHP_EOL; echo " -t --crt CRT, marked by the corresponding VC++ version, eg. vc11, vc14, etc.", PHP_EOL; echo " -s --stability One of stable or staging.", PHP_EOL, PHP_EOL; echo "Commands:", PHP_EOL; diff --git a/bin/phpsdk_dumpenv.bat b/bin/phpsdk_dumpenv.bat index b2c0e49..7d44df5 100644 --- a/bin/phpsdk_dumpenv.bat +++ b/bin/phpsdk_dumpenv.bat @@ -12,18 +12,8 @@ echo. call %PHP_SDK_BIN_PATH%\phpsdk_version.bat echo. -if "%PHP_SDK_OS_ARCH%"=="x64" ( - echo OS architecture: 64-bit -) else ( - echo OS architecture: 32-bit -) - -if "%PHP_SDK_ARCH%"=="x64" ( - echo Build architecture: 64-bit -) else ( - echo Build architecture: 32-bit -) - +echo OS architecture: %PHP_SDK_OS_ARCH% +echo Build architecture: %PHP_SDK_ARCH% echo Visual C++: %PHP_SDK_VC_TOOLSET_VER% echo PHP-SDK path: %PHP_SDK_ROOT_PATH% diff --git a/bin/phpsdk_setshell.bat b/bin/phpsdk_setshell.bat index aeb5b58..5212d02 100644 --- a/bin/phpsdk_setshell.bat +++ b/bin/phpsdk_setshell.bat @@ -46,30 +46,42 @@ set TMP_CHK= if /i not "%2"=="x64" ( if /i not "%2"=="x86" ( - echo Unsupported arch "%2" - goto out_error + if /i not "%2"=="arm64" ( + echo Unsupported arch "%2" + goto out_error + ) ) ) set PHP_SDK_ARCH=%2 rem check OS arch -set TMPKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion -reg query "%TMPKEY%" /v "ProgramFilesDir (x86)" >nul 2>nul +rem Architecture=9 meaning x86_64 +wmic cpu get Architecture /value | findstr "Architecture=9\>" >nul 2>nul if not errorlevel 1 ( set PHP_SDK_OS_ARCH=x64 -) else ( - if /i "%PHP_SDK_ARCH%"=="x64" ( - echo 32-bit OS detected, native 64-bit toolchain is unavailable. - goto out_error - ) +) +rem Architecture=12 meaning arm64 +wmic cpu get Architecture /value | findstr "Architecture=12\>" >nul 2>nul +if not errorlevel 1 ( + set PHP_SDK_OS_ARCH=arm64 +) +rem Architecture=0 meaning x86 +wmic cpu get Architecture /value | findstr "Architecture=0\>" >nul 2>nul +if not errorlevel 1 ( set PHP_SDK_OS_ARCH=x86 ) -set TMPKEY= + +rem cross compile is ok, so we donot need this +rem if not /i "%PHP_SDK_ARCH%"=="PHP_SDK_OS_ARCH" ( +rem echo 32-bit OS detected, native 64-bit toolchain is unavailable. +rem goto out_error +rem ) rem get vc base dir if 15 gtr %PHP_SDK_VS_NUM% ( - if /i "%PHP_SDK_OS_ARCH%"=="x64" ( + rem for arch other than x86, use WOW6432 + if /i not "%PHP_SDK_OS_ARCH%"=="x86" ( set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC ) else ( set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC @@ -85,16 +97,20 @@ if 15 gtr %PHP_SDK_VS_NUM% ( set /a PHP_SDK_VS_RANGE=PHP_SDK_VS_NUM + 1 set PHP_SDK_VS_RANGE="[%PHP_SDK_VS_NUM%,!PHP_SDK_VS_RANGE%!)" - for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do ( + set APPEND=x86.x64 + if /i "%PHP_SDK_OS_ARCH%"=="arm64" ( + set APPEND=ARM64 + ) + for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do ( set PHP_SDK_VC_DIR=%%b\VC ) if not exist "!PHP_SDK_VC_DIR!" ( - for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do ( + for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do ( set PHP_SDK_VC_DIR=%%b\VC ) if not exist "!PHP_SDK_VC_DIR!" ( rem check for a preview release - for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do ( + for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -property installationPath -format text') do ( set PHP_SDK_VC_DIR=%%b\VC ) if not exist "!PHP_SDK_VC_DIR!" ( @@ -105,13 +121,15 @@ if 15 gtr %PHP_SDK_VS_NUM% ( ) set VSCMD_ARG_no_logo=nologo ) +set APPEND= set TMPKEY= set PHP_SDK_VS_RANGE= if 15 gtr %PHP_SDK_VS_NUM% ( rem get sdk dir rem if 10.0 is available, it's ok - if /i "%PHP_SDK_OS_ARCH%"=="x64" ( + rem for arch other than x86, use WOW6432 + if /i not "%PHP_SDK_OS_ARCH%"=="x86" ( set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 ) else ( set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0 @@ -125,7 +143,8 @@ if 15 gtr %PHP_SDK_VS_NUM% ( ) rem Otherwise 8.1 should be available anyway - if /i "%PHP_SDK_OS_ARCH%"=="x64" ( + rem for arch other than x86, use WOW6432 + if /i not "%PHP_SDK_OS_ARCH%"=="x86" ( set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1 ) else ( set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1 @@ -143,17 +162,26 @@ if 15 gtr %PHP_SDK_VS_NUM% ( ) if /i "%PHP_SDK_ARCH%"=="x64" ( - if 15 gtr %PHP_SDK_VS_NUM% ( - set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64 - ) else ( - set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64 - ) + set TARGET_ARCH_NAME=amd64 ) else ( - if 15 gtr %PHP_SDK_VS_NUM% ( - set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86 - ) else ( - set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86 - ) + set TARGET_ARCH_NAME=%PHP_SDK_ARCH% +) + +if /i "%PHP_SDK_OS_ARCH%"=="x64" ( + set HOST_ARCH_NAME=amd64 +) else ( + set HOST_ARCH_NAME=%PHP_SDK_ARCH% +) + +if "%HOST_ARCH_NAME%"=="%TARGET_ARCH_NAME%" ( + set VCVARSALL_ARCH_NAME=%HOST_ARCH_NAME% +) else ( + set VCVARSALL_ARCH_NAME=%HOST_ARCH_NAME%_%TARGET_ARCH_NAME% +) +if 15 gtr %PHP_SDK_VS_NUM% ( + set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME! +) else ( + set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME! ) rem echo Visual Studio VC path %PHP_SDK_VC_DIR% diff --git a/lib/php/libsdk/SDK/Config.php b/lib/php/libsdk/SDK/Config.php index c116ac9..e6b6d08 100644 --- a/lib/php/libsdk/SDK/Config.php +++ b/lib/php/libsdk/SDK/Config.php @@ -47,8 +47,8 @@ public static function setCurrentArchName(string $arch) : void {/*{{{*/ $arch = strtolower($arch); - if ("x64" != $arch && "x86" != $arch) { - throw new Exception("Unknown arch keyword, either x86 or x64 is accepted"); + if ("x64" != $arch && "x86" != $arch && "arm64" != $arch) { + throw new Exception("Unknown arch keyword, x86 or x64 or arm64 is accepted"); } self::$currentArchName = $arch; @@ -72,6 +72,8 @@ public static function getCurrentArchName() : string self::setCurrentArchName("x64"); } elseif (preg_match(",x86,", $out[0])) { self::setCurrentArchName("x86"); + } elseif (preg_match(",arm64,", $out[0])) { + self::setCurrentArchName("arm64"); } else { throw new Exception("Couldn't determine Arch."); } @@ -146,7 +148,7 @@ public static function getKnownBranches() : array $tmp = $fetcher->getByUri(self::$depsBaseUri . "/series/"); if (false !== $tmp) { $data = array(); - if (preg_match_all(",/packages-(.+)-(v[cs]\d+)-(x86|x64)-(stable|staging)\.txt,U", $tmp, $m, PREG_SET_ORDER)) { + if (preg_match_all(",/packages-(.+)-(v[cs]\d+)-(x86|x64|arm64)-(stable|staging)\.txt,U", $tmp, $m, PREG_SET_ORDER)) { foreach ($m as $b) { if (!isset($data[$b[1]])) { $data[$b[1]] = array(); diff --git a/pgo/tpl/php/phpsdk_pgo.json b/pgo/tpl/php/phpsdk_pgo.json index 5d21d23..b7362eb 100644 --- a/pgo/tpl/php/phpsdk_pgo.json +++ b/pgo/tpl/php/phpsdk_pgo.json @@ -14,6 +14,12 @@ { "cache": { "ini": { + "arm64": { + "opcache.memory_consumption": 256, + "opcache.interned_strings_buffer": 16, + "opcache.max_accelerated_files": 8000, + "opcache.jit_buffer_size": "32M" + }, "x64": { "opcache.memory_consumption": 256, "opcache.interned_strings_buffer": 16,