php / php-src

The PHP Interpreter
https://www.php.net
Other
37.78k stars 7.72k forks source link

Unknown addr size on arm64 at MSVC 19.41.34115.96 #14970

Closed brianGriifin114 closed 1 month ago

brianGriifin114 commented 1 month ago

Description

The Microsoft MSVC team uses PHP and other open source projects as part of the compiler testing. We found that PHP will report an error when building on the arm64 architecture.

|                     |                               |
-------------------------------------------------------
| Build type          | Release                       |
| Thread Safety       | Yes                           |
| Compiler            | MSVC 19.41.34115.96, untested |
| Target Architecture | arm64                         |
| Host Architecture   | x64                           |
| Optimization        | PGO disabled                  |
| Native intrinsics   | NEON                          |
| Static analyzer     | disabled                      |
-------------------------------------------------------

Type 'nmake' to build PHP
##[debug] Command #4 exited with code [0].
##[command] Command #5 (Output in "Build.log"):  nmake 2>&1

Microsoft (R) Program Maintenance Utility Version 14.41.34115.96
Copyright (C) Microsoft Corporation.  All rights reserved.

Recreating build dirs
    bison.exe -Wall --output=Zend/zend_ini_parser.c -v -d Zend/zend_ini_parser.y
    bison.exe -Wall --output=Zend/zend_language_parser.c -v -d Zend/zend_language_parser.y
    "re2c.exe"  --no-generation-date --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
    "re2c.exe"  --no-generation-date --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
    bison.exe -Wall --output=sapi/phpdbg/phpdbg_parser.c -v -d sapi/phpdbg/phpdbg_parser.y
    "re2c.exe"  --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l
    type ext\pcre\php_pcre.def > C:\gitP\php\php-src\arm64\Release_TS\php8ts.dll.def
    "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\\x64\mc.exe" -h win32\ -r C:\gitP\php\php-src\arm64\Release_TS\ -x C:\gitP\php\php-src\arm64\Release_TS\ win32\build\wsyslog.mc
MC: Compiling win32\build\wsyslog.mc
    "cl.exe" /D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_OPCACHE /D OPCACHE_EXPORTS=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /I "ext\opcache\jit" /DHAVE_IR_IR_H=1 /I "ext\opcache\jit\ir" /D IR_TARGET_X64 /D IR_PHP /DHAVE_CAPSTONE_CAPSTONE_H=0 /I ext\opcache /nologo /I . /I main /I Zend /I TSRM /I ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /FD /wd4996 /Qspectre /guard:cf /Zc:inline /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP8 /LD /MD /Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "C:\gitP\php\php-src\no\include" /D FD_SETSIZE=256 /FoC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\ /FpC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\ /FRC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\ /FdC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\ /c ext\opcache\ZendAccelerator.c ext\opcache\shared_alloc_win32.c ext\opcache\zend_accelerator_blacklist.c ext\opcache\zend_accelerator_debug.c ext\opcache\zend_accelerator_hash.c ext\opcache\zend_accelerator_module.c ext\opcache\zend_accelerator_util_funcs.c ext\opcache\zend_file_cache.c ext\opcache\zend_persist.c ext\opcache\zend_persist_calc.c ext\opcache\zend_shared_alloc.c
ZendAccelerator.c
shared_alloc_win32.c
zend_accelerator_blacklist.c
zend_accelerator_debug.c
zend_accelerator_hash.c
zend_accelerator_module.c
zend_accelerator_util_funcs.c
zend_file_cache.c
zend_persist.c
zend_persist_calc.c
zend_shared_alloc.c
    "cl.exe" /D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_OPCACHE /D OPCACHE_EXPORTS=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /I "ext\opcache\jit" /DHAVE_IR_IR_H=1 /I "ext\opcache\jit\ir" /D IR_TARGET_X64 /D IR_PHP /DHAVE_CAPSTONE_CAPSTONE_H=0 /I ext\opcache /nologo /I . /I main /I Zend /I TSRM /I ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /FD /wd4996 /Qspectre /guard:cf /Zc:inline /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP8 /LD /MD /Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "C:\gitP\php\php-src\no\include" /D FD_SETSIZE=256 /FoC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FpC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FRC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FdC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /c ext\opcache\jit\zend_jit.c ext\opcache\jit\zend_jit_vm_helpers.c
zend_jit.c
zend_jit_vm_helpers.c
ext\opcache\jit/ir/ir.h(75): fatal error C1189: #error:  "Unknown addr size" (compiling source file ext\opcache\jit\zend_jit.c)
warning C1511: creating 'C:\a\_work\_temp\rwc_project_logs\PHP7\preprocessed_repro_build\zend_jit.rsp' for capture_repro
ext\opcache\jit/ir/ir.h(75): fatal error C1189: #error:  "Unknown addr size" (compiling source file ext\opcache\jit\zend_jit.c)
NMAKE : fatal error U1077: '"cl.exe" /D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_OPCACHE /D OPCACHE_EXPORTS=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /I "ext\opcache\jit" /DHAVE_IR_IR_H=1 /I "ext\opcache\jit\ir" /D IR_TARGET_X64 /D IR_PHP /DHAVE_CAPSTONE_CAPSTONE_H=0 /I ext\opcache /nologo /I . /I main /I Zend /I TSRM /I ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /FD /wd4996 /Qspectre /guard:cf /Zc:inline /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP8 /LD /MD /Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "C:\gitP\php\php-src\no\include" /D FD_SETSIZE=256 /FoC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FpC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FRC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FdC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /c ext\opcache\jit\zend_jit.c ext\opcache\jit\zend_jit_vm_helpers.c' : return code '0x2'
Stop.

We found the error in ext\opcache\jit/ir/ir.h(75), which seems to be because the pointer size of the arm64 platform is not defined at the beginning.

#ifdef _WIN32
/* TODO Handle ARM, too. */
# if defined(_M_X64)
# define __SIZEOF_SIZE_T__ 8
# elif defined(_M_IX86)
# define __SIZEOF_SIZE_T__ 4
# endif

maybe we should change it to this?

#if defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64)
#define __SIZEOF_SIZE_T__ 8

For more information, I attach build.log and setup.log for reference.If you need more information please leave a message. Build (1).log Setup (2).log

PHP Version

8.4.0-dev

Operating System

Windows

cmb69 commented 1 month ago

Generally, I assume that PHP support for ARM on Windows is still experimental and very limited; I don't know if there are any plans regarding shipping dependency builds for that platform. @shivammathur might know more about this.

Regarding your suggested fix, maybe @dstogov can comment on that. In any way, the change likely should be done in https://github.com/dstogov/ir, and backported later.

brianGriifin114 commented 1 month ago

noted,thanks for the reply.

brianGriifin114 commented 1 month ago

In addition, I also got the same error message when building under arm64ec.

"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\\x64\mc.exe" -h win32\ -r C:\gitP\php\php-src\arm64\Release_TS\ -x C:\gitP\php\php-src\arm64\Release_TS\ win32\build\wsyslog.mc
MC: Compiling win32\build\wsyslog.mc
    "cl.exe" /D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_OPCACHE /D OPCACHE_EXPORTS=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /I "ext\opcache\jit" /DHAVE_IR_IR_H=1 /I "ext\opcache\jit\ir" /D IR_TARGET_X64 /D IR_PHP /DHAVE_CAPSTONE_CAPSTONE_H=0 /I ext\opcache /nologo /I . /I main /I Zend /I TSRM /I ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /FD /wd4996 /Qspectre /guard:cf /Zc:inline /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP8 /LD /MD /Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "C:\gitP\php\php-src\no\include" /D FD_SETSIZE=256 /FoC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\ /FpC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\ /FRC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\ /FdC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\ /c ext\opcache\ZendAccelerator.c ext\opcache\shared_alloc_win32.c ext\opcache\zend_accelerator_blacklist.c ext\opcache\zend_accelerator_debug.c ext\opcache\zend_accelerator_hash.c ext\opcache\zend_accelerator_module.c ext...
ZendAccelerator.c
shared_alloc_win32.c
zend_accelerator_blacklist.c
zend_accelerator_debug.c
zend_accelerator_hash.c
zend_accelerator_module.c
zend_accelerator_util_funcs.c
zend_file_cache.c
zend_persist.c
zend_persist_calc.c
zend_shared_alloc.c
    "cl.exe" /D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_OPCACHE /D OPCACHE_EXPORTS=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /I "ext\opcache\jit" /DHAVE_IR_IR_H=1 /I "ext\opcache\jit\ir" /D IR_TARGET_X64 /D IR_PHP /DHAVE_CAPSTONE_CAPSTONE_H=0 /I ext\opcache /nologo /I . /I main /I Zend /I TSRM /I ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /FD /wd4996 /Qspectre /guard:cf /Zc:inline /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP8 /LD /MD /Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "C:\gitP\php\php-src\no\include" /D FD_SETSIZE=256 /FoC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FpC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FRC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FdC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /c ext\opcache\jit\zend_jit.c ext\opcache\jit\zend_jit_vm_helpers.c
zend_jit.c
zend_jit_vm_helpers.c
ext\opcache\jit/ir/ir.h(75): fatal error C1189: #error:  "Unknown addr size" (compiling source file ext\opcache\jit\zend_jit.c)
warning C1511: creating 'C:\a\_work\_temp\rwc_project_logs\PHP7\preprocessed_repro_build\zend_jit.rsp' for capture_repro
ext\opcache\jit/ir/ir.h(75): fatal error C1189: #error:  "Unknown addr size" (compiling source file ext\opcache\jit\zend_jit.c)
NMAKE : fatal error U1077: '"cl.exe" /D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_OPCACHE /D OPCACHE_EXPORTS=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /I "ext\opcache\jit" /DHAVE_IR_IR_H=1 /I "ext\opcache\jit\ir" /D IR_TARGET_X64 /D IR_PHP /DHAVE_CAPSTONE_CAPSTONE_H=0 /I ext\opcache /nologo /I . /I main /I Zend /I TSRM /I ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /FD /wd4996 /Qspectre /guard:cf /Zc:inline /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP8 /LD /MD /Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "C:\gitP\php\php-src\no\include" /D FD_SETSIZE=256 /FoC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FpC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FRC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /FdC:\gitP\php\php-src\arm64\Release_TS\ext\opcache\jit\ /c ext\opcache\jit\zend_jit.c ext\opcache\jit\zend_jit_vm_helpers.c' : return code '0x2'
Stop.

Does this mean that support under arm64ec is also limited?

cmb69 commented 1 month ago

Does this mean that support under arm64ec is also limited?

Most likely, yes. Maybe @dixyes or @vladimir-aubrecht have more information on the state of PHP for ARM on Windows.

dixyes commented 1 month ago

I have not tried with arm64ec (only tried on native arm64, when I was working on this port, arm64ec is not released).

for arm64, my lwmbs build for PHP 8.3 is still working now, I guess there are some breaking changes in the master branch?

dstogov commented 1 month ago

At this time PHP-JIT doesn't support ARM on Windows. Try to configure and build PHP without JIT. Use --disable-opcache-jit.

dstogov commented 1 month ago

I fixed ir.h to check for _M_ARM64, but this is not enough to make JIT work and I'm not able to check Windows/ARM build anyway.

brianGriifin114 commented 1 month ago

Thank you very much, I will try to build it according to the options you mentioned.

brianGriifin114 commented 1 month ago

it works,cheers!