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

Generating phar.php during cross-compile can't be done #11099

Closed
peter279k opened this issue Apr 18, 2023 · 8 comments · Fixed by ThePHPF/thephp.foundation#90
Closed

Generating phar.php during cross-compile can't be done #11099

peter279k opened this issue Apr 18, 2023 · 8 comments · Fixed by ThePHPF/thephp.foundation#90

Comments

@peter279k
Copy link
Contributor

peter279k commented Apr 18, 2023

Description

When building the PHP 8.x versions with phar support from source with aarch64-linux-gnu tool chain, it will be failed:

Here are configure commands:

./configure '--cache-file=/home/localadmin/.phpbrew/cache/config.cache' '--prefix=/home/localadmin/.phpbrew/php/php_8_0_arm' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--with-zlib=/usr' '--with-libdir=lib/x86_64-linux-gnu' '--enable-dom' '--with-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash' '--enable-pcntl' '--enable-pdo' '--enable-posix' '--enable-sockets' '--disable-opcache' '--without-readline' '--without-openssl' '--without-curl' '--without-pear' '--without-zip' '--host=aarch64-linux' '--with-xsl=/opt/libxslt' '--with-zlib=/opt/zlib' '--with-libxml=/opt/libxml2' '--with-bz2=/opt/bzip2' '--disable-test' '--with-config-file-path=/home/localadmin/.phpbrew/php/php_8_0_arm/etc/cli' '--with-config-file-scan-dir=/home/localadmin/.phpbrew/php/php_8_0_arm/var/db/cli' 'PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/libxslt/lib/pkgconfig' >> '/home/localadmin/.phpbrew/build/php_8_0_arm/build.log'

And the error message is as follows:

Generating phar.php

/bin/bash: /home/localadmin/.phpbrew/build/php_8_0_arm/sapi/cli/php: cannot execute binary file: Exec format error

Makefile:413: recipe for target 'ext/phar/phar.php' failed

make: *** [ext/phar/phar.php] Error 126

I think it should have the way to check whether it's cross compiling mode and it can avoid running the php binary.

That is, it should skip related phar generating steps when it's the cross compiling mode.

PHP Version

PHP 8.x

Operating System

Using the aarch64-linux-gnu tool chain in the Ubuntu 18.04 for the AARCH-64 target.

@FosterYi97
Copy link

Hello, have you solved this problem?

@peter279k
Copy link
Contributor Author

I don't resolve the problem.

peter279k added a commit to peter279k/php-src that referenced this issue May 15, 2023
peter279k added a commit to peter279k/php-src that referenced this issue May 17, 2023
peter279k added a commit to peter279k/php-src that referenced this issue May 17, 2023
peter279k added a commit to peter279k/php-src that referenced this issue May 18, 2023
nielsdos added a commit that referenced this issue May 20, 2023
* PHP-8.1:
  Fix GH-11099: Generating phar.php during cross-compile can't be done
nielsdos added a commit that referenced this issue May 20, 2023
* PHP-8.2:
  Fix GH-11099: Generating phar.php during cross-compile can't be done
@mcoelho80
Copy link

# uname -a
FreeBSD server 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64

Generating phar.php
[: -ne: unexpected operator
Skipping phar.php generating during cross compilation
Generating phar.phar
[: -ne: unexpected operator
Skipping phar.phar generating during cross compilation

This fix doesn't work on FreeBSD. I had to revert this patch to be able to build PHP with phar support.

@nielsdos
Copy link
Member

@mcoelho80 I'll take a look later today

@peter279k
Copy link
Contributor Author

It seems that the issue is about the shell. I will check this in the FreeBSD.

@mcoelho80
Copy link

Same problem with PHP 8.1.20.
PHP 8.0.29 seems fine, as ext/phar/Makefile.frag wasn't changed.

peter279k added a commit to peter279k/php-src that referenced this issue Jun 12, 2023
peter279k added a commit to peter279k/php-src that referenced this issue Jun 12, 2023
@peter279k
Copy link
Contributor Author

@mcoelho80, PR is created and you can also help me to check that. Thanks :).

@nielsdos
Copy link
Member

@mcoelho80, PR is created and you can also help me to check that. Thanks :).

I tested the patch on both Linux and FreeBSD and it works. The PR is merged now. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
@mcoelho80 @nielsdos @Girgias @peter279k @FosterYi97 and others