Bug 237722 - lang/php73: No PCRE2 JIT support on amd64
Summary: lang/php73: No PCRE2 JIT support on amd64
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Torsten Zuehlsdorff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-03 08:16 UTC by Jon Tejnung
Modified: 2019-05-06 20:28 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (tz)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Tejnung 2019-05-03 08:16:00 UTC
Hi,

When compiling this package using this port on a amd64/x86_64 machine, no JIT support will be compiled for PCRE2.

> checking for JIT support in PCRE2... no

PCRE2 JIT is supported on amd64/x86_64 and this not being compiled can cause a (sometimes huge) performance decrease in certain PHP scripts relying on regex matching.

In the Makefile the following line is specified:

GNU_CONFIGURE=  yes

This option will append this to the configure arguments.

--build=${CONFIGURE_TARGET}

Where CONFIGURE_TARGET defaults to ${ARCH}-portbld-${OPSYS:tl}${OSREL}, and $ARCH in our case is "amd64".

Specifying --build to the PHP configure script will override PHP:s "config.guess" which otherwise will try to find out which machine it's building for. If "config.guess" HAD run, it whould have discovered "amd64" but then translated it to "x86_64" before returning it. Now instead, because of the --build is stating the target architecture, the configure script have the value "amd64".

Later in the script, when deciding if it should compile with HAVE_PCRE_JIT_SUPPORT, it runs the following check.
 
19706         case $host_cpu in
19707         arm*|i3456786|x86_64|mips*|powerpc*|sparc)

The check will fail as $host_cpu is "amd64" which it doesn't think is a supported architecture and no JIT support will be compiled into the binary.
Comment 1 Jon Tejnung 2019-05-03 11:17:48 UTC
I ran som tests and the problem was not what I wrote from the beginning. Sorry for that. The problem with the name of the cpu architecture is only when cross compiling PHP.

The real problem seems to be that the PHP installer is running a test script to determine if PCRE2 have JIT support. But the script fails when including the PCRE library header (#include <pcre2.h>).

This is because PHP is looking for the header files in /usr/include, when they are actually in /usr/local/include. 

"./configure --help" says:

Some influential environment variables:
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>

So my solution and proposed change to fix this is adding this row to the Makefile:

CONFIGURE_ENV= CPPFLAGS="-I/usr/local/include"
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-05-03 22:32:38 UTC
A commit references this bug:

Author: tz
Date: Fri May  3 22:31:47 UTC 2019
New revision: 500756
URL: https://svnweb.freebsd.org/changeset/ports/500756

Log:
  lang/php73: enable PRCE2 JIT support

  This will speed up certain PHP scripts relying on regex matches.

  PR:		237722
  Submitted by: Jon Tejnung <jon@herrskogen.se>

Changes:
  head/lang/php73/Makefile
Comment 3 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2019-05-03 22:34:18 UTC
Hello Jon,

thanks for the detailed explanation and the suggestion for a fix. I tested it and it was fine. So i committed it a second ago!

Thank you!
Torsten
Comment 4 Mikael Urankar freebsd_committer freebsd_triage 2019-05-04 09:39:58 UTC
(In reply to Torsten Zuehlsdorff from comment #3)
What happens if I don't install ports in /usr/local?
Comment 5 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2019-05-06 20:28:15 UTC
(In reply to mikael.urankar from comment #4)

> What happens if I don't install ports in /usr/local?

Your question is a very polite way to tell me, that i broke it for this case! ;)

Thank you for sharing this question. I fixed it through the use of ${LOCALBASE}

Greetings,
Torsten
Comment 6 commit-hook freebsd_committer freebsd_triage 2019-05-06 20:28:19 UTC
A commit references this bug:

Author: tz
Date: Mon May  6 20:27:18 UTC 2019
New revision: 500929
URL: https://svnweb.freebsd.org/changeset/ports/500929

Log:
  lang/php73: convert CPPFLAGS from /usr/local to ${LOCALBASE}

  As mat point out too often: if you write /usr/local you should write ${LOCALBASE}

  PR:		237722
  Reported by:	mikael.urankar@gmail.com

Changes:
  head/lang/php73/Makefile