Open MadMapMaker opened 10 months ago
Hello, I just reproduced the problem and found the source error message. It is something related to the binary format of shared objects, similar to the one of issue #10129. In fact the error message is:
PHP Startup: Unable to load dynamic library 'pdo_pgsql.so' (tried: /data/data/com.termux/files/usr/lib/php-apache/pdo_pgsql.so (dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/data/com.termux/files/usr/lib/php-apache/pdo_pgsql.so" (new hash type from the future?)), /data/data/com.termux/files/usr/lib/php-apache/pdo_pgsql.so.so (dlopen failed: library "/data/data/com.termux/files/usr/lib/php-apache/pdo_pgsql.so.so" not found)) in Unknown on line 0
The same error message appears for extension pgsql.so and pdo_pgsql.so.
According to the previously referred issue, the problem migth be on the toolchain used for building the package, so I tried to compile the php package on the device itself.
Sadly, I found another problem when compiling php. Its configure command fails with error:
[...]
checking if we're at 64-bit platform... yes
checking for iconv support... yes
checking for iconv... yes
checking if iconv is glibc's... no
checking if using GNU libiconv... no
checking if iconv is Konstantin Chuguev's... no
checking if using IBM iconv... no
checking if iconv supports errno... no
configure: error: iconv does not support errno
and this is due to libiconv not being the libc one.
So, how should I proceed now? Is there a version of libc iconv for termux?
Thank you, Giuseppe
The complete error message wrote by configure on its config.log is:
configure:44279: checking if iconv supports errno
configure:44309: cc -o conftest -I/data/data/com.termux/files/home/.termux-build/php/host-build/ext/date/lib -I/data/data/com.termux/files/home/.termux-build/php/src/ext/date/lib -g -O2 -fvisibility=hidden -D_GNU_SOURCE conftest.c -lrt -lm >&5
ld.lld: error: undefined symbol: libiconv_open
>>> referenced by conftest.c:230
>>> /data/data/com.termux/files/usr/tmp/conftest-7ae90c.o:(main)
ld.lld: error: undefined symbol: libiconv_close
>>> referenced by conftest.c:238
>>> /data/data/com.termux/files/usr/tmp/conftest-7ae90c.o:(main)
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
configure:44309: $? = 1
configure: program exited with status 1
You may refer https://github.com/termux/termux-packages/tree/master/packages/php for the full build script (build.sh) and its patches. We use libiconv package as a dependency.
Hello @truboxl , you are right. The problem is that libconv on the device toolchain is different than the one on the crossbuilder platform.
On the device it is:
~ $ iconv --version
iconv (GNU libiconv 1.17)
Copyright (C) 2000-2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Bruno Haible.
while, on the crosscompiler, it is:
builder@499d206ad7a4:~/termux-packages$ iconv --version
iconv (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Ulrich Drepper.
As you see, the second one is from glibc, while the first one is from GNU. And, as explained in a php bug report, the only working iconv for php 8 compiling is the one from glibc.
So, the php package is currently not buildable on the device itself, and the crosscompiled version does not load php extensions when running in apache.
I dont know what could be the simplest solution among:
Any sugggestion?
Thank you, Giuseppe
I better digged into the problem and found that this errno thing is a red herring.
The real problem is that libiconv
is not passed to the linker when compiling any conftest source, and this happens since the include file iconv.h
is not correctly found by the configure script. And this lead to all iconv checks fails:
[...]
checking if we're at 64-bit platform... yes
checking for iconv support... yes
checking for iconv... yes
checking if iconv is glibc's... no
checking if using GNU libiconv... no
checking if iconv is Konstantin Chuguev's... no
checking if using IBM iconv... no
checking if iconv supports errno... no
configure: error: iconv does not support errno
I tried to add -liconv
to LD_FLAGS in build.sh script, but it did not fixed the problem.
no need to recompile everything
cd ext/pgsql
#in your case
#cd ~/.termux-build/php/src/ext/pgsql
phpize
nano ./configure
change PGSQL_SEARCH_PATHS="/usr... to PGSQL_SEARCH_PATHS="/data/data/com.termux/files/usr /data/data/com.termux/files/usr/local /data/data/com.termux/files/usr/local/pgsql"
./configure
make
cp ./libs/pgsql.so /data/data/com.termux/files/usr/lib/php-apache
Do the same for pdo_pgslq
patch libs
cd /data/data/com.termux/files/usr/lib/php-apache
patchelf --add-needed libphp.so pdo_pgsql.so
patchelf --set-rpath $PREFIX/libexec/apache2:$PREFIX/lib pdo_pgsql.so
patchelf --add-needed libphp.so pgsql.so
patchelf --set-rpath $PREFIX/libexec/apache2:$PREFIX/libpgsql.so
@licy183 something is damaging the libs, probably patching after stripping
PHP Startup: Unable to load dynamic library 'pdo_pgsql.so' (tried: /data/data/com.termux/files/usr/lib/php-apache/pdo_pgsql.so (dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/data/com.termux/files/usr/lib/php-apache/pdo_pgsql.so" (new hash type from the future?)),
and
httpd: Syntax error on line 66 of /data/data/com.termux/files/usr/etc/apache2/httpd.conf: Cannot load /data/data/com.termux/files/usr/lib/php-apache/pdo_pgsql.so into server: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/data/com.termux/files/usr/lib/php-apache/pdo_pgsql.so" (new hash type from the future?)
Thank you, @romanovj , the procedure you wrote works perfectly. I only had to find the correct path for patchelf (it was inside the ~/.termux-build
tree).
Should I now provide information about different header details for the shared object? Would this be intersting for fixing the build process?
@eppesuig it's standart package
pkg install patchelf
Just compiling pgsql extension as suggested works perfectly. Still I am uncertain about this bug report: the crossbuilder corrupts the shared objects.
Problem description
Hello everyone, I have this problem: I have installed postgresql on termux which works, I have installed apache which works, I have installed the php-pgsql extension which if launched from the terminal (a simple php with a pg_connect) does not give an error, but if it is called from apache it does not work. Furthermore, if I launch php -i from the terminal it tells me that the extension exists, whereas if I launch phpInfo() from Apache it does not see it (see the images). The php.ini file it loads ($PREFIX/lib/php.ini) is apparently the same. What am I doing wrong?
What steps will reproduce the bug?
resultt of php -i
result of phpInfo() in apache via chrome
What is the expected behavior?
No response
System information
termux-info: