PHP 7.4.23 fails to compile on Apple M1
vfsoraki opened this issue · 14 comments
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.
One more thing to add is that searching for error, yields results that people are having warnings, but I'm getting a fatal error.
More testing and PHP 8.0.10 also fails with the same error.
FWIW, I'm bumping up against the same thing (v7.4.27).
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
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!
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....
Also facing exactly the same Error!
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 php@7.4
.
It may help someone.
I also face this problem with Allocation of JIT memory failed
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
.
@andreacasarin I tried using your branch with that env var, I am still getting the same error :(
in this blog post: https://developpaper.com/mac-silicon-m1-compilation-and-installation-of-php8-swoole4-6-arm64/
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?
i was finally able to get php installed using my fix in #123