php: use qemu wrapper to build minilua

minilua, by default, is compiled by the host machine as a
dependency for compiling the JIT/opcache extension. To
successfully cross-compile, this needs to be run under QEMU to
match the target architecture.

According to the [RFC](https://wiki.php.net/rfc/jit), only
x86 and x86_64 targets are supported.

Signed-off-by: Ashley Cox <ashleyc@cybernetics.com>
Signed-off-by: Claude Bing <cbing@cybernetics.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Claude Bing 2021-11-16 09:21:39 -05:00 committed by Khem Raj
parent ab1057d1b5
commit 265bab83c9
3 changed files with 25 additions and 23 deletions

View File

@ -0,0 +1,11 @@
--- a/ext/opcache/jit/Makefile.frag 2021-10-19 06:34:32.000000000 -0400
+++ b/ext/opcache/jit/Makefile.frag 2021-11-15 15:10:41.437289836 -0500
@@ -3,7 +3,7 @@ $(builddir)/minilua: $(srcdir)/jit/dynas
$(CC) $(srcdir)/jit/dynasm/minilua.c -lm -o $@
$(builddir)/jit/zend_jit_x86.c: $(srcdir)/jit/zend_jit_x86.dasc $(srcdir)/jit/dynasm/*.lua $(builddir)/minilua
- $(builddir)/minilua $(srcdir)/jit/dynasm/dynasm.lua $(DASM_FLAGS) -o $@ $(srcdir)/jit/zend_jit_x86.dasc
+ $(top_srcdir)/qemuwrapper $(builddir)/minilua $(srcdir)/jit/dynasm/dynasm.lua $(DASM_FLAGS) -o $@ $(srcdir)/jit/zend_jit_x86.dasc
$(builddir)/jit/zend_jit.lo: \
$(builddir)/jit/zend_jit_x86.c \

View File

@ -1,20 +0,0 @@
From 73ea1d44c1e6b063bfa02e12919ec8a9de3709d8 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Wed, 3 Feb 2021 22:51:34 +0100
Subject: [PATCH] Fix opcache jit minilua compiling
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
ext/opcache/jit/Makefile.frag | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/ext/opcache/jit/Makefile.frag
+++ b/ext/opcache/jit/Makefile.frag
@@ -1,6 +1,6 @@
$(builddir)/minilua: $(srcdir)/jit/dynasm/minilua.c
- $(CC) $(srcdir)/jit/dynasm/minilua.c -lm -o $@
+ $(HOSTCC) $(srcdir)/jit/dynasm/minilua.c -lm -o $@
$(builddir)/jit/zend_jit_x86.c: $(srcdir)/jit/zend_jit_x86.dasc $(srcdir)/jit/dynasm/*.lua $(builddir)/minilua
$(builddir)/minilua $(srcdir)/jit/dynasm/dynasm.lua $(DASM_FLAGS) -o $@ $(srcdir)/jit/zend_jit_x86.dasc

View File

@ -6,7 +6,7 @@ LICENSE = "PHP-3.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=99532e0f6620bc9bca34f12fadaee33c"
BBCLASSEXTEND = "native"
DEPENDS = "zlib bzip2 libxml2 virtual/libiconv php-native lemon-native"
DEPENDS = "zlib bzip2 libxml2 virtual/libiconv php-native lemon-native qemu-native"
DEPENDS:class-native = "zlib-native libxml2-native"
PHP_MAJOR_VERSION = "${@d.getVar('PV').split('.')[0]}"
@ -25,7 +25,7 @@ SRC_URI:append:class-target = " \
file://0006-ext-phar-Makefile.frag-Fix-phar-packaging.patch \
file://0007-sapi-cli-config.m4-fix-build-directory.patch \
file://0008-ext-imap-config.m4-fix-include-paths.patch \
file://1010-Fix-opcache-jit-minilua-compiling.patch \
file://0011-use-qemuwrapper-for-minilua.patch \
file://php-fpm.conf \
file://php-fpm-apache.conf \
file://70_mod_php${PHP_MAJOR_VERSION}.conf \
@ -36,7 +36,7 @@ S = "${WORKDIR}/php-${PV}"
SRC_URI[sha256sum] = "b4886db1df322dc8fb128d8b34ae7e94f6fc682ecb29ff4f5a591d4de9feadbf"
inherit autotools pkgconfig python3native gettext
inherit autotools pkgconfig python3native gettext qemu
# phpize is not scanned for absolute paths by default (but php-config is).
#
@ -128,6 +128,17 @@ do_configure:prepend () {
find ${S} -name config.m4 | xargs -n1 sed -i 's!APXS_HTTPD=.*!APXS_HTTPD=${STAGING_SBINDIR_NATIVE}/httpd!'
}
do_configure:prepend:class-target () {
# Write out a qemu wrapper that will be used by the makefile
# so that it can run minilua through that.
qemu_binary="${@qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST'), [d.expand('${STAGING_DIR_HOST}${libdir}'),d.expand('${STAGING_DIR_HOST}${base_libdir}')])}"
cat > ${S}/qemuwrapper << EOF
#!/bin/sh
$qemu_binary "\$@"
EOF
chmod +x ${S}/qemuwrapper
}
do_configure:append() {
# No, libtool, we really don't want rpath set...
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' ${HOST_SYS}-libtool