[packages/php/PHP_5_4] - build on x32 with a help of slightly modified upstream patch

glen glen at pld-linux.org
Fri Feb 27 21:57:55 CET 2015


commit 0318ecf21250e721a1b9dfe004dfb1e33a3cd179
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sat Jan 3 22:03:01 2015 +0000

    - build on x32 with a help of slightly modified upstream patch
    
    Conflicts:
    	php.spec
    
    cherry-picked dc101b854cf29eca82f58ba779ef13c48ccd9181

 php.spec  |  9 +++++++--
 x32.patch | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 2 deletions(-)
---
diff --git a/php.spec b/php.spec
index f2b4aab..2bc1175 100644
--- a/php.spec
+++ b/php.spec
@@ -103,12 +103,12 @@
 %undefine	with_mm
 %endif
 
-%ifnarch %{ix86} %{x8664} sparc sparcv9 alpha
+%ifnarch %{ix86} %{x8664} x32 sparc sparcv9 alpha
 # ppc disabled (broken on th-ppc)
 %undefine	with_interbase
 %endif
 
-%ifnarch %{ix86} %{x8664}
+%ifnarch %{ix86} %{x8664} x32
 # unsupported, see sapi/cgi/fpm/fpm_atomic.h
 %undefine	with_fpm
 %endif
@@ -211,6 +211,7 @@ Patch63:	%{orgname}-mysql-nowarning.patch
 Patch65:	system-libzip.patch
 Patch66:	php-db.patch
 Patch67:	mysql-lib-ver-mismatch.patch
+Patch68:	x32.patch
 URL:		http://www.php.net/
 %{?with_interbase:%{!?with_interbase_inst:BuildRequires:	Firebird-devel >= 1.0.2.908-2}}
 %{?with_pspell:BuildRequires:	aspell-devel >= 2:0.50.0}
@@ -1932,6 +1933,7 @@ cp -p php.ini-production php.ini
 %{?with_system_libzip:%patch65 -p1}
 %patch66 -p1
 %patch67 -p1
+%patch68 -p1
 
 sed -i -e '/PHP_ADD_LIBRARY_WITH_PATH/s#xmlrpc,#xmlrpc-epi,#' ext/xmlrpc/config.m4
 
@@ -2007,6 +2009,9 @@ ix86= x8664=:
 %ifarch %{x8664}
 ix86=: x8664= \
 %endif
+%ifarch x32
+ix86=: x8664=: \
+%endif
 	sh -xe %{_sourcedir}/skip-tests.sh
 
 %build
diff --git a/x32.patch b/x32.patch
new file mode 100644
index 0000000..4b86bb6
--- /dev/null
+++ b/x32.patch
@@ -0,0 +1,62 @@
+From 514afd67b651bea834bdb84b7685b48e9e56ac21 Mon Sep 17 00:00:00 2001
+From: Gustavo Lopes <glopes at nebm.ist.utl.pt>
+Date: Tue, 30 Apr 2013 19:00:31 +0200
+Subject: [PATCH] Fix bug #64729: compilation failure on x32
+
+---
+ Zend/zend_alloc.c    | 18 ++++++++++++++----
+ Zend/zend_multiply.h |  4 ++--
+ 2 files changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
+index 605e396..0bbd59a 100644
+--- a/Zend/zend_alloc_canary.c
++++ b/Zend/zend_alloc_canary.c
+@@ -720,7 +720,7 @@ static inline unsigned int zend_mm_high_bit(size_t _size)
+ #elif defined(__GNUC__) && defined(__x86_64__)
+ 	unsigned long n;
+ 
+-        __asm__("bsrq %1,%0\n\t" : "=r" (n) : "rm"  (_size));
++        __asm__("bsr %1,%0\n\t" : "=r" (n) : "rm"  (_size));
+         return (unsigned int)n;
+ #elif defined(_MSC_VER) && defined(_M_IX86)
+ 	__asm {
+@@ -746,12 +746,12 @@ static inline unsigned int zend_mm_low_bit(size_t _size)
+ #elif defined(__GNUC__) && defined(__x86_64__)
+         unsigned long n;
+ 
+-        __asm__("bsfq %1,%0\n\t" : "=r" (n) : "rm"  (_size));
++        __asm__("bsf %1,%0\n\t" : "=r" (n) : "rm"  (_size));
+         return (unsigned int)n;
+ #elif defined(_MSC_VER) && defined(_M_IX86)
+ 	__asm {
+ 		bsf eax, _size
+-   }
++	}
+ #else
+ 	static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
+ 	unsigned int n;
+@@ -2481,12 +2481,22 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
+         size_t res = nmemb;
+         unsigned long overflow = 0;
+ 
+-        __asm__ ("mulq %3\n\taddq %4,%0\n\tadcq %1,%1"
++#ifdef __ILP32__ /* x32 */
++# define LP_SUFF "l"
++#else /* amd64 */
++# define LP_SUFF "q"
++#endif
++
++        __asm__ ("mul" LP_SUFF  " %3\n\t"
++                 "add %4,%0\n\t"
++                 "adc %1,%1"
+              : "=&a"(res), "=&d" (overflow)
+              : "%0"(res),
+                "rm"(size),
+                "rm"(offset));
+ 
++#undef LP_SUFF
++
+         if (UNEXPECTED(overflow)) {
+                 zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
+                 return 0;
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php.git/commitdiff/0318ecf21250e721a1b9dfe004dfb1e33a3cd179



More information about the pld-cvs-commit mailing list