RubixML / Tensor

A library and extension that provides objects for scientific computing in PHP.
https://rubixml.com
MIT License
223 stars 27 forks source link

Failed to install PHP extension in PHP Docker images with pecl #13

Closed mlocati closed 3 years ago

mlocati commented 3 years ago

I can't install tensor in a PHP 7.2 Alpine image with pecl.

Steps to reproduce inside the docker image (docker run --rm -it php:7.2-cli-alpine sh)

apk update
apk add $PHPIZE_DEPS lapack-dev libexecinfo-dev openblas-dev
pecl install tensor

Here's the last few lines of the output:

 cc -O3 -ffast-math -I. -I/tmp/pear/temp/tensor/ext -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/include -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/main -I/tmp/pear/temp/tensor/ext -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/tensor/ext/tensor/tensor.zep.c  -fPIC -DPIC -o tensor/.libs/tensor.o
/bin/sh /tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/libtool --mode=compile cc -O3 -ffast-math -I. -I/tmp/pear/temp/tensor/ext -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/include -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/main -I/tmp/pear/temp/tensor/ext -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/tensor/ext/tensor/vector.zep.c -o tensor/vector.lo
 cc -O3 -ffast-math -I. -I/tmp/pear/temp/tensor/ext -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/include -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/main -I/tmp/pear/temp/tensor/ext -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/tensor/ext/tensor/vector.zep.c  -fPIC -DPIC -o tensor/.libs/vector.o
/bin/sh /tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/libtool --mode=compile cc -O3 -ffast-math -I. -I/tmp/pear/temp/tensor/ext -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/include -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/main -I/tmp/pear/temp/tensor/ext -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/tensor/ext/tensor/columnvector.zep.c -o tensor/columnvector.lo
 cc -O3 -ffast-math -I. -I/tmp/pear/temp/tensor/ext -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/include -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/main -I/tmp/pear/temp/tensor/ext -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/tensor/ext/tensor/columnvector.zep.c  -fPIC -DPIC -o tensor/.libs/columnvector.o
/bin/sh /tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/libtool --mode=compile cc -O3 -ffast-math -I. -I/tmp/pear/temp/tensor/ext -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/include -I/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/main -I/tmp/pear/temp/tensor/ext -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/tensor/ext/tensor/decompositions/cholesky.zep.c -o tensor/decompositions/cholesky.lo
/tmp/pear/temp/pear-build-defaultuserDNKfcM/tensor-2.1.4/libtool: line 1283: can't create tensor/decompositions/cholesky.loT: nonexistent directory
mkdir tensor/decompositions/.libs
mkdir: can't create directory 'tensor/decompositions/.libs': No such file or directory
make: *** [Makefile:252: tensor/decompositions/cholesky.lo] Error 1
ERROR: `make' failed
andrewdalpino commented 3 years ago

Hi @mlocati thanks for the valuable feedback! Did you try building the extension as a super user?

mlocati commented 3 years ago

Yes:

$ docker run --rm -it php:7.2-cli-alpine whoami
root
andrewdalpino commented 3 years ago

Ok, what version are you attempting to compile? I wonder if this https://github.com/RubixML/Tensor/pull/11 issue is related in any way.

Also, just a heads up version 2.1.3 on PECL is defunct (the PECL service is very old and its limited set of features offers no way of deleting, updating, hiding, or otherwise disabling a defunct release) so you'll need the 2.1.03 if you want the actual 2.1.3 package. Although by now, 2.1.4 is currently out.

Thanks, any additional information would be great

mlocati commented 3 years ago

pecl install tensor uses the latest stable version: 2.1.4

andrewdalpino commented 3 years ago

Hmmm well, I'm out of ideas for the time being.

Thank you for the reconnaissance info @mlocati - we'll continue to monitor this to see if something similar comes up with other users, distributions of linux and/or containerized setups.

Join us in our Telegram channel if you'd like https://t.me/RubixML

mlocati commented 3 years ago

This error also occurs on debian-based docker images:

The output is almost the same: the compilation still fails after ext/tensor/decompositions/cholesky.zep.c; we only have a slightly different error message:

So, I'm going to update the subject of this issue to a more generic one.

mlocati commented 3 years ago

I tried to rebuild ext with the most recent version of zephir, and it seems that the new code should work:

    PHP_ADD_BUILD_DIR([$ext_builddir/kernel/])
-   PHP_ADD_BUILD_DIR([$ext_builddir/tensor/])
+   for dir in "tensor tensor/decompositions tensor/reductions"; do
+       PHP_ADD_BUILD_DIR([$ext_builddir/$dir])
+   done
    PHP_SUBST(TENSOR_SHARED_LIBADD)

So, instead of patching the generated config.m4 file, we could simply rebuild ext with the most recent zephir version...