Bug #80435 [Com]: Bus Error compiling phar.phar on Apple M1

From: Date: Wed, 23 Nov 2022 05:53:40 +0000
Subject: Bug #80435 [Com]: Bus Error compiling phar.phar on Apple M1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242883@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80435&edit=1

 ID:                 80435
 Comment by:         Daniel9895hah at gmail dot com
 Reported by:        cja987 at gmail dot com
 Summary:            Bus Error compiling phar.phar on Apple M1
 Status:             Assigned
 Type:               Bug
 Package:            Compile Failure
 Operating System:   macOS 11
 PHP Version:        8.0Git-2020-11-27 (Git)
 Assigned To:        kelunik
 Block user comment: N
 Private report:     N

 New Comment:

Thanks for the info I will try to figure it out for more.
(https://www.gmglobalconnect.one/)github.com


Previous Comments:
------------------------------------------------------------------------
[2022-08-08 22:26:22] kelunik@php.net

See https://github.com/php/php-src/pull/9279
for PHP 8.1.

------------------------------------------------------------------------
[2022-08-08 21:28:52] kelunik@php.net

The current error I get building on M2 is this:

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/kelunik/.php-build/release/ext/phar/phar.php:1145
Stack trace:
#0 /Users/kelunik/.php-build/release/ext/phar/phar.php(1145):
RegexIterator->__construct(Object(RecursiveIteratorIterator), '/\\.svn/')
#1 /Users/kelunik/.php-build/release/ext/phar/phar.php(1089): PharCommand::phar_add(Object(Phar), 0,
'/Users/kelunik/...', NULL, '/\\.svn/', Object(SplFileInfo), NULL, false)
#2 /Users/kelunik/.php-build/release/ext/phar/phar.php(225): PharCommand->cli_cmd_run_pack(Array)
#3 /Users/kelunik/.php-build/release/ext/phar/phar.php(2101): CLICommand->__construct(19, Array)
#4 {main}
  thrown in /Users/kelunik/.php-build/release/ext/phar/phar.php on line 1145
make: *** [ext/phar/phar.phar] Error 255

This is caused by Apple's default protection on Apple Silicon chips, see https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon

It's been fixed in https://github.com/zherczeg/sljit/pull/105,
which is contained in libpcre2 10.40.

https://github.com/php/php-src/commit/32cceb75bf5e42bebbf4d12bab4369924f1d6885
updates php-src to libpcre2 10.40, but only for the 8.2+.

------------------------------------------------------------------------
[2021-05-08 01:15:17] hao dot sun at arm dot com

In my Apple M1 machine, using the method mentioned in this
link(https://qiita.com/shirai_suguru/items/894dc1e71cbc96f4a857) would fix this bug.

$ brew install pcre2
$ ./configure --with-external-pcre=$(brew --prefix pcre2)
$ make
$ make test

Note: the link is in Japanese. you may need to translate it to English.

------------------------------------------------------------------------
[2020-11-30 16:33:48] cja987 at gmail dot com

sapi/cli/php -v does work, but it does immediately get run over by the bus (error)  when running the
test suite.  I can't convince gdb to install either, so there's not a lot that's
debuggable.  Homebrew does build php successfully, and it appears it even applies a patch or two, so
I'll work backwards from that.

------------------------------------------------------------------------
[2020-11-30 14:54:59] nikic@php.net

I suspect the build might be entirely borked, and the phar generation is just the first part that
actually uses the produced binary.

Does running sapi/cli/php -v work? If so, does running sapi/cli/php run-tests.php
Zend -j8 produce any failures?

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=80435


--
Edit this bug report at https://bugs.php.net/bug.php?id=80435&edit=1


Thread (8 messages)

« previous php.bugs (#242883) next »