Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.4.23 fails to compile on Apple M1 #94

Open
vfsoraki opened this issue Sep 19, 2021 · 14 comments
Open

PHP 7.4.23 fails to compile on Apple M1 #94

vfsoraki opened this issue Sep 19, 2021 · 14 comments

Comments

@vfsoraki
Copy link

I'm trying to compile like this:

PHP_WITHOUT_PDO_PGSQL=yes  asdf install php 7.4.23

I'm also having the same issue as this, but I'm ignoring it for now. I don't need Postgres support.

Compilation fails with the following error:

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.

Fatal error: Uncaught InvalidArgumentException: RegexIterator::__construct(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in /private/var/folders/5x/j_rlyqhx2hddmn_ds3pj0t0h0000gn/T/php-src-php-7.4.23/ext/phar/phar.php:1133
Stack trace:
#0 /private/var/folders/5x/j_rlyqhx2hddmn_ds3pj0t0h0000gn/T/php-src-php-7.4.23/ext/phar/phar.php(1133): RegexIterator->__construct(Object(RecursiveIteratorIterator), '/\\.svn/')
#1 /private/var/folders/5x/j_rlyqhx2hddmn_ds3pj0t0h0000gn/T/php-src-php-7.4.23/ext/phar/phar.php(1077): PharCommand::phar_add(Object(Phar), 0, '/var/folders/5x...', NULL, '/\\.svn/', Object(SplFileInfo), NULL, true)
#2 /private/var/folders/5x/j_rlyqhx2hddmn_ds3pj0t0h0000gn/T/php-src-php-7.4.23/ext/phar/phar.php(225): PharCommand->cli_cmd_run_pack(Array)
#3 /private/var/folders/5x/j_rlyqhx2hddmn_ds3pj0t0h0000gn/T/php-src-php-7.4.23/ext/phar/phar.php(2089): CLICommand->__constru in /private/var/folders/5x/j_rlyqhx2hddmn_ds3pj0t0h0000gn/T/php-src-php-7.4.23/ext/phar/phar.php on line 1133
make: *** [ext/phar/phar.phar] Error 255
make: *** Waiting for unfinished jobs....

Clearly, I can't set pcre.jit=0 because I don't have PHP installed yet, and I don't know what grant PHP permission to allocate executable memory means.

I tried adding PHP_CONFIGURE_OPTIONS="--with-pcre-jit" to compile command, to no avail.

I'm not sure what is causing it, I'm just hoping someone else also encountered this issue.

I've found issues searching for this error, but it seems people are having it while running some code. See also this bug, but I don't know if it applies to me.

@vfsoraki
Copy link
Author

One more thing to add is that searching for error, yields results that people are having warnings, but I'm getting a fatal error.

@vfsoraki
Copy link
Author

More testing and PHP 8.0.10 also fails with the same error.

@robwilkerson
Copy link

robwilkerson commented Jan 10, 2022

FWIW, I'm bumping up against the same thing (v7.4.27).

@FL-K
Copy link

FL-K commented Mar 10, 2022

7.4.28 using phpbrew facing same issue

phpbrew install 7.4.28 +bz2="$(brew --prefix bzip2)"

is not working failing with


Fatal error: Uncaught InvalidArgumentException: RegexIterator::__construct(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in /Users/kristi.jorgji/.phpbrew/build/php-7.4.28/ext/phar/phar.php:1133
Stack trace:
#0 /Users/kristi.jorgji/.phpbrew/build/php-7.4.28/ext/phar/phar.php(1133): RegexIterator->__construct(Object(RecursiveIteratorIterator), '/\\.svn/')
#1 /Users/kristi.jorgji/.phpbrew/build/php-7.4.28/ext/phar/phar.php(1077): PharCommand::phar_add(Object(Phar), 0, '/Users/kristi.j...', NULL, '/\\.svn/', Object(SplFileInfo), NULL, true)
#2 /Users/kristi.jorgji/.phpbrew/build/php-7.4.28/ext/phar/phar.php(225): PharCommand->cli_cmd_run_pack(Array)
#3 /Users/kristi.jorgji/.phpbrew/build/php-7.4.28/ext/phar/phar.php(2089): CLICommand->__construct(19, Array)
#4 {main}

I am on Mac 2021 silicion arm64 as well

@elalemanyo
Copy link

Hi,
I am also having some issues installing php on Apple M1, after lots of errors and some fixes I am stuck here:

Undefined symbols for architecture arm64:
  "_rl_mark", referenced from:
      _zif_readline_info in readline.o
Undefined symbols for architecture arm64:
  "_rl_mark", referenced from:
      _zif_readline_info in readline.o
  "_rl_pending_input", referenced from:
Undefined symbols for architecture arm64:
  "_rl_mark", referenced from:
      _zif_readline_info in readline.o
      _zif_readline_info in readline.o
  "_rl_pending_input", referenced from:
      _zif_readline_info in readline.o
  "_rl_pending_input", referenced from:
      _zif_readline_info in readline.o
ld: symbol(s) not found for architecture arm64
ld: symbol(s) not found for architecture arm64
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sapi/cgi/php-cgi] Error 1
make: *** Waiting for unfinished jobs....
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sapi/cli/php] Error 1
make: *** [sapi/fpm/php-fpm] Error 1
Undefined symbols for architecture arm64:
  "_rl_mark", referenced from:
      _zif_readline_info in readline.o
  "_rl_pending_input", referenced from:
      _zif_readline_info in readline.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sapi/phpdbg/phpdbg] Error 1

Any idea would be great. Thanks!

@mvalitov
Copy link

I get the same error:

PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.

Fatal error: Uncaught InvalidArgumentException: RegexIterator::__construct(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in /private/var/folders/39/rygwdt1s1w307lkpygr8qv4h0000gn/T/php-src-php-7.4.28/ext/phar/phar.php:1133
Stack trace:
#0 /private/var/folders/39/rygwdt1s1w307lkpygr8qv4h0000gn/T/php-src-php-7.4.28/ext/phar/phar.php(1133): RegexIterator->__construct(Object(RecursiveIteratorIterator), '/\\.svn/')
#1 /private/var/folders/39/rygwdt1s1w307lkpygr8qv4h0000gn/T/php-src-php-7.4.28/ext/phar/phar.php(1077): PharCommand::phar_add(Object(Phar), 0, '/var/folders/39...', NULL, '/\\.svn/', Object(SplFileInfo), NULL, true)
#2 /private/var/folders/39/rygwdt1s1w307lkpygr8qv4h0000gn/T/php-src-php-7.4.28/ext/phar/phar.php(225): PharCommand->cli_cmd_run_pack(Array)
#3 /private/var/folders/39/rygwdt1s1w307lkpygr8qv4h0000gn/T/php-src-php-7.4.28/ext/phar/phar.php(2089): CLICommand->__constru in /private/var/folders/39/rygwdt1s1w307lkpygr8qv4h0000gn/T/php-src-php-7.4.28/ext/phar/phar.php on line 1133
make: *** [ext/phar/phar.phar] Error 255
make: *** Waiting for unfinished jobs....

@AhmedMohsen600
Copy link

Also facing exactly the same Error!

@vfsoraki
Copy link
Author

As it seems people are facing this more and more, it’s good to know that you can install PHP 7.4 using brew: brew install [email protected].

It may help someone.

@bintoll
Copy link

bintoll commented Apr 17, 2022

I also face this problem with Allocation of JIT memory failed

@andreacasarin
Copy link
Contributor

Hello here, please take a look at #120 and let me know if it fixes the issue for you.

Just add PHP_WITHOUT_PCRE_JIT=yes before your usual asdf install.

@qshanahan-springhealth
Copy link
Contributor

@andreacasarin I tried using your branch with that env var, I am still getting the same error :(

@qshanahan-springhealth
Copy link
Contributor

in this blog post: https://developpaper.com/mac-silicon-m1-compilation-and-installation-of-php8-swoole4-6-arm64/

image

It looks like they edited the php installation files to set ini_set("pcre.jit", "0"); to zero. Is there a way to patch the installation archive?

@qshanahan-springhealth
Copy link
Contributor

i was finally able to get php installed using my fix in #123

@w3jimmy
Copy link

w3jimmy commented Apr 11, 2023

if you're still struggling, check this article, especially the part where the variables are set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

10 participants