Bug 233255

Summary: www/unit-php: error: no PHP embed SAPI found.
Product: Ports & Packages Reporter: iron.udjin
Component: Individual Port(s)Assignee: Sergey A. Osokin <osa>
Status: Closed FIXED    
Severity: Affects Only Me CC: ale, iron.udjin, osa
Priority: --- Flags: bugzilla: maintainer-feedback? (osa)
Version: Latest   
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
autoconf.err none

Description iron.udjin 2018-11-16 17:24:49 UTC
I'm trying to build www/unit-php with php56:

cd /usr/ports/www/unit-php/work-php56/unit-1.6 &&  ./configure php --lib-path=/usr/local/lib  --module=php56
configuring PHP module
checking for PHP ... found
 + PHP SAPI: [cli embed fpm]
checking for PHP embed SAPI ... not found

./configure: error: no PHP embed SAPI found.

*** Error code 1

php56 built with flags:
	CGI            : off
	CLI            : on
	DEBUG          : off
	DTRACE         : off
	EMBED          : on
	FPM            : on
	IPV6           : on
	LINKTHR        : on
	MAILHEAD       : off
	PHPDBG         : off
	ZTS            : on

# php-config --php-sapis
cli embed fpm

It seems configure script doesn't see 'embed' SAPI.

OS: FreeBSD 12.0-BETA4 r340415
Comment 1 iron.udjin 2018-11-16 18:03:43 UTC
Workaroud: build php56 with ZTS=off

It would be good to make unit-php port correctly detect such situations.
Comment 2 Sergey A. Osokin freebsd_committer freebsd_triage 2018-11-18 01:04:57 UTC
Hi,

thanks for the report.

I can't reproduce this issue on my laptop with FreeBSD 12.0-BETA4.

To fix the issue I'd recommend to install php56 with pkg(1) utility, php 5.6.38 has been built with "--enable-embed" option:

% php-config --configure-options
--with-layout=GNU --with-config-file-scan-dir=/usr/local/etc/php --disable-all --enable-libxml --enable-mysqlnd --with-libxml-dir=/usr/local --with-pcre-regex=/usr/local --with-zlib-dir=/usr --program-prefix= --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-embed --with-regex=php --with-zend-vm=CALL --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/ --build=amd64-portbld-freebsd12.0 build_alias=amd64-portbld-freebsd12.0 CC=cc CFLAGS=-O2 -pipe -fstack-protector -fno-strict-aliasing LDFLAGS= -fstack-protector LIBS=-lpthread CPPFLAGS= CPP=cpp CXX=c++ CXXFLAGS=-O2 -pipe -fstack-protector -fno-strict-aliasing

Also, unit-php56 can be installed via pkg(1) as well.
Comment 3 Sergey A. Osokin freebsd_committer freebsd_triage 2018-11-18 01:11:02 UTC
I've missed your recent commit about ZTS option for php.
So, let's try to get a comment about that behavior from lang/php56 maintainer.
Comment 4 Sergey A. Osokin freebsd_committer freebsd_triage 2018-11-18 01:15:33 UTC
Hi Alex,

hope you're doing well.


Could you help us to resolve the issue - when lang/php56 built with ZTS option the configure script from www/php-unit fails, i.e. can't detect php shared library.
Comment 5 Sergey A. Osokin freebsd_committer freebsd_triage 2018-11-18 01:21:58 UTC
Dear iron.udjin@gmail.com,


Could you please attach the unit-php/work-php56/unit-1.6/build/autoconf.err file to the ticket, hope it helps us to better understand the issue.

Thanks.
Comment 6 iron.udjin 2018-11-18 02:37:09 UTC
Created attachment 199306 [details]
autoconf.err
Comment 7 Sergey A. Osokin freebsd_committer freebsd_triage 2018-11-18 05:03:40 UTC
Thanks for the autoconf.err file.

As far as we can see there next code can't be compiled:

        #include <php.h>
        #include <php_main.h>

        int main() {
            php_request_startup();
            return 0;
        }

/usr/local/include/php/main/php_main.h:30:1: note: 'php_request_startup' declared here
PHPAPI int php_request_startup(TSRMLS_D);
^
/usr/local/include/php/main/php.h:60:18: note: expanded from macro 'PHPAPI'
#               define PHPAPI __attribute__ ((visibility("default")))
1 error generated.

So, it looks like unit doesn't support Zend Thread Safety (ZTS) feature of php.

I'd recommend to raise a feature request about that with the vendor,  https://trac.nginx.org/.
Comment 8 iron.udjin 2018-11-18 09:29:53 UTC
https://github.com/nginx/unit/issues/184
Comment 9 Alex Dupre freebsd_committer freebsd_triage 2018-11-19 16:26:15 UTC
I guess you should replace all php_request_startup() occurrences with php_request_startup(TSRMLS_C), to support thread-safe php 5.6.
Comment 10 iron.udjin 2018-11-19 20:22:09 UTC
Could you please add this patch? https://github.com/nginx/unit/issues/184#issuecomment-439994329

With the patch unit-php compiles fine when ZFS 'on' or 'off'.
Comment 11 commit-hook freebsd_committer freebsd_triage 2018-11-19 21:40:28 UTC
A commit references this bug:

Author: osa
Date: Mon Nov 19 21:40:16 UTC 2018
New revision: 485364
URL: https://svnweb.freebsd.org/changeset/ports/485364

Log:
  Fix the unit's php module build when the lang/php* was built with
  the ZTS option.

  Bump PORTREVISION.

  PR:	233255
  Patch:	https://github.com/nginx/unit/issues/184

Changes:
  head/www/unit/Makefile
  head/www/unit/files/php_zts.patch
Comment 12 Sergey A. Osokin freebsd_committer freebsd_triage 2018-11-19 21:41:32 UTC
Thanks for the report, the issue has been fixed.