crazywhalecc / static-php-cli

Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included.
https://static-php.dev
MIT License
1.33k stars 233 forks source link

如何交叉编译? #521

Closed rampageX closed 3 months ago

rampageX commented 3 months ago

想编译一个 armv5 的版本,尝试:

export CC=arm-linux-musleabi-gcc
export CXX=arm-linux-musleabi-g++

./spc build "openssl,pcntl,mbstring,imagick" --build-cli --build-fpm

会报错,提示交叉编译但未提供 --host 参数:

[02:23:29] [DEBU] [PASSTHRU] cd '/root/src/static-php/source/pkg-config' && LDFLAGS="--static" ./configure --disable-shared --enable-static --with-internal-glib --disable-host-tool --with-pic --prefix=/root/src/static-php/buildroot --without-sysroot --without-system-include-path --without-system-library-path --without-pc-path
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for style of include used by make... GNU
checking for gcc... arm-linux-musleabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/root/src/static-php/source/pkg-config':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.

试过用 SPC_CMD_PREFIX_PHP_CONFIGURE 环境变量增加 ,/configure --host=arm-linux-musleabi ,但好像无效?

crazywhalecc commented 3 months ago

鉴于目前支持的依赖库和扩展较多,且不同库对交叉编译的要求都不太一样,维护对交叉编译的支持较为困难,所以暂不支持交叉编译。