Open TheDiamondYT1 opened 7 years ago
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.
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.
Of course. I compiled just now the ImageMagick extension:
apt install autoconf pkg-config clang libllvm termux-elf-cleaner imagemagick-dev pcre-dev
wget http://pecl.php.net/get/imagick-3.4.3.tgz
tar xzvf imagick-3.4.3.tgz
cd imagick-3.4.3
phpize
# here I edited _configure_ and replaced `/bin/sh` with `/data/data/com.termux/files/usr/bin/sh`
./configure
make
make install
termux-elf-cleaner /data/data/com.termux/files/usr/lib/php/imagick.so
# here I added `extension=imagick-3.4.3.tgz. so` to php.ini
php -m | grep imagick
I attached two files: the successful compilation and the phpinfo()
output.
As I said, we need to patch php package to fix /bin/sh problem and some other paths. I have some patches done but not enough time to complete. Will send a pull request as soon as I can.
After phpsize
$termux-chroot
$cd imagick-3.4.3
$make
.
.
.
Build complete.
Don't forget to run 'make test'.
$
Thank you!
"ldconfig
Permission denied" keeps creeping up, not just here.
What libc is being used when compiled on device?
bionic libc ... the native one
So the toolchain on the device has the appropriate Android NDK headers? This is very cool if so
yes that is what seperates termux from chroot linux image. everything is using bionic libc.
@its-pointless How can I let it see ldconfig
? This might resolve lm-sensors too.
thats the reason we set LD_LIBRARY_PATH so the linker can see it.
@its-pointless where how if you don't mind me asking? termux-chroot
doesn't set it; Does it?
iv never bothered with php. But when you start termux the shell env LD_LIBRARY_PATH is set to /data/data/com.termux/files/usr/lib. this makes the linker at /system/bin/linker or linker64 to search our libs before the android libs. to add to this search path either the executable searches a specific path or you can do this from shell. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/data/com.termux/usr/lib/otherlibpath
@its-pointless I enjoyed rust btw.
Online help: https://termux.com/help
Community forum: https://termux.com/community
IRC channel: #termux on freenode
Gitter chat: https://gitter.im/termux/termux
Mailing list: termux+subscribe@groups.io
Search packages: pkg search <query>
Install a package: pkg install <package>
Upgrade packages: pkg upgrade
Learn more: pkg help
$ $LD_LIBRARY_PATH
bash: /data/data/com.termux/files/usr/lib: Is a directory
$ termux-chroot
$ $LD_LIBRARY_PATH
bash: /data/data/com.termux/files/usr/lib: Is a directory
$
There are extensions that need patches. @fornwall, what's the best way to do this?. I mean, must we provide patches with php-dev package for the extensions? Must we patch phpize script to automate this?.
Suggestions are welcome...
One suggestion would be to build both threadsafe and non-ts versions of libphp7. Current package is non-ts. Not all sapis can use non-ts builds, and some extensions require it a threadsafe build. Any major distribution offers both.
I have a problem with compiling imagick. Make fatal error: 'pcre2.h' file not found This included in /data/data/com/termux/files/usr/include/php/ext/pcre/php_pcre.h:27:10:
How can I fix it?
@grigruss you can install the package that contains the file that it doesn't find.
Header files are found in the -dev packages. Installing pcre2-dev
should solve the problem in your case.
@Grimler91 thank you! It's work!
This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Can you help build a CLI with ZTS support? I tried to add in build.sh PHP package flag --enable-zts, however, the build with this flag fails with errors. TSRM.c: error: undefined symbol: _tsrm_ls_cache
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)
Please tell me if this instruction is working today with PHP 8.2? I can't compile it in a termux package with the --enable-zts flag to connect parallel
Please can this be done, or at least tell me how to do it on termux.