Skip to content

Support build codepage.c for Windows arm64 #7702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

dixyes
Copy link
Contributor

@dixyes dixyes commented Dec 1, 2021

This is a series of work on building php for windows arm64 (cross compile only yet)

  • codepage.c used some x86 simd instructions, this patch translates them for arm64 using neon
  • InterlockedExchange8 change seems to be a workaround for msvc cl.exe bug, InterlockedExchange8 should be a compiler intrinsic, however at my environment, it try to link to external symbol.

@cmb69
Copy link
Member

cmb69 commented Dec 1, 2021

Thank you for the PRs! I'd prefer to set up a CI (maybe scheduled only) for those builds (AFAIK, cross-compiling for arm64 is supported by AppVeyor), but that would need to wait on your PR for the PHP-SDK (or whatever happens with that repo). And some way to actually run the test suite on arm64 would be good, too. We'd probably need a self-hosted runner for this, though.

@dixyes
Copy link
Contributor Author

dixyes commented Dec 2, 2021

Yes, we need a self-hosted runner/other ci to test this.

For ci things:.

  • I've tried run windows arm64 at huawei cloud and aliyun arm64 vps. Huawei cloud vps provides kunpeng 920 cpus, using openstack vm, they can reboot into efi shell to try windows installation, but it stuck before entering setup (maybe efifb issue i guess), aliyun vps provides ampere altra cpu, it have less support - i cannot touch tianocore/efishell even. It's may be hard to find a vps can run an arm64 runner for now.
  • Windows arm64 is offically supported by microsoft on a few devices, i have none of them, because they are (mostly) expensive and have poor performance, comparing to them, even a m1 mac is more valuable. It's may be hard to find a good device to run arm64 runner also.

For building and testing:

Microsoft seems have not released native arm64 toolchain to make arm64 binaries yet, so you can only cross-compile from a x86 pc, this can be done on any x86 windows with arm64 visual studio components installed. but test it requires a real hardware/vm/other emulation.
I've tested Zend/tests, most tests can pass, some fiber related things is broken, maybe my boost context port is somewhat wrong. Boost's jam is not supported on windows arm64 now. so I cannot make boost context tests and pr to boost upstream.

@cmb69
Copy link
Member

cmb69 commented Dec 2, 2021

Thanks for further information! So I suggest to wait some days on the outcome of https://externals.io/message/116546, and if that gets done, to add arm64 support to the PHP-SDK first. Then we can try to set up CI (build only, no tests), and go from there.

@twose
Copy link
Member

twose commented Jul 5, 2022

Ping @cmb69 🥺, I am always waiting for Windows arm64 support, it's been a long time...
#7702 #7703 #7704

@cmb69
Copy link
Member

cmb69 commented Jul 5, 2022

@twosee, ARM64 support for Windows would certainly be good to have, but is there any chance to actually test this?

@dixyes
Copy link
Contributor Author

dixyes commented Jul 5, 2022

@twosee, ARM64 support for Windows would certainly be good to have, but is there any chance to actually test this?

Many developers have a M1 mac, and using parallel desktop or other vmms for windows, compiling and running x64 PHP on windows arm64 is rather slow (that's why the pr here), this is a good place to test them.

As for continuous test, a macmini M1 with github actions/azure pipeline runner can do this (but at lease in actions, the runner have poor permission control, you can run any code at runners with PR). I would prefer to a buildbot or jenkins thing.

@cmb69
Copy link
Member

cmb69 commented Jul 5, 2022

Note that there is currently no sponsoring for PHP 8 on Windows. Unless that changes, there is no way for us to have a self hosted test runner. And I don't have any access to an ARM64 machine.

That said, I'm not against adding experimental Windows ARM64 support to php-src, and not even against shipping ARM64 binaries, but we need at the very least a full-fledged PR for a minimal PHP build; if I remember correctly, just using the four current PRs is not sufficient; that likely would need your whole branch (dixyes:win32_arm64_patch1). It might be best if you can submit a single PR for all that.

Also note that while it may be possible to do a minimal build, having the required library dependencies for a full build would require work on winlibs.

@dixyes
Copy link
Contributor Author

dixyes commented Jul 5, 2022

I thought a single PR may be too huge to review so splited it into multiple parts...

My developing branch is win_arm64, but these days I've just ported boost context fully and that full branch needs refactor (sjlj parts may not needed any more), it will not be usable these days, I can only create another PR when that branch is ready.

As for winlibs, I did not know where it is before and thus made my own: https://github.com/dixyes/lwmbs/tree/master/windows/libraries, you can grab a binary from here

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

The changes to win32/codepage.c look good to me, but win32/signal.c has a merge conflict. Can you please resolve that? It may require a change to Zend/zend_atomic.h.

@dixyes dixyes force-pushed the win32_arm64_patch1 branch from 12a0684 to c6d8587 Compare July 20, 2022 15:27
@dixyes dixyes changed the title Support build codepage.c and signal.c for Windows arm64 Support build codepage.c for Windows arm64 Jul 20, 2022
@dixyes
Copy link
Contributor Author

dixyes commented Jul 20, 2022

@cmb69

I've reverted signal.c modification. I think InterlockedExchange8 should be fixed in zend patches since it's in zend_atomic.h now.
Also, I wonder which is better: splited into zend + buildsystem or all in one pr.

nmake test using dixyes/php-src@19165ed :

=====================================================================
TIME END 2022-07-20 15:11:05

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :   66
Exts tested     :   10
---------------------------------------------------------------------

Number of tests : 17481              6539
Tests skipped   : 10942 ( 62.6%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   11 (  0.1%) (  0.2%)
Expected fail   :   18 (  0.1%) (  0.3%)
Tests passed    : 6510 ( 37.2%) ( 99.6%)
---------------------------------------------------------------------
Time taken      :  403 seconds
=====================================================================

=====================================================================
EXPECTED FAILED TEST SUMMARY
---------------------------------------------------------------------
DateTime::add() -- fall type2 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_add-fall-type2-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::add() -- fall type3 type2 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_add-fall-type3-type2.phpt]  XFAIL REASON: Various bugs exist
DateTime::add() -- fall type3 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_add-fall-type3-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::add() -- spring type2 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_add-spring-type2-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::add() -- spring type3 type2 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_add-spring-type3-type2.phpt]  XFAIL REASON: Various bugs exist
DateTime::add() -- spring type3 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_add-spring-type3-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::diff() -- fall type2 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_diff-fall-type2-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::diff() -- fall type3 type2 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_diff-fall-type3-type2.phpt]  XFAIL REASON: Various bugs exist
DateTime::diff() -- fall type3 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_diff-fall-type3-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::diff() -- spring type2 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_diff-spring-type2-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::diff() -- spring type3 type2 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_diff-spring-type3-type2.phpt]  XFAIL REASON: Various bugs exist
DateTime::diff() -- spring type3 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_diff-spring-type3-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::sub() -- fall type2 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_sub-fall-type2-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::sub() -- fall type3 type2 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_sub-fall-type3-type2.phpt]  XFAIL REASON: Various bugs exist
DateTime::sub() -- fall type3 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_sub-fall-type3-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::sub() -- spring type2 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_sub-spring-type2-type3.phpt]  XFAIL REASON: Various bugs exist
DateTime::sub() -- spring type3 type2 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_sub-spring-type3-type2.phpt]  XFAIL REASON: Various bugs exist
DateTime::sub() -- spring type3 type3 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\DateTime_sub-spring-type3-type3.phpt]  XFAIL REASON: Various bugs exist
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Zend signed multiply 64-bit, variation 2 [C:\Users\dixyes\Desktop\php\php-src\Zend\tests\zend_signed_multiply-64bit-2.phpt]
Testing bug #65371 [C:\Users\dixyes\Desktop\php\php-src\ext\date\tests\bug65371.phpt]
Hash: hash_copy() via clone [C:\Users\dixyes\Desktop\php\php-src\ext\hash\tests\hash-clone.phpt]
Hash: hash_copy() basic tests [C:\Users\dixyes\Desktop\php\php-src\ext\hash\tests\hash_copy_001.phpt]
Hash: serialize()/unserialize() [C:\Users\dixyes\Desktop\php\php-src\ext\hash\tests\hash_serialize_001.phpt]
Hash: MurmurHash3 test [C:\Users\dixyes\Desktop\php\php-src\ext\hash\tests\murmurhash3.phpt]
Hash: MurmurHash3 seed [C:\Users\dixyes\Desktop\php\php-src\ext\hash\tests\murmurhash3_seed.phpt]
An error is thrown when INF or NaN are encoded [C:\Users\dixyes\Desktop\php\php-src\ext\json\tests\inf_nan_error.phpt]
JSON_THROW_ON_ERROR: global error flag untouched [C:\Users\dixyes\Desktop\php\php-src\ext\json\tests\json_exceptions_error_clearing.phpt]
SPL: RecursiveDirectoryIterator::hasChildren() follow symlinks test [C:\Users\dixyes\Desktop\php\php-src\ext\spl\tests\RecursiveDirectoryIterator_hasChildren.phpt]
Bug #71273 A wrong ext directory setup in php.ini leads to crash [C:\Users\dixyes\Desktop\php\php-src\tests\basic\bug71273.phpt]
=====================================================================

You may have found a problem in PHP.
This report can be saved and used to open an issue on the bug tracker at
https://github.com/php/php-src/issues
This gives us a better understanding of PHP's behavior.
Do you want to save this report in a file? [Yn]: n
NMAKE : fatal error U1077: “C:\Users\dixyes\Desktop\php\php-src\arm64\Release_TS\php.exe”: 返回代码“0x1”
Stop.

@cmb69
Copy link
Member

cmb69 commented Jul 21, 2022

nmake test using dixyes/php-src@19165ed :

Not bad. :)

Also, I wonder which is better: splited into zend + buildsystem or all in one pr.

I think multiple PRs are preferable, since we already started that route. But feel free to decide for yourself what makes sense. :)

@cmb69 cmb69 closed this in 02881a7 Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants