termux-packages
termux-packages copied to clipboard
Compile PHP with pthreads
Please can this be done, or at least tell me how to do it on termux.
pcntl is not enough? Is enabled in current build...
The software I'm trying to run requires pthreads
I believe the MariaDB package is working - #216 . It would be great to have pdo_mysql!
I see, I believe that I have been writing it in the pdo_mysql thread - must have messed it up somehow... Sorry.
How to install pthreads ?
The extension probably must be patched because of the partial support for pthreads on Android... You can try using source code and phpize as usual but will fail.
pthreads can be included in a static PHP binary on Android
But with pecl and phpize missing php-pthreads.lo for make
1 warning and 14 errors generated. make: *** [Makefile:196: php_pthreads.lo] Error 1 ERROR: `make' failed
@PokeyvalGamer Someone has created a static PocketMine-MP Android binary but it's 32-bit and i need 64-bit, since PocketMine dropped 32-bit support.
Maybe we can do what happens on Ubuntu — install the basic PHP then install extensions seperatly as their own packages. This would allow for greater flexibility and ease of use.
@fornwall @vishalbiswas @Neo-Oli
@TheDiamondYT1 Yes, but I tried to install pthreads with pecl / gcc / make but this gives me the error above you have an idea to install the extentions once the lib created it can be put with the php.ini
https://packages.ubuntu.com/zesty/php/
look through there and you can see many php extensions
Yes but pthreads is here https://pecl.php.net/package/pthreads
@PokeyvalGamer pthreads doesn't contain a makefile...
pecl and phpize create the makefile but make give this error : make: *** [Makefile:196: php_pthreads.lo] Error 1 (php-pthreads.lo not found) else make give this error : no makefile found. Stop. @TheDiamondYT1
@PokeyvalGamer Try compiling pthreads alongside php. When running ./configure in PHP, try including the pthreads directory in that command
with pecl : https://pastebin.com/6m3BNHYu how to run ./configure with php when i run phpize with out pecl in the folder pthreads he failed chmod : Operation not permitted and can't run scripts @TheDiamondYT1
@PokeyvalGamer You don't actually compile it in Termux... you do it on Linux
To get it working I downloaded pthreads from https://github.com/krakjoe/pthreads and PHP 7.1.8 source from php.net. You will need to add pthreads to the ext/ folder within the php-7.1.8.tar.xz (note to verify that pthreads is located at ext/pthreads in the tar.xz, NOT ext/pthreads-master). With pthreads in the PHP source tree you can run buildconf to have PHP's configure file remade to include pthreads as an option in ./configure (--enable-pthreads)
You will have to add the new php-7.1.8.tar.xz to a webserver (such as localhost if you have httpd on your localhost) so that termux-packages can fetch it from the build.sh file. You will get 2 errors once you try to build PHP: First is that the hash code of the new php tar.xz doesnt match that in the build.sh file. It will show both the expected hash value and the hash value of the new php tar.xz file in the error, so copy new value to build.sh. Next error will be about pthreads including all of it's header files (such as classes/pool.h) within <>'s and to change to quotes. This is solved by adding pthreads classes dir and src dir to your C_INCLUDE_PATH. Once built it will work - The low end device that I tested it on was able to do 274.344 (274 point 344) threads per seconds when running ./php -f examples/Benchmark.php from pthreads source.
I'm sure we can do it like it is done on Linux.
- Install PHP from APT
- Install PHP extension from APT
- Jackpot
This way is much more flexible and doesn't require many extensions to be included with the base PHP package.
@TheDiamondYT1 correct, but the ext needs to be compiled before it can be packaged for apt.
Obviously, but the current system is 'just compile it with PHP and be done with it'
@TheDiamondYT1 your walking a path that has frustrated developers for close to a decade. phpize is not cross-compile friendly, which means you can only compile php extensions for android (including pecl) by adding them to the php base source tree. this isn't termux specific. you should forward complaints to #phpinterals
@ClosetMonkey I once used an Android web server app that let you toggle extensions
@TheDiamondYT1 yes, but this specific project is for compiling packages. I can send you an .dpkg of the pthreads ext for php for android if you need,
Someone else compiled PHP 7.2 with pthreads for me.
I think is a waste of time to try to cross compile any PECL extension using the Android SDK on x86 like any other package or PHP itself. These extensions must be compiled on the device because we have all the necessary (C compiler, php-dev package, dev packages for any library...) and PECL is made this way.
We need to fix phpize script and anything else to replace temporary paths and make it work for simple extensions (I tried some patches but don't have time to complete, test and publish it) and then try to compile on the device. Probably the extension will need some patches like many other packages that uses pthreads because of the limited implementation on Android, but done this the extension must compile without problems.
@vaites The more we can do on device, the better! Like making https://github.com/termux/termux-app on device is way cool. https://github.com/sdrausty/buildAPKs/issues/3 Can we get docker on device, or do we need docker to make packages (*.deb) on device?
No need to use docker on the device... To compile a PECL extension in any Linux distro you need the PHP header files, a C compiler and the dependencies. We have all now on Termux.
@vaites can you supply us with a brief example please. A screenshot is greatly appreciated too. I hope it is not too much to ask. I would like to build and package https://github.com/termux/termux-packages/tree/master/packages/moon-buggy on device; PHP as well.