php-src icon indicating copy to clipboard operation
php-src copied to clipboard

phpize builds of ext/tokenizer fail

Open evrinoma opened this issue 4 years ago • 14 comments

Description

Hi I was trying to build tokenizer and catch next error

The following code:

./configure && make

Resulted in this output:

make: *** No rule to make target '/usr/src/php/ext/tokenizer/Zend/zend_language_parser.y', needed by '/usr/src/php/ext/tokenizer/Zend/zend_language_parser.c'.  Stop.

found solution by fixing Makefile.frag

$(top_srcdir)/ext/tokenizer/tokenizer_data.c: $(top_srcdir)/Zend/zend_language_parser.h
        @if test ! -z "$(PHP)"; then \
                $(PHP) $(srcdir)/tokenizer_data_gen.php; \
        fi;
#$(builddir)/tokenizer.lo: $(top_srcdir)/Zend/zend_language_parser.c $(top_srcdir)/Zend/zend_language_scanner.c

and finally the module was built and tested successfully ¯_(ツ)_/¯

PHP Version

PHP 8.1.5

Operating System

REHL

evrinoma avatar Apr 24 '22 06:04 evrinoma

Can you run make distclean && ./buildconf and try again?

iluuu1994 avatar Apr 24 '22 08:04 iluuu1994

sure

cd /usr/src/php/ext/tokenizer && phpize && ./configure && make distclean && ./buildconf

but it doesn't matter Resulted in this output:

[root@e28941db27ab /]# cd /usr/src/php/ext/tokenizer && phpize && ./configure && make distclean && ./buildconf
Configuring for:
PHP Api Version:         20210902
Zend Module Api No:      20210902
Zend Extension Api No:   420210902
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -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
checking for PHP extension directory... /usr/local/php/modules
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... gawk
checking whether to enable tokenizer support... yes, shared
checking for a sed that does not truncate output... /usr/bin/sed
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o -o -name \*.dep | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la      modules/* libs/*
rm -f ext/opcache/jit/zend_jit_x86.c
rm -f ext/opcache/jit/zend_jit_arm64.c
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h
rm -f main/build-defs.h scripts/phpize
rm -f ext/date/lib/timelib_config.h ext/mbstring/libmbfl/config.h ext/oci8/oci8_dtrace_gen.h ext/oci8/oci8_dtrace_gen.h.bak
rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 sapi/phpdbg/phpdbg.1 ext/phar/phar.1 ext/phar/phar.phar.1
rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
rm -f ext/phar/phar.phar ext/phar/phar.php
if test "/usr/src/php/ext/tokenizer" != "/usr/src/php/ext/tokenizer"; then \
  rm -f ext/phar/phar/phar.inc; \
fi
/usr/bin/grep -E define'.*include/php' /usr/src/php/ext/tokenizer/configure | /usr/bin/sed 's/.*>//'|xargs rm -f
bash: ./buildconf: No such file or directory

evrinoma avatar Apr 24 '22 08:04 evrinoma

So you're suggesting to apply:

 ext/tokenizer/Makefile.frag | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/tokenizer/Makefile.frag b/ext/tokenizer/Makefile.frag
index 745cbfce91..21b9349a51 100644
--- a/ext/tokenizer/Makefile.frag
+++ b/ext/tokenizer/Makefile.frag
@@ -1,4 +1,4 @@
-$(top_srcdir)/ext/tokenizer/tokenizer_data.c: $(top_srcdir)/Zend/zend_language_parser.y
+$(top_srcdir)/ext/tokenizer/tokenizer_data.c: $(top_srcdir)/Zend/zend_language_parser.h
 	@if test ! -z "$(PHP)"; then \
 		$(PHP) $(srcdir)/tokenizer_data_gen.php; \
 	fi;

That doesn't look right. Actually, I doubt that it makes sense to support building ext/tokenizer via phpize. In my opinion, this is a WONTFIX.

cmb69 avatar Apr 25 '22 10:04 cmb69

I suppose you are right, that's why I asked Сould you give me another way how to build this extension? I have not see specific argument to build this extension with engine, just one argument like --disable-tokenizer (Disable tokenizer support) but I've built php without this argument, and engine doesn't support tokenizer still

also patch should looks like

diff --git a/ext/tokenizer/Makefile.frag b/ext/tokenizer/Makefile.frag
index 745cbfce91..21b9349a51 100644
--- a/ext/tokenizer/Makefile.frag
+++ b/ext/tokenizer/Makefile.frag
@@ -1,4 +1,4 @@
-$(top_srcdir)/ext/tokenizer/tokenizer_data.c: $(top_srcdir)/Zend/zend_language_parser.y
+$(top_srcdir)/ext/tokenizer/tokenizer_data.c: $(top_srcdir)/Zend/zend_language_parser.h
 	@if test ! -z "$(PHP)"; then \
 		$(PHP) $(srcdir)/tokenizer_data_gen.php; \
 	fi;
-$(builddir)/tokenizer.lo: $(top_srcdir)/Zend/zend_language_parser.c $(top_srcdir)/Zend/zend_language_scanner.c

and the building was successful and make test too ¯\_(ツ)_/¯

evrinoma avatar Apr 25 '22 10:04 evrinoma

Сould you give me another way how to build this extension? I have not see specific argument to build this extension with engine, just one argument like --disable-tokenizer (Disable tokenizer support) but I've built php without this argument, and engine doesn't support tokenizer still

The tokenizer extension is supposed to be enabled by default, but is built in statically to the php executable:

$ cd php-src && ./buildconf && ./configure && sapi/cli/php -n -m | grep tokenizer
tokenizer

If you want to build tokenizer.so (dynamically), you need to configure --enable-tokenizer=shared.

cmb69 avatar Apr 25 '22 12:04 cmb69

Hi The solution still doesn't help me to solve building problem tried to build with next configuration Configure Command => './configure' '--build=x86_64' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--disable-all' '--with-pic' '--with-password-argon2' '--with-zlib' '--enable-xml' '--with-libxml' '--disable-phpdbg' '--with-pear' '--disable-cgi' '--enable-fpm' '--enable-mysqlnd' '--enable-tokenizer=shared' '--with-fpm-user=www-data' '--with-fpm-group=www-data' 'build_alias=x86_64' and I have faced with broken tests

[root@31c7b768cb31 php]# make test

Build complete.
Don't forget to run 'make test'.


=====================================================================
PHP         : /usr/src/php/sapi/cli/php 
Warning: PHP Startup: Unable to load dynamic library '' (tried: /usr/src/php/modules/ (/usr/src/php/modules/: cannot read file data: Is a directory), /usr/src/php/modules/.so (/usr/src/php/modules/.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP_SAPI    : cli
PHP_VERSION : 8.1.5
ZEND_VERSION: 4.1.5
PHP_OS      : Linux - Linux 31c7b768cb31 5.16.14-1-default #1 SMP PREEMPT Fri Mar 11 12:33:34 UTC 2022 (80acc65) x86_64
INI actual  : /usr/src/php/tmp-php.ini
More .INIs  :   
CWD         : /usr/src/php
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2022-04-26 09:12:45
=====================================================================
PHP Warning:  PHP Startup: Unable to load dynamic library '' (tried: /usr/src/php/modules/ (/usr/src/php/modules/: cannot read file data: Is a directory), /usr/src/php/modules/.so (/usr/src/php/modules/.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '' (tried: /usr/src/php/modules/ (/usr/src/php/modules/: cannot read file data: Is a directory), /usr/src/php/modules/.so (/usr/src/php/modules/.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
SKIP phpt EXTENSIONS directive - shared module [tests/run-test/extensions-shared.phpt] reason: Required extension missing: openssl
FAIL phpt EXTENSIONS directive - static extension is present [tests/run-test/extensions-static.phpt] 
FAIL EXPECT [tests/run-test/test001.phpt] 
FAIL EXPECTF [tests/run-test/test002.phpt] 
FAIL EXPECTREGEX [tests/run-test/test003.phpt] 
FAIL INI section allows '=' [tests/run-test/test004.phpt] 
PASS Error messages are shown [tests/run-test/test006.phpt] 
FAIL dirname test [tests/run-test/test007.phpt] 
FAIL print_r(Object) [tests/run-test/test009.phpt] 
FAIL STDIN input [tests/run-test/test010.phpt] 
FAIL EXPECT_EXTERNAL [tests/run-test/test011.phpt] 
FAIL EXPECTF_EXTERNAL [tests/run-test/test012.phpt] 
FAIL EXPECTREGEX_EXTERNAL [tests/run-test/test013.phpt] 
FAIL Trivial "Hello World" test [tests/basic/001.phpt] 

Warning: Undefined variable $php_cgi in /usr/src/php/run-tests.php on line 1950
SKIP Simple POST Method test [tests/basic/002.phpt] reason: CGI not available
....

try to load some extension and can't PHP Warning: PHP Startup: Unable to load dynamic library '' (tried: /usr/src/php/modules/ (/usr/src/php/modules/: cannot read file data: Is a directory), /usr/src/php/modules/.so (/usr/src/php/modules/.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '' (tried: /usr/src/php/modules/ (/usr/src/php/modules/: cannot read file data: Is a directory), /usr/src/php/modules/.so (/usr/src/php/modules/.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Also I tried to build with next configuration Configure Command => './configure' '--build=x86_64' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--disable-all' '--with-pic' '--with-password-argon2' '--with-zlib' '--enable-xml' '--with-libxml' '--disable-phpdbg' '--with-pear' '--disable-cgi' '--enable-fpm' '--enable-mysqlnd' '--enable-tokenizer' '--with-fpm-user=www-data' '--with-fpm-group=www-data' 'build_alias=x86_64' and I have faced with broken tests

Finally all tests were fine and php -i show me that tokenize is enabled

evrinoma avatar Apr 26 '22 09:04 evrinoma

If you configure --disable-all, you need to explicitly enable all extensions you want to build. That's the reason, why ext/tokenizer had not been built for your first attempt.

Regarding your --enable-tokenizer=shared builds: I cannot reproduce PHP Startup: Unable to load dynamic library ''. Check /usr/src/php/tmp-php.ini for a line with extension= or so.

Coming back to the original issue, namely that ext/tokenizer can't be built with phpize; I still don't see a good reason to even try that. @remicollet, @oerdnj, do you (need to) do phpize builds of ext/tokenizer?

cmb69 avatar Apr 26 '22 10:04 cmb69

do you (need to) do phpize builds of ext/tokenizer?

I certainly don't, I all for keeping things simple.

oerdnj avatar Apr 26 '22 10:04 oerdnj

Why didn't I catch the fall while app configuration cause tokenizer to depend on other extensions? I think it's a good reason to think about it. 8) Why am I using phpize? because it's simple for me too, and while I tried to build php with all extensions then all tests failed, and it required a lot of time to check and fix. Why couldn't I use phpize?   The tokenizer extension is supposed to be enabled by default, but extension was not disable by default thanks for help

evrinoma avatar Apr 26 '22 10:04 evrinoma

The tokenizer extension is supposed to be enabled by default, but extension was not disable by default

Like I said:

If you configure --disable-all, you need to explicitly enable all extensions you want to build. That's the reason, why ext/tokenizer had not been built for your first attempt.

I'm closing this ticket as WONTFIX. Regular builds of ext/tokenizer using buildconf shouldn't be a problem. @evrinoma, consider to consult StackOverflow or any of the other support channels for your specific issue.

cmb69 avatar Apr 26 '22 10:04 cmb69

The tokenizer extension is supposed to be enabled by default, but the tokenizer extension was not disable by default when I tried to build with config without arg --enable-tokenize and with --disable-all

Configure Command => './configure' '--build=x86_64' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--disable-all' '--with-pic' '--with-password-argon2' '--with-zlib' '--enable-xml' '--with-libxml' '--disable-phpdbg' '--with-pear' '--disable-cgi' '--enable-fpm' '--enable-mysqlnd' '--with-fpm-user=www-data' '--with-fpm-group=www-data' 'build_alias=x86_64'

and but why my json extension is compiled successful and json extension is enabled by default too, I don't know...

Thanks for your big help.

I hoped as a developer you could help me but you sent me to read documentation and ask StackOverflow. I was thinking Stackoverflow is not soo competent in these questions then php engine developers, and I still wonder why you think so. Good You threw me and it's impolite and unprofessional, cause I asked normal questions.

My apologies, I wish you good luck.

evrinoma avatar Apr 26 '22 11:04 evrinoma

As open-source developers, we are not obliged to provide user support. Please take your aggression towards people somewhere else, your attitude is certainly not welcomed here. The only person who is rude here is you, @evrinoma.

oerdnj avatar Apr 26 '22 11:04 oerdnj

I'm sorry, I think you are afraid, cause I don't need support, cause I've built this extension successfully and tested it,  but I found the problem and described it, I tried to help you with the project. Where could you find my aggression? But is normal for you call me rube and sound very polite.

evrinoma avatar Apr 26 '22 11:04 evrinoma

There might be a language barrier issue. :)

Anyhow, almost certainly a lot of people build PHP with the tokenizer extension, and apparently that works for (almost) all of them. If you are facing issues which require you to change the build scripts, this is probably caused by some very special build process and/or build environment. The bandwidth of the php-src developers is limited, and so we cannot cater to all eventualities. Therefore, this is a WONTFIX; that doesn't mean that we don't acknowledge the issue, but rather that we won't spend time fixing it, because there are more important issues we need to work out.

cmb69 avatar Apr 26 '22 11:04 cmb69