Has anyone compiled x32 php?

116 views
Skip to first unread message

H.J. Lu

unread,
Aug 1, 2012, 12:17:43 AM8/1/12
to x32...@googlegroups.com
Hi,

Has anyone compiled x32 php? Does everything work?

--
H.J.

Daniel Schepler

unread,
Aug 1, 2012, 2:15:14 PM8/1/12
to x32...@googlegroups.com
On Tuesday, July 31, 2012 9:17:43 PM UTC-7, H.J. wrote:
Hi,

Has anyone compiled x32 php? Does everything work?

FWIW, when my semi-auto-builder tried building the Debian package (version 5.4.4-3), it failed building ext/standard/math.c:

 /tmp/buildd/php5-5.4.4/ext/standard/math.c: Assembler messages:
/tmp/buildd/php5-5.4.4/ext/standard/math.c:628: Error: incorrect register `%esi' used with `q' suffix
/tmp/buildd/php5-5.4.4/ext/standard/math.c:629: Error: incorrect register `%edx' used with `q' suffix
/tmp/buildd/php5-5.4.4/ext/standard/math.c:632: Error: incorrect register `%edx' used with `q' suffix
/tmp/buildd/php5-5.4.4/ext/standard/math.c:633: Error: incorrect register `%esi' used with `q' suffix
--
Daniel Schepler

H. Peter Anvin

unread,
Aug 1, 2012, 2:16:37 PM8/1/12
to x32...@googlegroups.com, Daniel Schepler
Odds are pretty good they can just be fixed by removing the q's and just
use, say "mov" instead of "movq".

-hpa

Daniel Schepler

unread,
Nov 15, 2012, 3:49:15 PM11/15/12
to x32...@googlegroups.com
OK, I finally got around to looking at this.  With the patch below, php compiles, but the cgi build still gives an error message:

Generating phar.php
Generating phar.phar
Unknown command 'pack', check ext/phar/phar.php help
make[1]: *** [ext/phar/phar.phar] Error 1
make[1]: Leaving directory `/tmp/buildd/php5-5.4.4/cgi-build'
make: *** [build-cgi-stamp] Error 2

So it looks like there's still brokenness in there.

Index: php5-5.4.4/Zend/zend_multiply.h
===================================================================
--- php5-5.4.4.orig/Zend/zend_multiply.h        2012-11-15 19:25:39.000000000 +0000
+++ php5-5.4.4/Zend/zend_multiply.h     2012-11-15 19:30:18.000000000 +0000
@@ -31,7 +31,7 @@
        else (lval) = __tmpvar;                                                \
 } while (0)
 
-#elif defined(__x86_64__) && defined(__GNUC__)
+#elif defined(__x86_64__) && ! defined(__ILP32__) && defined(__GNUC__)
 
 #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do {      \
        long __tmpvar;                                                         \
Index: php5-5.4.4/Zend/zend_alloc.c
===================================================================
--- php5-5.4.4.orig/Zend/zend_alloc.c   2012-06-13 04:54:23.000000000 +0000
+++ php5-5.4.4/Zend/zend_alloc.c        2012-11-15 19:57:24.000000000 +0000
@@ -672,7 +672,7 @@
 #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 {
@@ -698,7 +698,7 @@
 #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 {
@@ -2481,7 +2481,7 @@
         size_t res = nmemb;
         unsigned long overflow = 0;
 
-        __asm__ ("mulq %3\n\taddq %4,%0\n\tadcq %1,%1"
+        __asm__ ("mul %3\n\tadd %4,%0\n\tadc %1,%1"
              : "=&a"(res), "=&d" (overflow)
              : "%0"(res),
                "rm"(size),
--
Daniel Schepler

Daniel Schepler

unread,
Nov 15, 2012, 3:52:49 PM11/15/12
to x32...@googlegroups.com
(Slaps forehead...)  Of course just removing the q suffix on the one-register mul operation won't do the right thing.  Looking at the surrounding code, it looks like I should probably just force it to the general code which handles the case where long64 is available and long is 32-bit.  As I already did in the part of the patch for zend_multiply.h.
--
Daniel Schepler


Daniel Schepler

unread,
Nov 15, 2012, 4:53:19 PM11/15/12
to x32...@googlegroups.com
Even with the corrected patch below, I'm still getting the error regarding "Unknown command 'pack', check ext/phar/phar.php help".

Index: php5-5.4.4/Zend/zend_multiply.h
===================================================================
--- php5-5.4.4.orig/Zend/zend_multiply.h        2012-11-15 20:06:31.000000000 +0000
+++ php5-5.4.4/Zend/zend_multiply.h     2012-11-15 20:08:25.000000000 +0000

@@ -31,7 +31,7 @@
        else (lval) = __tmpvar;                                                \
 } while (0)
 
-#elif defined(__x86_64__) && defined(__GNUC__)
+#elif defined(__x86_64__) && ! defined(__ILP32__) && defined(__GNUC__)
 
 #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do {      \
        long __tmpvar;                                                         \
Index: php5-5.4.4/Zend/zend_alloc.c
===================================================================
--- php5-5.4.4.orig/Zend/zend_alloc.c   2012-11-15 20:06:31.000000000 +0000
+++ php5-5.4.4/Zend/zend_alloc.c        2012-11-15 20:53:49.000000000 +0000

@@ -672,7 +672,7 @@
 #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 {
@@ -698,7 +698,7 @@
 #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 {
@@ -2474,7 +2474,7 @@
        return res;
 }
 
-#elif defined(__GNUC__) && defined(__x86_64__)
+#elif defined(__GNUC__) && defined(__x86_64__) && ! defined(__ILP32__)
 
 static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
 {

Reply all
Reply to author
Forward
0 new messages