Php – How to fix this error trying to build php for a 64 bit Windows system

64-bitiisiis-6PHPwindows-server-2003

I need to run php in a website on our Windows 2003 64 bit server and while php offer 32 bit binaries for Windows, they aren't offering 64 bit ones at the moment.

I can't switch IIS 6 to run 32 bit applications as it then stops all my other asp.net sites working.

What I am doing is trying to build php from source for a 64 bit target by following this guide : http://wiki.php.net/internals/windows/stepbystepbuild

I used the Windows SDK build environment command window to build this and started by issuing the command:

setenv /x64 /xp /release

..to set the build target to "Targeting Windows XP x64 RELEASE"

I issued the configure line of:

configure --disable-all --enable-cli --enable-isapi

Which results in the failure during building (it builds fine if I omit –enable-isapi which I don't want to do):

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

SAPI sapi\cli build complete
cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
php5isapi.c
c:\php-sdk\php53dev\vc9\x64\php5.3\zend\zend_execute.h(234) : warning C4267: 'function' : conversion from 'size_t' to 'int', possibl
oss of data
sapi\isapi\php5isapi.c(286) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
sapi\isapi\php5isapi.c(300) : warning C4267: '=' : conversion from 'size_t' to 'DWORD', possible loss of data
sapi\isapi\php5isapi.c(789) : warning C4267: '=' : conversion from 'size_t' to 'DWORD', possible loss of data
sapi\isapi\php5isapi.c(791) : warning C4267: '=' : conversion from 'size_t' to 'DWORD', possible loss of data
sapi\isapi\php5isapi.c(863) : warning C4267: 'function' : conversion from 'size_t' to 'uint', possible loss of data
sapi\isapi\php5isapi.c(885) : error C4235: nonstandard extension used : '_asm' keyword not supported on this architecture
sapi\isapi\php5isapi.c(885) : error C2065: 'mov' : undeclared identifier
sapi\isapi\php5isapi.c(885) : error C2146: syntax error : missing ';' before identifier 'lpPage'
sapi\isapi\php5isapi.c(885) : error C2065: 'esp' : undeclared identifier
sapi\isapi\php5isapi.c(905) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
sapi\isapi\php5isapi.c(908) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
sapi\isapi\php5isapi.c(912) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\Bin\x86_amd64\cl.exe"' : return code '0x2'
Stop.

This looks like the problem: "nonstandard extension used : '_asm' keyword not supported on this architecture". I suspect I have not done enough to tell the build process to provide a 64 bit output can anyone suggest how to overcome this?

Best Answer

Your "_asm" refers to inline assembly language embedded in the C code.

"Inline assembly is not supported on the Itanium and x64 processors," per http://msdn.microsoft.com/en-us/library/4ks26t93(VS.80).aspx.

Therefore, you cannot simply recompile it; you would have to rework the code to remove the inline assembly code and replace it with C-language instructions. Not only would this be a lot of work, but it probably would undo the performance optimizations that were implemented using the inline assembly code. There's probably a way to use a separate assembler to build the assembly-language portions and then link them into the project, but that obviously would be light-years beyond our sysadmin realm.

I suspect that this is the reason why there is no official 64-bit build of PHP for Windows. I have heard of unofficial 64-bit Windows builds of PHP, but they are reputed to be unstable.

Have you considered setting up a separate 32-bit application pool specifically for PHP? That would enable you to run PHP in 32-bit compatibility mode without breaking your 64-bit ASP.NET applications.