title: Cross-compile PHP for ARM
body: <p>I'm trying to cross-compile PHP for ARM. Here what I did:</p>
  
  <pre><code>$ apt install re2c
  $ mkdir ~/lamp
  $ git clone https://github.com/php/php-src.git
  $ cd php-src
  $ ./buildconf
  $ ./configure --prefix ~/lamp/sysroot --host=arm --build=x86_64
  </code></pre>
  
  <p>The system vars are set by the init script of the cross-compiler. For example:</p>
  
  <pre><code>$ echo $CC
  arm-openstlinux_weston-linux-gnueabi-gcc -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi
  
  $ echo $CFLAGS
  -O2 -pipe -g -feliminate-unused-debug-types
  </code></pre>
  
  <p>The <code>configure</code> stage exits successfully.
  But when I try to build I get:</p>
  
  <pre><code>$ make
  /bin/bash /home/osboxes/lamp/php-src/libtool --silent --preserve-dup-deps --mode=compile arm-openstlinux_weston-linux-gnueabi-gcc -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iext/opcache/ -I/home/osboxes/lamp/php-src/ext/opcache/ -DPHP_ATOM_INC -I/home/osboxes/lamp/php-src/include -I/home/osboxes/lamp/php-src/main -I/home/osboxes/lamp/php-src -I/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/valgrind -I/home/osboxes/lamp/php-src/ext/date/lib -I/local/STM32MP15-Ecosystem-v1.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/usr/include/libxml2 -I/home/osboxes/lamp/php-src/TSRM -I/home/osboxes/lamp/php-src/Zend    -I/usr/include -O2 -pipe -g -feliminate-unused-debug-types -fvisibility=hidden -Wall -Wno-strict-aliasing -DZEND_SIGNALS    -c /home/osboxes/lamp/php-src/ext/opcache/ZendAccelerator.c -o ext/opcache/ZendAccelerator.lo 
  cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
  In file included from /home/osboxes/lamp/php-src/Zend/zend.h:30,
                   from /home/osboxes/lamp/php-src/main/php.h:31,
                   from /home/osboxes/lamp/php-src/ext/opcache/ZendAccelerator.c:22:
  /home/osboxes/lamp/php-src/ext/opcache/ZendAccelerator.c: In function ‘store_script_in_file_cache’:
  /home/osboxes/lamp/php-src/Zend/zend_alloc.h:30:38: error: missing binary operator before token "8"
   # define ZEND_MM_ALIGNMENT ((size_t) 8)
                                        ^
  /home/osboxes/lamp/php-src/ext/opcache/ZendAccelerator.c:1371:7: note: in expansion of macro ‘ZEND_MM_ALIGNMENT’
   #elif ZEND_MM_ALIGNMENT &lt; 8
         ^~~~~~~~~~~~~~~~~
  Makefile:794: recipe for target 'ext/opcache/ZendAccelerator.lo' failed
  make: *** [ext/opcache/ZendAccelerator.lo] Error 1
  </code></pre>
  
  <p>As far as I understand the problem might rely on the include directory (<code>/usr/include</code>) that is related to the host system instead of the target one (sysroot).</p>
  
  <p>I looked through the <code>configure -h</code> options but I didn't find anything related to sysroot or include directories.</p>