Bug 223880 - Compilation of a port 'archivers/php71-phar' breaks with an error
Summary: Compilation of a port 'archivers/php71-phar' breaks with an error
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Torsten Zuehlsdorff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-26 09:47 UTC by Alexander Mishin
Modified: 2017-12-05 15:57 UTC (History)
4 users (show)

See Also:


Attachments
files/patch-Makefile.frag (472 bytes, patch)
2017-11-26 09:47 UTC, Alexander Mishin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Mishin 2017-11-26 09:47:55 UTC
Created attachment 188291 [details]
files/patch-Makefile.frag

A compilation of a port 'archivers/php71-phar' breaks with following message:

ar/work/php-7.1.12/ext/phar/phar_object.c  -fPIC -DPIC -o .libs/phar_object.o
--- /usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar/phar_path_check.c ---
re2c: error: cannot open ext/phar/phar_path_check.re
*** [/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar/phar_path_check.c] Error code 1

make[1]: stopped in /usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar
1 error

make[1]: stopped in /usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar
===> Compilation failed unexpectedly.

As a current directory of a 'make' job is the same as a location of files 'phar_path_check.*'. there is a dirty patch files/patch-Makefile.frag:
Comment 1 Jochen Neumeister freebsd_committer 2017-11-26 10:15:19 UTC
I'll give it to tz @ - he is maintainer of the php7 * ports :-)
Comment 2 Torsten Zuehlsdorff freebsd_committer 2017-11-27 09:45:40 UTC
(In reply to mishin from comment #0)

> A compilation of a port 'archivers/php71-phar' breaks with following message:

I do need more information. Compiling the port with the default options works just fine on all supported FreeBSD versions. I double checked it.

So - what options do you use? Which commands do you type? What is in /etc/make.conf? 

Greetings,
Torsten
Comment 3 Alexander Mishin 2017-11-27 13:23:08 UTC
My system is:
FreeBSD www.example.com 12.0-CURRENT FreeBSD 12.0-CURRENT #3 r326145: Sat Nov 25 00:53:43 +04 2017     root@www.example.com:/usr/obj/usr/src/amd64.amd64/sys/MYKERNEL  amd64

I tried to compile by 'cd /usr/ports/archivers/php71-phar; make' and by 'portmaster archivers/php71-phar' (with and without 'ccache') with the same result.

All I can see is a full and correct path to 'phar_path_check.c' and relative and   uncertain one to 'phar_path_check.re' from the error message. Then I find Makefile.frag and a difference with paths definitions.

My /etc/make.conf:
----
LINGUAS=ru
CCACHE_DIR=/var/ccache

#NOCCACHE=YES
.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))
.if !defined(NOCCACHE) && exists(/usr/local/libexec/ccache/world/cc)
CC:=${CC:C,^cc,/usr/local/libexec/ccache/world/cc,1}
CXX:=${CXX:C,^c\+\+,/usr/local/libexec/ccache/world/c++,1}
.endif
.endif

.if ${CC:T} == "clang"
CFLAGS+=-Qunused-arguments
.endif

DEFAULT_VERSIONS+=python=2.7 python2=2.7 python3=3.6
DEFAULT_VERSIONS+=linux=c7
MALLOC_PRODUCTION=YES
----

And `ls -1 ./files/` for the port:
---
patch-config.m4
patch-phar.c
---
Both from 2016.07.26

Thanks
Comment 4 Dean E. Weimer 2017-11-27 15:04:55 UTC
I ran into this as well running FreeBSD 11.1-RELEASE-p4, I have a working directory prefix set in my /etc/make.conf thought maybe there was an issue with that.

WRKDIRPREFIX= /var/ports

[...snip...]
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/var/ports/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar -DPHP_ATOM_INC -I/var/ports/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar/include -I/var/ports/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar/main -I/var/ports/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar -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 -I/usr/local/include -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 -O2 -pipe -fstack-protector -fno-strict-aliasing -c /var/ports/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar/phar_object.c  -fPIC -DPIC -o .libs/phar_object.o
re2c: error: cannot open ext/phar/phar_path_check.re
*** Error code 1

Stop.
make[1]: stopped in /var/ports/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar
*** Error code 1

Stop.
make: stopped in /usr/ports/archivers/php71-phar

Worked around it by searching using grep in the work directory for ext/phar/phar_path_check.re, then used sed to add in the full path.

sed -I .bak s~ext\/phar\/phar_path_check\.re~/var/ports/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar/phar_path_check.re~g /var/ports/usr/ports/archivers/php71-phar/work/php-7.1.12/ext/phar/phar_path_check.c

Then ran make again (without Cleaning), completed successfully and installed.

full list of options in make.conf:
CFLAGS?= -O                                                                                                                                                                                             CLFAGS+= -pipe                                                                                                                                                                                          NO_WERROR=
WERROR=                                                                                                                                                                                                 .if ${CC:T} == "clang"                                                                                                                                                                                    CFLAGS+= -Qunused-arguments                                                                                                                                                                           .endif                                                                                                                                                                                                  
WITH_CCACHE_BUILD= YES                                                                                                                                                                                  OPTIONS_SET= LIBEDIT OPTIMIZED_CFLAGS                                                                                                                                                                   OPTIONS_UNSET= X11 X GUI TLS_SRP AVAHI                                                                                                                                                                  WRKDIRPREFIX= /var/ports                                                                                                                                                                                PACKAGES= /var/ports/packages
WITH_PKGNG= YES                                                                                                                                                                                         DEFAULT_VERSIONS= pgsql=9.6 php=7.1 apache=2.4 perl5=5.26 python=2.7 bdb=6 mysql=10.2m ssl=libressl
Comment 5 Kristian K. Nielsen 2017-11-28 20:26:56 UTC
I have the exact same problem.

This is caused by the package "devel/re2c" - if you like me have this one installed the php71-phar compiler will also try to generate the parsers:
checking for re2c... re2c
checking for re2c version... 0.14.3 (ok)

This will fail due to incorrect paths to the .re-scripts.

But if you have not installed "devel/re2c" - this will be skipped with this warning:
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.


It is up to tz what is the correct behaviour.

Maybe devel/re2c should actually be a compile-time-dependency of php-phar.
At least the package most be able to compile when the package is installed.

I have re2c installed due to use of spamassassin on the same machine which uses it to compile rules (when that is enabled).
Comment 6 Torsten Zuehlsdorff freebsd_committer 2017-11-29 09:11:14 UTC
Thanks for the feedback, i will investigate the issue and come back.

But at first glance i find this rather suspicious. re2c is a lexer and shouldn't be used at all in phar. But i will check this.
Comment 7 Kristian K. Nielsen 2017-11-29 10:30:36 UTC
Great..

Well in phar - they did in fact implement phar_path_check using re2c.

This is the file:
https://github.com/php/php-src/blob/master/ext/phar/phar_path_check.re

It is also included in the compiled version:
https://github.com/php/php-src/blob/master/ext/phar/phar_path_check.c
Comment 8 Markus Kohlmeyer 2017-11-30 21:38:45 UTC
I'm having the same issue.
It only happens when devel/re2c is installed, but re2c is needed or at least recommended by other ports and even by PHP itself.
Seems like an upstream bug.
Comment 9 commit-hook freebsd_committer 2017-12-05 15:56:49 UTC
A commit references this bug:

Author: tz
Date: Tue Dec  5 15:56:05 UTC 2017
New revision: 455586
URL: https://svnweb.freebsd.org/changeset/ports/455586

Log:
  archivers/php71-phar: Unbreak if devel/re2c is installed

  There is a upstream bug which makes compiling this module
  impossible if devel/re2c is installed:
  https://bugs.php.net/bug.php?id=75587

  The patch unbreaks this behavior.

  PR:           223880
  Submitted by: mishin@mh.san.ru

Changes:
  head/archivers/php71-phar/Makefile
  head/archivers/php71-phar/files/patch-Makefile.frag
Comment 10 Torsten Zuehlsdorff freebsd_committer 2017-12-05 15:57:34 UTC
Yes it is an upstream bug introduced in 7.1.12. The patch is fine but misses the PORTREVISION.

The build-tests are fine and after the patch its possible ti compile the module even if devel/re2c is installed.

The fix is committed. Thanks everyone! :)