php-force-cross-compile.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. php: force cross-compilation
  2. In its configure script, PHP detects whether we're cross-compiling or
  3. not, by compiling and running a simple C program. Depending on whether
  4. cross-compiling has been detected or not, then PHP enables or disables
  5. the AC_TRY_RUN tests (which verify the availability of something by
  6. *executing* a program, which, by definition, cannot work in
  7. cross-compilation mode).
  8. This works just fine when the target architecture is ARM or PowerPC
  9. and the build machine is x86 or x86_64. Unfortunately, when the target
  10. architecture is x86_64 and the build machine is also x86_64, the
  11. cross-compilation mode detection concludes that we are not
  12. cross-compiling, because it succeeds in running this small program.
  13. However, while it succeeds in running this basic small program, some
  14. other programs executed later through AC_TRY_RUN tests do not work,
  15. because they have target library dependencies that are not available
  16. on the build machine. For example, the libxml2 test fails to *run*
  17. because libxml2 is not available on the build machine, only in the
  18. target/staging directories. So trying to run a program linked against
  19. libxml2, on the build machine, simply doesn't make sense.
  20. We fix this problem by just forcing PHP to think that we're
  21. cross-compiling (which is always the case with Buildroot, as we're at
  22. the moment never building PHP for the host). Unfortunately, the
  23. configure.in file dates back from the autoconf 2.13 era, so the
  24. configure script does not understand the ac_cv_prog_cc_cross cache
  25. variable, and we cannot easily regenerate the configure script using
  26. our package autoconf version. The easiest solution is therefore to
  27. simply patch the configure script to make the cross-compilation test
  28. fail: we replace the execution of the program by a call to false,
  29. which always fail, leading the configure script to understand that we
  30. *are* cross-compiling.
  31. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  32. Index: b/configure
  33. ===================================================================
  34. --- a/configure
  35. +++ b/configure
  36. @@ -2387,7 +2387,7 @@
  37. if { (eval echo configure:2388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  38. ac_cv_prog_cc_works=yes
  39. # If we can't run a trivial program, we are probably using a cross compiler.
  40. - if (./conftest; exit) 2>/dev/null; then
  41. + if (false; exit) 2>/dev/null; then
  42. ac_cv_prog_cc_cross=no
  43. else
  44. ac_cv_prog_cc_cross=yes